爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

644 lines
20 KiB

3 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="inspection-page">
  3. <!-- 固定顶部区域 -->
  4. <view class="fixed-header">
  5. <!-- 顶部渐变导航栏 -->
  6. <view class="nav-bar" :style="{ height: navBarTotalHeight + 'px', paddingTop: statusBarHeight + 'px' }">
  7. <view class="nav-bar-inner">
  8. <view class="back-icon" @tap="navigateBack">
  9. <uni-icons type="left" size="22" color="#fff" />
  10. </view>
  11. <view class="nav-bar-title">质检报告</view>
  12. <view class="nav-bar-right">
  13. <uni-icons type="more-filled" size="22" color="#fff" />
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 打钩标签区及说明 -->
  18. <view class="feature-area">
  19. <view class="feature-desc">该报告由{{ applet_title }}质检查验出具</view>
  20. <view class="feature-tags">
  21. <view class="tag" v-for="(t, i) in featureTags" :key="i">
  22. <text class="check"></text>
  23. <text class="text">{{ t }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 主内容区卡片悬浮覆盖打钩区 -->
  29. <scroll-view scroll-y class="main-content" enhanced :show-scrollbar="false">
  30. <view class="content-wrapper">
  31. <view v-if="showQualified && goodsList.length" class="inspection-card">
  32. <view class="report-title">质检合格</view>
  33. <view class="goods-list">
  34. <view class="goods-item" v-for="(item, i) in displayedGoodsList" :key="i"
  35. @tap="goToInspectionDetail('qualified', item)">
  36. <image class="goods-img" :src="item.img" mode="aspectFit" />
  37. <view class="goods-info">
  38. <view class="goods-row">
  39. <view class="goods-name">{{ item.name }}</view>
  40. <view v-if="item.detail" class="detail-link">查看详情 <uni-icons type="right" size="16" color="#bbb" />
  41. </view>
  42. </view>
  43. <!-- <view class="goods-desc">{{item.desc}}</view> -->
  44. <view class="goods-bottom-row">
  45. <view class="goods-price-row">
  46. <text class="goods-price" v-if="item.price">{{ (item.price / item.count).toFixed(2) }}</text>
  47. <text class="goods-unit" v-if="item.price && item.unit">/{{ item.unit }}</text>
  48. <text class="goods-count">x{{ item.count }}</text>
  49. </view>
  50. <!-- <view class="goods-total">{{item.total}}</view> -->
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="goodsList.length > 2" class="collapse-btn" @tap="qualifiedCollapsed = !qualifiedCollapsed">
  56. <text>{{ qualifiedCollapsed ? '展开(共' + goodsList.length + '件)' : '收起' }}</text>
  57. <uni-icons :type="qualifiedCollapsed ? 'arrowdown' : 'arrowup'" size="16" color="#bbb" />
  58. </view>
  59. <view class="summary-row">
  60. <text>件数<text class="highlight">{{ totalCount }}</text> </text>
  61. <text>结算金额<text class="highlight">{{ totalAmount }}</text></text>
  62. </view>
  63. </view>
  64. <view v-if="showProblem && problemList.length" class="inspection-card problem-card">
  65. <view class="report-title">质量问题</view>
  66. <view class="goods-list">
  67. <view class="goods-item" v-for="(item, i) in displayedProblemList" :key="i"
  68. @tap="goToInspectionDetail('problem', item)">
  69. <image class="goods-img" :src="item.img || bkhs_image" mode="aspectFit" />
  70. <view class="goods-info">
  71. <view class="goods-row">
  72. <view class="goods-name">{{ item.name }}</view>
  73. <view v-if="item.detail" class="detail-link">查看详情 <uni-icons type="right" size="16" color="#bbb" />
  74. </view>
  75. </view>
  76. <!-- <view class="goods-desc">{{item.desc}}</view> -->
  77. <view class="goods-bottom-row">
  78. <view class="goods-price-row problem-price-row">
  79. <text class="goods-price" v-if="item.price">{{ (item.price / item.count).toFixed(2) }}</text>
  80. <text class="goods-unit" v-if="item.price">/</text>
  81. <text class="goods-count">x{{ item.count }}</text>
  82. </view>
  83. <!-- <view class="goods-total">{{item.total}}</view> -->
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view v-if="problemList.length > 2" class="collapse-btn" @tap="problemCollapsed = !problemCollapsed">
  89. <text>{{ problemCollapsed ? '展开(共' + problemList.length + '件)' : '收起' }}</text>
  90. <uni-icons :type="problemCollapsed ? 'arrowdown' : 'arrowup'" size="16" color="#bbb" />
  91. </view>
  92. <view class="summary-row">
  93. <text>件数<text class="highlight">{{ problemCount }}</text> </text>
  94. <text>结算金额<text class="highlight">{{ problemAmount }}</text></text>
  95. </view>
  96. </view>
  97. <view v-if="showUnrecyclable && unrecyclableList.length" class="inspection-card problem-card">
  98. <view class="report-title">不可回收</view>
  99. <view class="goods-list">
  100. <view class="goods-item" v-for="(item, i) in displayedUnrecyclableList" :key="i"
  101. @tap="goToInspectionDetail('unrecyclable', item)">
  102. <image class="goods-img" :src="item.img || bkhs_image" mode="aspectFit" />
  103. <view class="goods-info">
  104. <view class="goods-row">
  105. <view class="goods-name">{{ item.name }}</view>
  106. <view v-if="item.detail" class="detail-link">查看详情 <uni-icons type="right" size="16" color="#bbb" />
  107. </view>
  108. </view>
  109. <!-- <view class="goods-desc">{{item.desc}}</view> -->
  110. <view class="goods-bottom-row">
  111. <view class="goods-price-row problem-price-row">
  112. <text class="goods-price" v-if="item.price">{{ (item.price / item.count).toFixed(2) }}</text>
  113. <text class="goods-unit" v-if="item.price">/</text>
  114. <text class="goods-count">x{{ item.count }}</text>
  115. </view>
  116. <!-- <view class="goods-total">{{item.total}}</view> -->
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <view v-if="unrecyclableList.length > 2" class="collapse-btn"
  122. @tap="unrecyclableCollapsed = !unrecyclableCollapsed">
  123. <text>{{ unrecyclableCollapsed ? '展开(共' + unrecyclableList.length + '件)' : '收起' }}</text>
  124. <uni-icons :type="unrecyclableCollapsed ? 'arrowdown' : 'arrowup'" size="16" color="#bbb" />
  125. </view>
  126. <view class="summary-row">
  127. <text>件数<text class="highlight">{{ unrecyclableCount }}</text> </text>
  128. <text>结算金额<text class="highlight">{{ unrecyclableAmount }}</text></text>
  129. </view>
  130. </view>
  131. </view>
  132. </scroll-view>
  133. </view>
  134. </template>
  135. <script>
  136. import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'
  137. export default {
  138. mixins: [pullRefreshMixin],
  139. data() {
  140. return {
  141. statusBarHeight: 0,
  142. navBarHeight: 14,
  143. navBarTotalHeight: 14,
  144. featureTags: ['透明检', '专业验', '公正评', '逐件验'],
  145. goodsList: [], // 质检合格
  146. problemList: [], // 质量问题
  147. unrecyclableList: [], // 不可回收
  148. reportData: null,
  149. showQualified: false,
  150. showProblem: false,
  151. showUnrecyclable: false,
  152. orderId: 0,
  153. fixedHeaderHeight: 0, // 固定头部的高度
  154. qualifiedCollapsed: true,
  155. problemCollapsed: true,
  156. unrecyclableCollapsed: true,
  157. isSelf: false,
  158. }
  159. },
  160. computed: {
  161. applet_title() {
  162. const item = getApp().globalData.configData.find(i => i.keyName === 'applet_title')
  163. return item ? item.keyContent : ''
  164. },
  165. totalCount() {
  166. return this.goodsList.reduce((sum, item) => sum + item.count, 0)
  167. },
  168. totalAmount() {
  169. return this.goodsList.reduce((sum, item) => sum + item.price, 0).toFixed(2)
  170. },
  171. problemCount() {
  172. return this.problemList.reduce((sum, item) => sum + item.count, 0)
  173. },
  174. problemAmount() {
  175. return this.problemList.reduce((sum, item) => sum + item.price, 0).toFixed(2)
  176. },
  177. unrecyclableCount() {
  178. return this.unrecyclableList.reduce((sum, item) => sum + item.count, 0)
  179. },
  180. unrecyclableAmount() {
  181. return this.unrecyclableList.reduce((sum, item) => sum + item.price, 0).toFixed(2)
  182. },
  183. fixedHeaderHeight() {
  184. // 导航栏高度 + 状态栏高度 + 特性区域高度 (约140rpx转px)
  185. return this.statusBarHeight + this.navBarHeight + 70
  186. },
  187. displayedGoodsList() {
  188. return this.qualifiedCollapsed ? this.goodsList.slice(0, 2) : this.goodsList;
  189. },
  190. displayedProblemList() {
  191. return this.problemCollapsed ? this.problemList.slice(0, 2) : this.problemList;
  192. },
  193. displayedUnrecyclableList() {
  194. return this.unrecyclableCollapsed ? this.unrecyclableList.slice(0, 2) : this.unrecyclableList;
  195. },
  196. bkhs_image() {//不可回收图片
  197. const item = getApp().globalData.configData.find(i => i.keyName === 'bkhs_image')
  198. return item ? item.keyContent : ''
  199. },
  200. zlwt_image() {//质量问题图片
  201. const item = getApp().globalData.configData.find(i => i.keyName === 'zlwt_image')
  202. return item ? item.keyContent : ''
  203. },
  204. },
  205. onLoad(options) {
  206. const sysInfo = uni.getSystemInfoSync()
  207. this.statusBarHeight = sysInfo.statusBarHeight
  208. this.navBarHeight = 14
  209. this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight
  210. // 获取 orderId
  211. const orderId = options.orderId
  212. this.isSelf = options.isSelf
  213. this.orderId = orderId
  214. if (orderId) {
  215. this.fetchQualityReport(orderId)
  216. }
  217. },
  218. methods: {
  219. async fetchQualityReport(orderId) {
  220. // 调用订单详情接口
  221. this.$api && this.$api('getOrderDetail', {
  222. orderId: this.orderId
  223. }, res => {
  224. if (res && res.code === 200 && res.result) {
  225. this.reportData = res.result
  226. // 解析嵌套的订单数据
  227. this.parseOrderData(res.result)
  228. }
  229. })
  230. },
  231. parseOrderData(orderData) {
  232. this.goodsList = []
  233. this.problemList = []
  234. this.unrecyclableList = []
  235. if (orderData.orderCheckList && orderData.orderCheckList.length > 0) {
  236. orderData.orderCheckList.forEach(item => {
  237. // 合格
  238. if (Number(item.qualifiedNum) > 0) {
  239. this.goodsList.push({
  240. img: item.image || '/static/default-goods.png',
  241. name: item.title || '未知品类',
  242. desc: item.pinName ? `${item.pinName}` : '',
  243. price: item.price || 0,
  244. count: item.qualifiedNum,
  245. total: (item.price || 0) * item.qualifiedNum,
  246. detail: true,
  247. testingInstructions: '',
  248. testingImages: (item.commonOrderList && item.commonOrderList[0] && item.commonOrderList[0].testingImages) || '',
  249. testingTime: (item.commonOrderList && item.commonOrderList[0] && item.commonOrderList[0].testingTime) || '',
  250. problemDesc: ''
  251. })
  252. }
  253. // 质量问题和不可回收
  254. if (Array.isArray(item.commonOrderList)) {
  255. item.commonOrderList.forEach(sub => {
  256. // 质量问题
  257. if (sub.testingStatus == 1) {
  258. this.problemList.push({
  259. img: item.image,
  260. name: item.title || '未知品类',
  261. desc: item.pinName ? `${item.pinName}` : '',
  262. price: item.price || 0,
  263. count: sub.num || 1,
  264. total: (item.price || 0) * (sub.num || 1),
  265. detail: true,
  266. testingInstructions: sub.testingInstructions || '',
  267. testingImages: sub.testingImages || '',
  268. testingTime: sub.testingTime || '',
  269. problemDesc: sub.testingInstructions || ''
  270. })
  271. }
  272. // 不可回收
  273. if (sub.testingStatus == 2) {
  274. this.unrecyclableList.push({
  275. img: item.image,
  276. name: item.title || '未知品类',
  277. desc: item.pinName ? `${item.pinName}` : '',
  278. price: item.price || 0,
  279. count: sub.num || 1,
  280. total: (item.price || 0) * (sub.num || 1),
  281. detail: true,
  282. testingInstructions: sub.testingInstructions || '',
  283. testingImages: sub.testingImages || '',
  284. testingTime: sub.testingTime || '',
  285. problemDesc: sub.testingInstructions || ''
  286. })
  287. }
  288. })
  289. }
  290. })
  291. }
  292. this.showQualified = this.goodsList.length > 0
  293. this.showProblem = this.problemList.length > 0
  294. this.showUnrecyclable = this.unrecyclableList.length > 0
  295. },
  296. async onRefresh() {
  297. // 模拟刷新数据
  298. await new Promise(resolve => setTimeout(resolve, 1000))
  299. uni.stopPullRefresh()
  300. },
  301. navigateBack() {
  302. uni.navigateBack()
  303. },
  304. goToInspectionDetail(status, item) {
  305. if (!item) return;
  306. const userId = this.reportData && this.reportData.userId;
  307. const data = { ...item, userId };
  308. let url = `/pages/subcomponent/inspection-detail?status=${status}&data=${encodeURIComponent(JSON.stringify(data))}`
  309. if (this.isSelf) {
  310. console.log(this.isSelf, 'this.isSelf');
  311. url += `&isSelf=true`
  312. }
  313. uni.navigateTo({
  314. url
  315. })
  316. }
  317. }
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. .inspection-page {
  322. min-height: 100vh;
  323. background: #422525;
  324. position: relative;
  325. }
  326. .fixed-header {
  327. position: fixed;
  328. top: 0;
  329. left: 0;
  330. right: 0;
  331. z-index: 1000;
  332. background: #422525;
  333. }
  334. .nav-bar {
  335. width: 100vw;
  336. background: #422525;
  337. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  338. .nav-bar-inner {
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. height: 44px;
  343. width: 100vw;
  344. position: relative;
  345. }
  346. .back-icon,
  347. .nav-bar-right {
  348. width: 44px;
  349. height: 44px;
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. position: absolute;
  354. top: 0;
  355. }
  356. .back-icon {
  357. left: 0;
  358. }
  359. .nav-bar-right {
  360. right: 0;
  361. }
  362. .nav-bar-title {
  363. flex: 1;
  364. text-align: center;
  365. font-size: 36rpx;
  366. font-weight: bold;
  367. color: #fff;
  368. letter-spacing: 2rpx;
  369. line-height: 44px;
  370. font-family: DingTalk JinBuTi;
  371. font-weight: 400;
  372. font-style: italic;
  373. font-size: 28px;
  374. line-height: 100%;
  375. letter-spacing: 0%;
  376. text-align: center;
  377. // vertical-align: bottom;
  378. }
  379. }
  380. .feature-area {
  381. margin: 0 32rpx;
  382. background: #422525;
  383. border-radius: 32rpx;
  384. padding: 18rpx 24rpx 18rpx 24rpx;
  385. display: flex;
  386. flex-direction: column;
  387. align-items: stretch;
  388. justify-content: center;
  389. }
  390. .feature-desc {
  391. text-align: center;
  392. font-size: 22rpx;
  393. color: #fff;
  394. font-weight: 500;
  395. margin-bottom: 10rpx;
  396. margin-top: 18rpx;
  397. letter-spacing: 1rpx;
  398. }
  399. .feature-tags {
  400. // margin: 0 32rpx;
  401. background: #533030;
  402. border-radius: 12rpx;
  403. box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.08);
  404. // padding: 0 24rpx;
  405. width: 100%;
  406. height: 80rpx;
  407. display: flex;
  408. flex-direction: row;
  409. justify-content: space-between;
  410. align-items: center;
  411. .tag {
  412. flex: 1;
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. .check {
  417. width: 36rpx;
  418. height: 36rpx;
  419. background: #fff;
  420. border-radius: 50%;
  421. display: flex;
  422. align-items: center;
  423. justify-content: center;
  424. font-size: 28rpx;
  425. color: #422525;
  426. font-weight: bold;
  427. margin-right: 10rpx;
  428. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  429. }
  430. .text {
  431. color: #fff;
  432. font-size: 28rpx;
  433. font-weight: bold;
  434. }
  435. }
  436. }
  437. .main-content {
  438. background: linear-gradient(180deg, #fef7e6 0%, #fff 50%);
  439. position: absolute;
  440. top: 220rpx;
  441. left: 0;
  442. right: 0;
  443. bottom: 0;
  444. border-radius: 40rpx 40rpx 0 0;
  445. z-index: 11;
  446. }
  447. .content-wrapper {
  448. display: flex;
  449. flex-direction: column;
  450. align-items: center;
  451. padding: 30rpx 0;
  452. padding-bottom: calc(env(safe-area-inset-bottom) + 60rpx);
  453. }
  454. .inspection-card {
  455. background: #fff;
  456. border-radius: 32rpx;
  457. box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08);
  458. padding: 40rpx 32rpx 32rpx 32rpx;
  459. margin: 150rpx auto 0 auto;
  460. width: calc(100vw - 64rpx);
  461. max-width: 700rpx;
  462. display: flex;
  463. flex-direction: column;
  464. flex-shrink: 0;
  465. .report-title {
  466. font-size: 32rpx;
  467. font-weight: bold;
  468. color: #222;
  469. text-align: center;
  470. margin-bottom: 12rpx;
  471. }
  472. .goods-list {
  473. .goods-item {
  474. display: flex;
  475. align-items: center;
  476. background: #fff;
  477. border-radius: 20rpx;
  478. box-shadow: 0 2rpx 8rpx rgba(60, 167, 250, 0.04);
  479. padding: 24rpx 20rpx;
  480. margin-bottom: 20rpx;
  481. .goods-img {
  482. width: 80rpx;
  483. height: 80rpx;
  484. border-radius: 16rpx;
  485. margin-right: 20rpx;
  486. background: #f5f5f5;
  487. }
  488. .goods-info {
  489. flex: 1;
  490. display: flex;
  491. flex-direction: column;
  492. .goods-row {
  493. display: flex;
  494. justify-content: space-between;
  495. align-items: center;
  496. .goods-name {
  497. font-size: 28rpx;
  498. color: #222;
  499. font-weight: bold;
  500. }
  501. .detail-link {
  502. font-size: 24rpx;
  503. color: #bbb;
  504. display: flex;
  505. align-items: center;
  506. }
  507. }
  508. .goods-desc {
  509. font-size: 24rpx;
  510. color: #bbb;
  511. margin-bottom: 8rpx;
  512. }
  513. .goods-bottom-row {
  514. display: flex;
  515. justify-content: space-between;
  516. align-items: flex-end;
  517. margin-top: 8rpx;
  518. .goods-price-row {
  519. display: flex;
  520. align-items: baseline;
  521. .goods-price {
  522. font-size: 26rpx;
  523. color: #bbb;
  524. font-weight: bold;
  525. }
  526. .goods-unit {
  527. font-size: 24rpx;
  528. color: #bbb;
  529. margin-left: 2rpx;
  530. }
  531. .goods-count {
  532. font-size: 22rpx;
  533. color: #bbb;
  534. margin-left: 8rpx;
  535. font-weight: normal;
  536. }
  537. }
  538. .goods-total {
  539. font-size: 28rpx;
  540. color: #222;
  541. font-weight: bold;
  542. margin-left: 24rpx;
  543. }
  544. }
  545. }
  546. }
  547. .goods-item:last-child {
  548. margin-bottom: 0;
  549. }
  550. }
  551. .summary-row {
  552. display: flex;
  553. justify-content: space-between;
  554. align-items: center;
  555. margin-top: 24rpx;
  556. font-size: 28rpx;
  557. color: #222;
  558. .highlight {
  559. color: #f79400;
  560. font-weight: bold;
  561. font-size: 30rpx;
  562. }
  563. }
  564. }
  565. .check {
  566. width: 36rpx;
  567. height: 36rpx;
  568. background: #fff;
  569. border-radius: 50%;
  570. display: flex;
  571. align-items: center;
  572. justify-content: center;
  573. font-size: 28rpx;
  574. color: #13ac47;
  575. font-weight: bold;
  576. margin-right: 10rpx;
  577. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  578. }
  579. .problem-card {
  580. margin-top: 24rpx;
  581. margin-bottom: 40rpx;
  582. }
  583. .problem-price-row {
  584. color: #bbb !important;
  585. }
  586. .collapse-btn {
  587. text-align: center;
  588. color: #bbb;
  589. font-size: 24rpx;
  590. margin: 10rpx 0;
  591. cursor: pointer;
  592. display: flex;
  593. align-items: center;
  594. justify-content: center;
  595. gap: 8rpx;
  596. }
  597. </style>