diff --git a/api/order.js b/api/order.js index 4fcc542..50b1cf8 100644 --- a/api/order.js +++ b/api/order.js @@ -124,4 +124,81 @@ export const apiGetOrderCount = (data) => { ); } +// 申请退款 +export const apiApplyRefund = (data) => { + return httpRequest.post( + `${baseUrl}/reverse/add`, + data + ); + } + +// 申请评价 +export const apiApplyComment = (data) => { + return httpRequest.post( + `${baseUrl}/comment/add`, + data + ); + } + +// 上传图片(支持批量上传) +export const apiUploadFile = (fileList) => { + // uni.request不支持FormData和文件上传,需要使用uni.uploadFile + // fileList应该是文件对象数组,格式:[{path:'xxx'}] 或 [{tempFilePath:'xxx'}] + return new Promise((resolve, reject) => { + // 获取用户信息用于添加token + let user_info = uni.getStorageSync("user_info") || {}; + if (typeof user_info === "string") { + try { + user_info = JSON.parse(user_info) || {}; + } catch (e) { + user_info = {}; + } + } + // 批量上传所有文件 + const uploadPromises = fileList.map((file, index) => { + return new Promise((fileResolve, fileReject) => { + const filePath = file.path || file.tempFilePath || file.path || file; + if (!filePath) { + fileReject({ msg: `第${index + 1}个文件路径无效` }); + return; + } + uni.uploadFile({ + url: `${baseUrl}/upload/file`, + filePath: filePath, + name: 'files', + header: { + token: user_info.token || '', + buyerId: user_info.buyerId || '', + flag: user_info.flag || '' + }, + success: (res) => { + try { + const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data; + if (res.statusCode === 200) { + fileResolve(data); + } else { + fileReject({ code: res.statusCode, msg: data.msg || '上传失败', data }); + } + } catch (e) { + fileReject({ code: res.statusCode, msg: '解析响应数据失败', data: res.data }); + } + }, + fail: (err) => { + fileReject({ msg: err.errMsg || '上传失败', err }); + } + }); + }); + }); + + // 等待所有文件上传完成 + Promise.all(uploadPromises) + .then(results => { + resolve(results); + }) + .catch(err => { + reject(err); + }); + }); + } + diff --git a/pages/order/comment/index.vue b/pages/order/comment/index.vue index b27eb5d..cd03e3c 100644 --- a/pages/order/comment/index.vue +++ b/pages/order/comment/index.vue @@ -3,12 +3,10 @@ - - + {{ item.goods_name }} @@ -17,7 +15,6 @@ - @@ -27,22 +24,22 @@ ×{{ item.total_num }} - + --> - + 好评 - + 中评 - + 差评 @@ -50,9 +47,52 @@ + + + + 商品分: + + + + + + 卖家服务评分: + + + + + + 物流评分: + + + + + + - + @@ -81,41 +121,33 @@ @@ -364,6 +375,35 @@ } } + // 评分详情 + .rating-detail { + padding: 20rpx 20rpx; + margin-top: 10rpx; + + .rating-item { + display: flex; + align-items: center; + margin-bottom: 20rpx; + font-size: 28rpx; + color: #333; + + &:last-child { + margin-bottom: 0; + } + + .rating-label { + width: 200rpx; + color: #666; + } + + .rating-stars { + flex: 1; + display: flex; + align-items: center; + } + } + } + // 评价内容 .form-content { padding: 14rpx 10rpx; diff --git a/pages/order/detail.vue b/pages/order/detail.vue index 3e18cda..4e51efc 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -82,7 +82,7 @@ {{ goods.productName }} - {{ props.value.name }} + {{ props.propertyName }}: {{ props.propertyValue }} @@ -179,7 +179,7 @@ - {{ action.desc }} + {{ action.desc }} @@ -305,47 +305,29 @@ }, // 跳转到申请售后页面 - handleApplyRefund(orderGoodsId) { - this.$goPageByToken('pages/refund/apply', { orderGoodsId }) + handleApplyRefund(orderGoodsId, trackNumber) { + this.$goPageByToken('pages/refund/apply', { orderGoodsId, trackNumber }) }, - // 取消订单 - onCancel(orderId) { + onClick(orderId, url, tip) { const app = this uni.showModal({ title: '友情提示', - content: '确认要取消该订单吗?', + content: tip, success(o) { if (o.confirm) { - OrderApi.cancel(orderId) + OrderApi.apiActionOrder(url, { tradeOrderId: orderId }) .then(result => { - // 显示成功信息 - app.$toast(result.message) - // 刷新当前订单数据 - setTimeout(() => app.getOrderDetail(true), 1500) + app.$toast(result.msg) + const timer = setTimeout(() => { + clearTimeout(timer); + uni.navigateBack(); + }, 1500); }) } } }); }, - onReceipt(orderId, url) { - const app = this - uni.showModal({ - title: '友情提示', - content: '确认要确认收货吗?', - success(o) { - if (o.confirm) { - OrderApi.apiActionOrder(url, { tradeOrderId: orderId }) - .then(result => { - // 显示成功信息 - app.$toast(result.msg) - // 刷新订单列表 - app.onRefreshList() - }) - } - } - }); - }, // 确认收货 /* async onReceipt(orderId) { const app = this @@ -440,22 +422,26 @@ this.$goPageByToken('pages/checkout/cashier/index', { orderId }) }, // 跳转到订单评价页 - handleTargetComment(orderId) { - this.$goPageByToken('pages/order/comment/index', { orderId }) + handleTargetComment(orderId, trackNumber) { + this.$goPageByToken('pages/order/comment/index', { tradeOrderId: orderId, trackNumber }) }, + onClickBtn(orderId, trackNumber, action) { + console.warn('----- my data is orderId, action: ', orderId, trackNumber, action) + const tip = [{ name: '/applyCancel', tip: '确认要取消该订单吗?' }, { name: '/receipt', tip: '确认要收货吗?' }, { name: '/shipped', tip: '确认要收货吗?' }] + if (action.interfaceUri.includes('/pay')) { + this.onPay(orderId) + } else if (action.interfaceUri.includes('/comment')) { + this.handleTargetComment(orderId, trackNumber) + } else if (action.interfaceUri.includes('/refund')) { + this.handleApplyRefund(orderId, trackNumber) + } else if (action.interfaceUri.includes('/logistics')) { + this.handleTargetExpress(trackNumber) + } else { + const tipContent = tip.find(item => action.interfaceUri.includes(item.name))?.tip + this.onClick(orderId, action.interfaceUri, tipContent) + } + } }, - onClickBtn(orderId, action) { - console.warn('----- my data is orderId, action: ', orderId, action) - if (action.interfaceUri === '/app/order/applyCancel') { - this.onCancel(orderId, action.interfaceUri) - } else if (action.interfaceUri.includes('/pay')) { - this.onPay(orderId) - } else if (action.interfaceUri.includes('/receipt')) { - this.onReceipt(orderId, action.interfaceUri) - } else if (action.interfaceUri.includes('/comment')) { - this.handleTargetComment(orderId) - } - } } diff --git a/pages/order/index.vue b/pages/order/index.vue index cb59321..5e9a575 100644 --- a/pages/order/index.vue +++ b/pages/order/index.vue @@ -53,7 +53,7 @@ - {{ action.desc }} + {{ action.desc }} - + 服务类型 - {{ item.name }} @@ -36,15 +36,15 @@ 申请原因 - - + 退款金额 - ¥{{ goods.total_pay_price }} + ¥{{ reFundPrice }} @@ -75,68 +75,59 @@