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

558 lines
17 KiB

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