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

487 lines
14 KiB

5 days 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>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="summary-row">
  49. <text>件数<text class="highlight">{{totalCount}}</text> </text>
  50. <text>结算金额<text class="highlight">{{totalAmount}}</text></text>
  51. </view>
  52. </view>
  53. <view v-if="showProblem && problemList.length" class="inspection-card problem-card">
  54. <view class="report-title">质量问题</view>
  55. <view class="goods-list">
  56. <view class="goods-item" v-for="(item, i) in problemList" :key="i" @tap="goToInspectionDetail('problem')">
  57. <image class="goods-img" :src="item.img" mode="aspectFit" />
  58. <view class="goods-info">
  59. <view class="goods-row">
  60. <view class="goods-name">{{item.name}}</view>
  61. <view v-if="item.detail" class="detail-link">查看详情 <uni-icons type="right" size="16" color="#bbb" /></view>
  62. </view>
  63. <view class="goods-desc">{{item.desc}}</view>
  64. <view class="goods-bottom-row">
  65. <view class="goods-price-row problem-price-row">
  66. <text class="goods-price">{{item.price}}</text>
  67. <text class="goods-unit">/</text>
  68. <text class="goods-count">x{{item.count}}</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="summary-row">
  75. <text>件数<text class="highlight">{{problemCount}}</text> </text>
  76. <text>结算金额<text class="highlight">{{problemAmount}}</text></text>
  77. </view>
  78. </view>
  79. <view v-if="showUnrecyclable && unrecyclableList.length" class="inspection-card problem-card">
  80. <view class="report-title">不可回收</view>
  81. <view class="goods-list">
  82. <view class="goods-item" v-for="(item, i) in unrecyclableList" :key="i">
  83. <image class="goods-img" :src="item.img" mode="aspectFit" />
  84. <view class="goods-info">
  85. <view class="goods-row">
  86. <view class="goods-name">{{item.name}}</view>
  87. </view>
  88. <view class="goods-desc">{{item.desc}}</view>
  89. <view class="goods-bottom-row">
  90. <view class="goods-price-row">
  91. <text class="goods-price">{{item.price}}</text>
  92. <text class="goods-unit">/</text>
  93. <text class="goods-count">x{{item.count}}</text>
  94. </view>
  95. <view class="goods-total">0</view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="summary-row">
  101. <text>件数<text class="highlight">{{unrecyclableCount}}</text> </text>
  102. <text>结算金额<text class="highlight">0</text></text>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'
  110. export default {
  111. mixins: [pullRefreshMixin],
  112. data() {
  113. return {
  114. statusBarHeight: 0,
  115. navBarHeight: 14,
  116. navBarTotalHeight: 14,
  117. featureTags: ['透明检', '专业验', '公正评', '逐件验'],
  118. goodsList: [], // 质检合格
  119. problemList: [], // 质量问题
  120. unrecyclableList: [], // 不可回收
  121. reportData: null,
  122. showQualified: false,
  123. showProblem: false,
  124. showUnrecyclable: false
  125. }
  126. },
  127. computed: {
  128. totalCount() {
  129. return this.goodsList.reduce((sum, item) => sum + item.count, 0)
  130. },
  131. totalAmount() {
  132. return this.goodsList.reduce((sum, item) => sum + item.total, 0).toFixed(1)
  133. },
  134. problemCount() {
  135. return this.problemList.reduce((sum, item) => sum + item.count, 0)
  136. },
  137. problemAmount() {
  138. return this.problemList.reduce((sum, item) => sum + item.total, 0).toFixed(1)
  139. },
  140. unrecyclableCount() {
  141. return this.unrecyclableList.reduce((sum, item) => sum + item.count, 0)
  142. }
  143. },
  144. onLoad(options) {
  145. const sysInfo = uni.getSystemInfoSync()
  146. this.statusBarHeight = sysInfo.statusBarHeight
  147. this.navBarHeight = 14
  148. this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight
  149. // 获取 id 或 goodsId,优先 id
  150. const goodsId = options.id || options.goodsId
  151. if (goodsId) {
  152. this.fetchQualityReport(goodsId)
  153. }
  154. },
  155. methods: {
  156. async fetchQualityReport(goodsId) {
  157. // 假设 this.$api 可用
  158. this.$api && this.$api('getQualityReport', { goodsId }, res => {
  159. if (res && res.code === 200 && res.result) {
  160. this.reportData = res.result
  161. // 适配数据
  162. const status = Number(res.result.testingStatus)
  163. // 0: 质量问题,1: 质检合格,2: 不可回收
  164. this.showQualified = status === 1 || status === 0 // 0和1都可能有合格
  165. this.showProblem = status === 0 || status === 1 // 0和1都可能有问题
  166. this.showUnrecyclable = status === 2
  167. // 合格/问题都用同一条数据(如有多个需后端返回数组)
  168. if (status === 1) {
  169. this.goodsList = [this.mapReportToGoods(res.result)]
  170. this.problemList = []
  171. this.unrecyclableList = []
  172. } else if (status === 0) {
  173. this.goodsList = []
  174. this.problemList = [this.mapReportToGoods(res.result, true)]
  175. this.unrecyclableList = []
  176. } else if (status === 2) {
  177. this.goodsList = []
  178. this.problemList = []
  179. this.unrecyclableList = [this.mapReportToGoods(res.result)]
  180. }
  181. }
  182. })
  183. },
  184. mapReportToGoods(data, isProblem = false) {
  185. return {
  186. img: data.image,
  187. name: data.title || '未知品类',
  188. desc: data.details || '',
  189. price: data.onePrice || 0,
  190. count: data.num || 1,
  191. total: (data.onePrice || 0) * (data.num || 1),
  192. detail: true,
  193. problemDesc: isProblem ? (data.testingInstructions || '') : ''
  194. }
  195. },
  196. async onRefresh() {
  197. // 模拟刷新数据
  198. await new Promise(resolve => setTimeout(resolve, 1000))
  199. uni.stopPullRefresh()
  200. },
  201. navigateBack() {
  202. uni.navigateBack()
  203. },
  204. goToInspectionDetail(status) {
  205. // 取接口返回的字段
  206. const d = this.reportData || {}
  207. uni.navigateTo({
  208. url: `/pages/subcomponent/inspection-detail?status=${status}` +
  209. `&testingStatus=${d.testingStatus || ''}` +
  210. `&testingInstructions=${encodeURIComponent(d.testingInstructions || '')}` +
  211. `&testingTime=${encodeURIComponent(d.testingTime || '')}` +
  212. `&testingImages=${encodeURIComponent(d.testingImages || '')}`
  213. })
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .inspection-page {
  220. min-height: 100vh;
  221. background: #422525;
  222. height: 100vh;
  223. overflow: hidden;
  224. // padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
  225. }
  226. .nav-bar {
  227. position: fixed;
  228. top: 0;
  229. left: 0;
  230. right: 0;
  231. z-index: 1000;
  232. width: 100vw;
  233. background: #422525;
  234. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.03);
  235. .nav-bar-inner {
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. height: 44px;
  240. width: 100vw;
  241. position: relative;
  242. }
  243. .back-icon, .nav-bar-right {
  244. width: 44px;
  245. height: 44px;
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. position: absolute;
  250. top: 0;
  251. }
  252. .back-icon { left: 0; }
  253. .nav-bar-right { right: 0; }
  254. .nav-bar-title {
  255. flex: 1;
  256. text-align: center;
  257. font-size: 36rpx;
  258. font-weight: bold;
  259. color: #fff;
  260. letter-spacing: 2rpx;
  261. line-height: 44px;
  262. font-family: DingTalk JinBuTi;
  263. font-weight: 400;
  264. font-style: italic;
  265. font-size: 28px;
  266. line-height: 100%;
  267. letter-spacing: 0%;
  268. text-align: center;
  269. // vertical-align: bottom;
  270. }
  271. }
  272. .feature-area {
  273. margin: 0 32rpx;
  274. margin-top: 0;
  275. margin-bottom: 0;
  276. background:#422525;
  277. border-radius: 32rpx;
  278. // box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.08);
  279. padding: 18rpx 24rpx 18rpx 24rpx;
  280. display: flex;
  281. flex-direction: column;
  282. align-items: stretch;
  283. justify-content: center;
  284. }
  285. .feature-desc {
  286. text-align: center;
  287. font-size: 22rpx;
  288. color: #fff;
  289. font-weight: 500;
  290. margin-bottom: 10rpx;
  291. margin-top: 18rpx;
  292. letter-spacing: 1rpx;
  293. }
  294. .feature-tags {
  295. // margin: 0 32rpx;
  296. background: #533030;
  297. border-radius: 12rpx;
  298. box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.08);
  299. // padding: 0 24rpx;
  300. width: 100%;
  301. height: 80rpx;
  302. display: flex;
  303. flex-direction: row;
  304. justify-content: space-between;
  305. align-items: center;
  306. .tag {
  307. flex: 1;
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. .check {
  312. width: 36rpx;
  313. height: 36rpx;
  314. background: #fff;
  315. border-radius: 50%;
  316. display: flex;
  317. align-items: center;
  318. justify-content: center;
  319. font-size: 28rpx;
  320. color: #422525;
  321. font-weight: bold;
  322. margin-right: 10rpx;
  323. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  324. }
  325. .text {
  326. color: #fff;
  327. font-size: 28rpx;
  328. font-weight: bold;
  329. }
  330. }
  331. }
  332. .main-content {
  333. margin-top: 20rpx;
  334. padding-top: 88rpx;
  335. background: linear-gradient(180deg, #fef7e6 0%, #fff 50%);
  336. height: calc(100vh - 88rpx);
  337. width: 100vw;
  338. box-sizing: border-box;
  339. position: relative;
  340. z-index: 11;
  341. border-radius: 40rpx 40rpx 0 0;
  342. overflow: hidden;
  343. display: flex;
  344. flex-direction: column;
  345. align-items: center;
  346. }
  347. .inspection-card {
  348. background: #fff;
  349. border-radius: 32rpx;
  350. box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08);
  351. padding: 40rpx 32rpx 32rpx 32rpx;
  352. margin: -60rpx auto 0 auto;
  353. width: calc(100vw - 64rpx);
  354. max-width: 700rpx;
  355. display: flex;
  356. flex-direction: column;
  357. .report-title {
  358. font-size: 32rpx;
  359. font-weight: bold;
  360. color: #222;
  361. text-align: center;
  362. margin-bottom: 12rpx;
  363. }
  364. .goods-list {
  365. .goods-item {
  366. display: flex;
  367. align-items: center;
  368. background: #fff;
  369. border-radius: 20rpx;
  370. box-shadow: 0 2rpx 8rpx rgba(60, 167, 250, 0.04);
  371. padding: 24rpx 20rpx;
  372. margin-bottom: 20rpx;
  373. .goods-img {
  374. width: 80rpx;
  375. height: 80rpx;
  376. border-radius: 16rpx;
  377. margin-right: 20rpx;
  378. background: #f5f5f5;
  379. }
  380. .goods-info {
  381. flex: 1;
  382. display: flex;
  383. flex-direction: column;
  384. .goods-row {
  385. display: flex;
  386. justify-content: space-between;
  387. align-items: center;
  388. .goods-name {
  389. font-size: 28rpx;
  390. color: #222;
  391. font-weight: bold;
  392. }
  393. .detail-link {
  394. font-size: 24rpx;
  395. color: #bbb;
  396. display: flex;
  397. align-items: center;
  398. }
  399. }
  400. .goods-desc {
  401. font-size: 24rpx;
  402. color: #bbb;
  403. margin-bottom: 8rpx;
  404. }
  405. .goods-bottom-row {
  406. display: flex;
  407. justify-content: space-between;
  408. align-items: flex-end;
  409. margin-top: 8rpx;
  410. .goods-price-row {
  411. display: flex;
  412. align-items: baseline;
  413. .goods-price {
  414. font-size: 26rpx;
  415. color: #bbb;
  416. font-weight: bold;
  417. }
  418. .goods-unit {
  419. font-size: 24rpx;
  420. color: #bbb;
  421. margin-left: 2rpx;
  422. }
  423. .goods-count {
  424. font-size: 22rpx;
  425. color: #bbb;
  426. margin-left: 8rpx;
  427. font-weight: normal;
  428. }
  429. }
  430. .goods-total {
  431. font-size: 28rpx;
  432. color: #222;
  433. font-weight: bold;
  434. margin-left: 24rpx;
  435. }
  436. }
  437. }
  438. }
  439. .goods-item:last-child { margin-bottom: 0; }
  440. }
  441. .summary-row {
  442. display: flex;
  443. justify-content: space-between;
  444. align-items: center;
  445. margin-top: 24rpx;
  446. font-size: 28rpx;
  447. color: #222;
  448. .highlight {
  449. color: #f79400;
  450. font-weight: bold;
  451. font-size: 30rpx;
  452. }
  453. }
  454. }
  455. .check {
  456. width: 36rpx;
  457. height: 36rpx;
  458. background: #fff;
  459. border-radius: 50%;
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. font-size: 28rpx;
  464. color: #13ac47;
  465. font-weight: bold;
  466. margin-right: 10rpx;
  467. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  468. }
  469. .problem-card {
  470. margin-top: 40rpx;
  471. }
  472. .problem-price-row {
  473. color: #bbb !important;
  474. }
  475. </style>