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

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