爱简收旧衣按件回收前端代码仓库
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.

594 lines
18 KiB

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