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

493 lines
14 KiB

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