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

643 lines
19 KiB

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