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

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