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

587 lines
18 KiB

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