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

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