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

497 lines
14 KiB

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