|
|
- <template>
- <view class="inspection-page">
- <!-- 顶部渐变导航栏 -->
- <view class="nav-bar" :style="{height: navBarTotalHeight + 'px', paddingTop: statusBarHeight + 'px'}">
- <view class="nav-bar-inner">
- <view class="back-icon" @tap="navigateBack">
- <uni-icons type="left" size="22" color="#fff" />
- </view>
- <view class="nav-bar-title">质检报告</view>
- <view class="nav-bar-right">
- <uni-icons type="more-filled" size="22" color="#fff" />
- </view>
- </view>
- </view>
- <!-- 打钩标签区及说明 -->
- <view class="feature-area" :style="{marginTop: navBarTotalHeight+statusBarHeight + 'px'}">
- <view class="feature-desc">该报告由「瀚海回收」质检查验出具</view>
- <view class="feature-tags">
- <view class="tag" v-for="(t, i) in featureTags" :key="i">
- <text class="check">✓</text>
- <text class="text">{{t}}</text>
- </view>
- </view>
- </view>
- <!-- 主内容区(卡片悬浮覆盖打钩区) -->
- <view class="main-content">
- <view v-if="showQualified && goodsList.length" class="inspection-card">
- <view class="report-title">质检合格</view>
- <view class="goods-list">
- <view class="goods-item" v-for="(item, i) in goodsList" :key="i" @tap="goToInspectionDetail('qualified')">
- <image class="goods-img" :src="item.img" mode="aspectFit" />
- <view class="goods-info">
- <view class="goods-row">
- <view class="goods-name">{{item.name}}</view>
- <view v-if="item.detail" class="detail-link">查看详情 <uni-icons type="right" size="16" color="#bbb" /></view>
- </view>
- <view class="goods-desc">{{item.desc}}</view>
- <view class="goods-bottom-row">
- <view class="goods-price-row">
- <text class="goods-price">¥{{item.price}}</text>
- <text class="goods-unit">/件</text>
- <text class="goods-count">x{{item.count}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="summary-row">
- <text>件数:<text class="highlight">{{totalCount}}</text> 件</text>
- <text>结算金额:<text class="highlight">¥{{totalAmount}}</text></text>
- </view>
- </view>
- <view v-if="showProblem && problemList.length" class="inspection-card problem-card">
- <view class="report-title">质量问题</view>
- <view class="goods-list">
- <view class="goods-item" v-for="(item, i) in problemList" :key="i" @tap="goToInspectionDetail('problem')">
- <image class="goods-img" :src="item.img" mode="aspectFit" />
- <view class="goods-info">
- <view class="goods-row">
- <view class="goods-name">{{item.name}}</view>
- <view v-if="item.detail" class="detail-link">查看详情 <uni-icons type="right" size="16" color="#bbb" /></view>
- </view>
- <view class="goods-desc">{{item.desc}}</view>
- <view class="goods-bottom-row">
- <view class="goods-price-row problem-price-row">
- <text class="goods-price">¥{{item.price}}</text>
- <text class="goods-unit">/件</text>
- <text class="goods-count">x{{item.count}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="summary-row">
- <text>件数:<text class="highlight">{{problemCount}}</text> 件</text>
- <text>结算金额:<text class="highlight">¥{{problemAmount}}</text></text>
- </view>
- </view>
- <view v-if="showUnrecyclable && unrecyclableList.length" class="inspection-card problem-card">
- <view class="report-title">不可回收</view>
- <view class="goods-list">
- <view class="goods-item" v-for="(item, i) in unrecyclableList" :key="i">
- <image class="goods-img" :src="item.img" mode="aspectFit" />
- <view class="goods-info">
- <view class="goods-row">
- <view class="goods-name">{{item.name}}</view>
- </view>
- <view class="goods-desc">{{item.desc}}</view>
- <view class="goods-bottom-row">
- <view class="goods-price-row">
- <text class="goods-price">¥{{item.price}}</text>
- <text class="goods-unit">/件</text>
- <text class="goods-count">x{{item.count}}</text>
- </view>
- <view class="goods-total">¥0</view>
- </view>
- </view>
- </view>
- </view>
- <view class="summary-row">
- <text>件数:<text class="highlight">{{unrecyclableCount}}</text> 件</text>
- <text>结算金额:<text class="highlight">¥0</text></text>
- </view>
- </view>
- </view>
- </view>
- </template>
-
- <script>
- import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'
-
- export default {
- mixins: [pullRefreshMixin],
- data() {
- return {
- statusBarHeight: 0,
- navBarHeight: 14,
- navBarTotalHeight: 14,
- featureTags: ['透明检', '专业验', '公正评', '逐件验'],
- goodsList: [], // 质检合格
- problemList: [], // 质量问题
- unrecyclableList: [], // 不可回收
- reportData: null,
- showQualified: false,
- showProblem: false,
- showUnrecyclable: false
- }
- },
- computed: {
- totalCount() {
- return this.goodsList.reduce((sum, item) => sum + item.count, 0)
- },
- totalAmount() {
- return this.goodsList.reduce((sum, item) => sum + item.total, 0).toFixed(1)
- },
- problemCount() {
- return this.problemList.reduce((sum, item) => sum + item.count, 0)
- },
- problemAmount() {
- return this.problemList.reduce((sum, item) => sum + item.total, 0).toFixed(1)
- },
- unrecyclableCount() {
- return this.unrecyclableList.reduce((sum, item) => sum + item.count, 0)
- }
- },
- onLoad(options) {
- const sysInfo = uni.getSystemInfoSync()
- this.statusBarHeight = sysInfo.statusBarHeight
- this.navBarHeight = 14
- this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight
- // 获取 id 或 goodsId,优先 id
- const goodsId = options.id || options.goodsId
- if (goodsId) {
- this.fetchQualityReport(goodsId)
- }
- },
- methods: {
- async fetchQualityReport(goodsId) {
- // 假设 this.$api 可用
- this.$api && this.$api('getQualityReport', { goodsId }, res => {
- if (res && res.code === 200 && res.result) {
- this.reportData = res.result
- // 适配数据
- const status = Number(res.result.testingStatus)
- // 0: 质量问题,1: 质检合格,2: 不可回收
- this.showQualified = status === 1 || status === 0 // 0和1都可能有合格
- this.showProblem = status === 0 || status === 1 // 0和1都可能有问题
- this.showUnrecyclable = status === 2
- // 合格/问题都用同一条数据(如有多个需后端返回数组)
- if (status === 1) {
- this.goodsList = [this.mapReportToGoods(res.result)]
- this.problemList = []
- this.unrecyclableList = []
- } else if (status === 0) {
- this.goodsList = []
- this.problemList = [this.mapReportToGoods(res.result, true)]
- this.unrecyclableList = []
- } else if (status === 2) {
- this.goodsList = []
- this.problemList = []
- this.unrecyclableList = [this.mapReportToGoods(res.result)]
- }
- }
- })
- },
- mapReportToGoods(data, isProblem = false) {
- return {
- img: data.image,
- name: data.title || '未知品类',
- desc: data.details || '',
- price: data.onePrice || 0,
- count: data.num || 1,
- total: (data.onePrice || 0) * (data.num || 1),
- detail: true,
- problemDesc: isProblem ? (data.testingInstructions || '') : ''
- }
- },
- async onRefresh() {
- // 模拟刷新数据
- await new Promise(resolve => setTimeout(resolve, 1000))
- uni.stopPullRefresh()
- },
- navigateBack() {
- uni.navigateBack()
- },
- goToInspectionDetail(status) {
- // 取接口返回的字段
- const d = this.reportData || {}
- uni.navigateTo({
- url: `/pages/subcomponent/inspection-detail?status=${status}` +
- `&testingStatus=${d.testingStatus || ''}` +
- `&testingInstructions=${encodeURIComponent(d.testingInstructions || '')}` +
- `&testingTime=${encodeURIComponent(d.testingTime || '')}` +
- `&testingImages=${encodeURIComponent(d.testingImages || '')}`
- })
- }
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .inspection-page {
- min-height: 100vh;
- background: #422525;
- height: 100vh;
- overflow: hidden;
- // padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
- }
-
- .nav-bar {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- z-index: 1000;
- width: 100vw;
- background: #422525;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.03);
- .nav-bar-inner {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 44px;
- width: 100vw;
- position: relative;
- }
- .back-icon, .nav-bar-right {
- width: 44px;
- height: 44px;
- display: flex;
- align-items: center;
- justify-content: center;
- position: absolute;
- top: 0;
- }
- .back-icon { left: 0; }
- .nav-bar-right { right: 0; }
- .nav-bar-title {
- flex: 1;
- text-align: center;
- font-size: 36rpx;
- font-weight: bold;
- color: #fff;
- letter-spacing: 2rpx;
- line-height: 44px;
- font-family: DingTalk JinBuTi;
- font-weight: 400;
- font-style: italic;
- font-size: 28px;
- line-height: 100%;
- letter-spacing: 0%;
- text-align: center;
- // vertical-align: bottom;
- }
- }
-
- .feature-area {
- margin: 0 32rpx;
- margin-top: 0;
- margin-bottom: 0;
- background:#422525;
- border-radius: 32rpx;
- // box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.08);
- padding: 18rpx 24rpx 18rpx 24rpx;
- display: flex;
- flex-direction: column;
- align-items: stretch;
- justify-content: center;
- }
-
- .feature-desc {
- text-align: center;
- font-size: 22rpx;
- color: #fff;
- font-weight: 500;
- margin-bottom: 10rpx;
- margin-top: 18rpx;
- letter-spacing: 1rpx;
- }
-
- .feature-tags {
- // margin: 0 32rpx;
- background: #533030;
- border-radius: 12rpx;
- box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.08);
- // padding: 0 24rpx;
- width: 100%;
- height: 80rpx;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
-
- .tag {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- .check {
- width: 36rpx;
- height: 36rpx;
- background: #fff;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 28rpx;
- color: #422525;
- font-weight: bold;
- margin-right: 10rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
- }
- .text {
- color: #fff;
- font-size: 28rpx;
- font-weight: bold;
- }
- }
- }
-
- .main-content {
- margin-top: 20rpx;
- padding-top: 88rpx;
- background: linear-gradient(180deg, #fef7e6 0%, #fff 50%);
- height: calc(100vh - 88rpx);
- width: 100vw;
- box-sizing: border-box;
- position: relative;
- z-index: 11;
- border-radius: 40rpx 40rpx 0 0;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- .inspection-card {
- background: #fff;
- border-radius: 32rpx;
- box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08);
- padding: 40rpx 32rpx 32rpx 32rpx;
- margin: -60rpx auto 0 auto;
- width: calc(100vw - 64rpx);
- max-width: 700rpx;
- display: flex;
- flex-direction: column;
- .report-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #222;
- text-align: center;
- margin-bottom: 12rpx;
- }
- .goods-list {
- .goods-item {
- display: flex;
- align-items: center;
- background: #fff;
- border-radius: 20rpx;
- box-shadow: 0 2rpx 8rpx rgba(60, 167, 250, 0.04);
- padding: 24rpx 20rpx;
- margin-bottom: 20rpx;
- .goods-img {
- width: 80rpx;
- height: 80rpx;
- border-radius: 16rpx;
- margin-right: 20rpx;
- background: #f5f5f5;
- }
- .goods-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- .goods-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .goods-name {
- font-size: 28rpx;
- color: #222;
- font-weight: bold;
- }
- .detail-link {
- font-size: 24rpx;
- color: #bbb;
- display: flex;
- align-items: center;
- }
- }
- .goods-desc {
- font-size: 24rpx;
- color: #bbb;
- margin-bottom: 8rpx;
- }
- .goods-bottom-row {
- display: flex;
- justify-content: space-between;
- align-items: flex-end;
- margin-top: 8rpx;
- .goods-price-row {
- display: flex;
- align-items: baseline;
- .goods-price {
- font-size: 26rpx;
- color: #bbb;
- font-weight: bold;
- }
- .goods-unit {
- font-size: 24rpx;
- color: #bbb;
- margin-left: 2rpx;
- }
- .goods-count {
- font-size: 22rpx;
- color: #bbb;
- margin-left: 8rpx;
- font-weight: normal;
- }
- }
- .goods-total {
- font-size: 28rpx;
- color: #222;
- font-weight: bold;
- margin-left: 24rpx;
- }
- }
- }
- }
- .goods-item:last-child { margin-bottom: 0; }
- }
- .summary-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 24rpx;
- font-size: 28rpx;
- color: #222;
- .highlight {
- color: #f79400;
- font-weight: bold;
- font-size: 30rpx;
- }
- }
- }
-
- .check {
- width: 36rpx;
- height: 36rpx;
- background: #fff;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 28rpx;
- color: #13ac47;
- font-weight: bold;
- margin-right: 10rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
- }
-
- .problem-card {
- margin-top: 40rpx;
- }
-
- .problem-price-row {
- color: #bbb !important;
- }
- </style>
|