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

508 lines
14 KiB

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