diff --git a/pages/component/home.vue b/pages/component/home.vue index 8ff9bd7..d11173e 100644 --- a/pages/component/home.vue +++ b/pages/component/home.vue @@ -328,7 +328,7 @@ export default { this.$api('getRecentGoodsList', {}, res => { if (res && res.code === 200 && Array.isArray(res.result) && res.result.length > 0) { this.records = res.result.map(item => ({ - id: item.id, + orderId: item.orderId, image: item.image, name: item.name, phone: item.phone, @@ -347,7 +347,7 @@ export default { }, goToInspectionReport(item) { uni.navigateTo({ - url: `/pages/subcomponent/inspection-report?id=${item.id}` + url: `/pages/subcomponent/inspection-report?orderId=${item.orderId}` }) }, getFreeCityList() { diff --git a/pages/manager/inspect-result.vue b/pages/manager/inspect-result.vue index 4c5269e..a7e9aa6 100644 --- a/pages/manager/inspect-result.vue +++ b/pages/manager/inspect-result.vue @@ -475,7 +475,7 @@ export default { const selectedReasonIds = [] this.reasonChecked.forEach((checked, index) => { if (checked) { - selectedReasonIds.push(this.reasonOptions[index].id.toString()) + selectedReasonIds.push(this.reasonOptions[index].reason.toString()) } }) diff --git a/pages/manager/order.vue b/pages/manager/order.vue index 4058b97..1bbd033 100644 --- a/pages/manager/order.vue +++ b/pages/manager/order.vue @@ -244,7 +244,8 @@ export default { this.isLoading = true const params = { pageNo: isLoadMore ? this.pageNo + 1 : 1, - pageSize: this.pageSize + pageSize: this.pageSize, + status: 0 } console.log(params,'params') if (this.userId) { diff --git a/pages/subcomponent/inspection-detail.vue b/pages/subcomponent/inspection-detail.vue index f2d1571..3a5a857 100644 --- a/pages/subcomponent/inspection-detail.vue +++ b/pages/subcomponent/inspection-detail.vue @@ -30,7 +30,7 @@ {{(idx+1).toString().padStart(2, '0')}} / {{problemList.length.toString().padStart(2, '0')}} - {{testingInstructions || '质量问题'}} + {{item.title}} 质量问题实拍 @@ -70,7 +70,7 @@ {{testingTime}} - 01 / {{qualifiedImages.length < 10 ? '0' + qualifiedImages.length : qualifiedImages.length}} + 01 / {{qualifiedImages.length.toString().padStart(2, '0')}} 质检图片 @@ -103,7 +103,6 @@ export default { return { status: 'problem', // 'problem' or 'qualified' testingStatus: '', - testingInstructions: '', testingTime: '', testingImages: [], statusBarHeight: 0, @@ -155,24 +154,42 @@ export default { if (options.testingStatus) { this.testingStatus = options.testingStatus } + + // 处理 testingInstructions,转换为数组 + let testingInstructionsArray = [] if (options.testingInstructions) { - this.testingInstructions = decodeURIComponent(options.testingInstructions) + const instructionsStr = decodeURIComponent(options.testingInstructions) + if (instructionsStr && instructionsStr.trim()) { + // 按逗号分割成数组,并过滤空值 + testingInstructionsArray = instructionsStr.split(',').filter(item => item.trim() !== '') + } } + if (options.testingTime) { this.testingTime = decodeURIComponent(options.testingTime) } if (options.testingImages) { // 逗号分割为数组 - this.testingImages = decodeURIComponent(options.testingImages).split(',') + this.testingImages = decodeURIComponent(options.testingImages).split(',').filter(item => item.trim() !== '') } + // 可根据 status 动态设置 problemList/qualifiedImages if (this.status === 'problem') { - this.problemList = [ - { - title: this.testingInstructions || '质量问题', - images: this.testingImages - } - ] + // 根据 testingInstructions 数组创建对应的问题列表 + if (testingInstructionsArray.length > 0) { + this.problemList = testingInstructionsArray.map((instruction, index) => ({ + title: instruction || '质量问题', + images: this.testingImages // 所有问题共享图片,如果需要分别对应可以进一步处理 + })) + } else { + // 如果没有具体说明,创建默认的问题项 + this.problemList = [ + { + title: '质量问题', + images: this.testingImages + } + ] + } } else if (this.status === 'qualified') { this.qualifiedImages = this.testingImages } diff --git a/pages/subcomponent/inspection-report.vue b/pages/subcomponent/inspection-report.vue index c7daabc..3b721a5 100644 --- a/pages/subcomponent/inspection-report.vue +++ b/pages/subcomponent/inspection-report.vue @@ -41,6 +41,7 @@ /件 x{{item.count}} + ¥{{item.total}} @@ -63,45 +64,21 @@ {{item.desc}} - ¥{{item.price}} - /件 + x{{item.count}} + 件数:{{problemCount}} - 结算金额:¥{{problemAmount}} - - - - 不可回收 - - - - - - {{item.name}} - - {{item.desc}} - - - ¥{{item.price}} - /件 - x{{item.count}} - - ¥0 - - - - - - 件数:{{unrecyclableCount}} - 结算金额:¥0 + 结算金额:¥ 0 + @@ -119,11 +96,9 @@ export default { featureTags: ['透明检', '专业验', '公正评', '逐件验'], goodsList: [], // 质检合格 problemList: [], // 质量问题 - unrecyclableList: [], // 不可回收 reportData: null, showQualified: false, - showProblem: false, - showUnrecyclable: false + showProblem: false } }, computed: { @@ -138,9 +113,6 @@ export default { }, 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) { @@ -148,53 +120,80 @@ export default { 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) + // 获取 orderId + const orderId = options.orderId + if (orderId) { + this.fetchQualityReport(orderId) } }, methods: { - async fetchQualityReport(goodsId) { - // 假设 this.$api 可用 - this.$api && this.$api('getQualityReport', { goodsId }, res => { + async fetchQualityReport(orderId) { + // 调用订单详情接口 + this.$api && this.$api('getOrderDetail', { orderId }, 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)] - } + // 解析嵌套的订单数据 + this.parseOrderData(res.result) } }) }, - mapReportToGoods(data, isProblem = false) { + + parseOrderData(orderData) { + // 重置数据 + this.goodsList = [] + this.problemList = [] + + // 遍历主订单的 commonOrderList + if (orderData.commonOrderList && orderData.commonOrderList.length > 0) { + orderData.commonOrderList.forEach(mainOrder => { + // 如果有子订单列表,遍历子订单 + if (mainOrder.commonOrderList && mainOrder.commonOrderList.length > 0) { + mainOrder.commonOrderList.forEach(subOrder => { + this.categorizeOrderItem(subOrder, mainOrder) + }) + } else { + // 如果没有子订单,直接处理主订单项 + this.categorizeOrderItem(mainOrder) + } + }) + } + + // 设置显示状态 + this.showQualified = this.goodsList.length > 0 + this.showProblem = this.problemList.length > 0 + }, + + categorizeOrderItem(orderItem, parentOrder = null) { + const status = Number(orderItem.testingStatus) + const parentData = parentOrder || orderItem + + // 根据 testingStatus 分类:0-质检合格,1-质量问题 + if (status === 0) { + // 质检合格 + this.goodsList.push(this.mapOrderToGoods(orderItem, parentData)) + } else if (status === 1) { + // 质量问题 + this.problemList.push(this.mapOrderToGoods(orderItem, parentData, true)) + } + // 移除 testingStatus = 2 (不可回收) 的处理 + }, + + mapOrderToGoods(orderItem, parentData, 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), + img: parentData.image || '/static/default-goods.png', + name: parentData.title || '未知品类', + desc: parentData.pinName ? `${parentData.pinName}` :'', + price: parentData.onePrice || 0, + count: orderItem.num || 1, + total: parentData.price, detail: true, - problemDesc: isProblem ? (data.testingInstructions || '') : '' + testingInstructions: orderItem.testingInstructions || '', + testingImages: orderItem.testingImages || '', + testingTime: orderItem.testingTime || '', + problemDesc: isProblem ? (orderItem.testingInstructions || '') : '' } }, + async onRefresh() { // 模拟刷新数据 await new Promise(resolve => setTimeout(resolve, 1000)) @@ -204,15 +203,22 @@ export default { 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 || '')}` - }) + // 根据状态获取对应的商品数据 + let itemData = null + if (status === 'qualified' && this.goodsList.length > 0) { + itemData = this.goodsList[0] + } else if (status === 'problem' && this.problemList.length > 0) { + itemData = this.problemList[0] + } + + if (itemData) { + uni.navigateTo({ + url: `/pages/subcomponent/inspection-detail?status=${status}` + + `&testingInstructions=${encodeURIComponent(itemData.testingInstructions || '')}` + + `&testingTime=${encodeURIComponent(itemData.testingTime || '')}` + + `&testingImages=${encodeURIComponent(itemData.testingImages || '')}` + }) + } } } } @@ -359,7 +365,7 @@ export default { border-radius: 32rpx; box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08); padding: 40rpx 32rpx 32rpx 32rpx; - margin: -60rpx auto 0 auto; + margin: 24rpx auto 0 auto; width: calc(100vw - 64rpx); max-width: 700rpx; display: flex;