From 3180f97cbda6e7805b47f58ef196bf214c007cc5 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 13 Dec 2023 20:06:40 +0800 Subject: [PATCH 01/39] =?UTF-8?q?=E2=9C=A8=20=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=EF=BC=9A=E6=8E=A5=E5=85=A5=2080%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/detail.vue | 256 ++++++++++++++------------------------- pages/order/list.vue | 44 +++---- sheep/api/trade/order.js | 20 +++ sheep/hooks/useGoods.js | 30 ++++- 4 files changed, 163 insertions(+), 187 deletions(-) diff --git a/pages/order/detail.vue b/pages/order/detail.vue index c6b370f..a212383 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -1,7 +1,7 @@ @@ -100,23 +100,23 @@ } from 'lodash'; import OrderApi from '@/sheep/api/trade/order'; - const pagination = { - data: [], - current_page: 1, - total: 1 + const paginationNull = { + list: [], + total: 0, + pageNo: 1, + pageSize: 5, }; // 数据 const state = reactive({ currentTab: 0, // 选中的 tabMaps 下标 pagination: { - data: [], - current_page: 1, - total: 1 + list: [], + total: 0, + pageNo: 1, + pageSize: 5, }, - loadStatus: '', - deleteOrderId: 0, - error: 0, + loadStatus: '' }); const tabMaps = [{ @@ -142,11 +142,12 @@ // 切换选项卡 function onTabsChange(e) { - if (state.currentTab === e.index) return; - - state.pagination = pagination; + if (state.currentTab === e.index) { + return; + } + // 重头加载代码 + state.pagination = paginationNull; state.currentTab = e.index; - getOrderList(); } @@ -196,11 +197,9 @@ } // 正常的确认收货流程 - const { - error - } = await sheep.$api.order.confirm(order.id); - if (error === 0) { - state.pagination = pagination; + const { code } = await OrderApi.receiveOrder(order.id); + if (code === 0) { + state.pagination = paginationNull; await getOrderList(); } } @@ -256,8 +255,8 @@ const { code } = await OrderApi.cancelOrder(orderId); if (code === 0) { // 修改数据的状态 - let index = state.pagination.data.findIndex((order) => order.id === orderId); - const orderInfo = state.pagination.data[index]; + let index = state.pagination.list.findIndex((order) => order.id === orderId); + const orderInfo = state.pagination.list[index]; orderInfo.status = 40; handleOrderButtons(orderInfo); } @@ -275,39 +274,31 @@ const { code } = await OrderApi.deleteOrder(orderId); if (code === 0) { // 删除数据 - let index = state.pagination.data.findIndex((order) => order.id === orderId); - state.pagination.data.splice(index, 1); + let index = state.pagination.list.findIndex((order) => order.id === orderId); + state.pagination.list.splice(index, 1); } } }, }); } - // 获取订单列表 TODO 芋艿:待测试 - async function getOrderList(page = 1, list_rows = 5) { + // 获取订单列表 + async function getOrderList() { state.loadStatus = 'loading'; - let res = await sheep.$api.order.list({ - status: tabMaps[state.currentTab].value, - pageSize: list_rows, - pageNo: page, - commentStatus: tabMaps[state.currentTab].value == 30 ? false : null + let { code, data } = await OrderApi.getOrderPage({ + pageNo: state.pagination.pageNo, + pageSize: state.pagination.pageSize, + status: tabMaps[state.currentTab].value, + commentStatus: tabMaps[state.currentTab].value === 30 ? false : null }); - state.error = res.code; - if (res.code === 0) { - res.data.list.forEach(order => handleOrderButtons(order)); - let orderList = _.concat(state.pagination.data, res.data.list); - state.pagination = { - ...res.data, - data: orderList, - }; - console.log(state.pagination) - if (state.pagination.data.length < state.pagination.total) { - state.loadStatus = 'more'; - } else { - state.loadStatus = 'noMore'; - } - } - } + if (code !== 0) { + return; + } + data.list.forEach(order => handleOrderButtons(order)); + state.pagination.list = _.concat(state.pagination.list, data.list) + state.pagination.total = data.total; + state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'; + } onLoad(async (options) => { if (options.type) { @@ -317,20 +308,22 @@ }); // 加载更多 - function loadmore() { - if (state.loadStatus !== 'noMore') { - getOrderList(parseInt((state.pagination.data.length / 5) + 1)); + function loadMore() { + if (state.loadStatus === 'noMore') { + return } - } + state.pagination.pageNo++; + getOrderList(); + } // 上拉加载更多 onReachBottom(() => { - loadmore(); + loadMore(); }); // 下拉刷新 onPullDownRefresh(() => { - state.pagination = pagination; + state.pagination = paginationNull; getOrderList(); setTimeout(function() { uni.stopPullDownRefresh(); diff --git a/sheep/api/order.js b/sheep/api/order.js index 02441b4..1bcf981 100644 --- a/sheep/api/order.js +++ b/sheep/api/order.js @@ -37,16 +37,7 @@ export default { showLoading: false, }, }), - // 订单列表 - list: (params) => - request({ - url: '/app-api/trade/order/page', - method: 'GET', - params, - custom: { - showLoading: false, - }, - }), + // list: (params) => // request({ // url: 'order/order', diff --git a/sheep/api/trade/order.js b/sheep/api/trade/order.js index b6b6e74..1211a5c 100644 --- a/sheep/api/trade/order.js +++ b/sheep/api/trade/order.js @@ -1,4 +1,5 @@ import request2 from '@/sheep/request2'; +import request from '@/sheep/request'; const OrderApi = { // 计算订单信息 @@ -48,6 +49,27 @@ const OrderApi = { }, }); }, + // 订单列表 + getOrderPage: (params) => { + return request({ + url: '/app-api/trade/order/page', + method: 'GET', + params, + custom: { + showLoading: false, + }, + }); + }, + // 确认收货 + receiveOrder: (id) => { + return request2({ + url: `/app-api/trade/order/receive`, + method: 'PUT', + params: { + id, + }, + }); + }, // 取消订单 cancelOrder: (id) => { return request2({ @@ -67,7 +89,7 @@ const OrderApi = { id, }, }); - } + }, }; export default OrderApi; diff --git a/sheep/request/index.js b/sheep/request/index.js index 94d5bc0..e9b16c0 100644 --- a/sheep/request/index.js +++ b/sheep/request/index.js @@ -94,6 +94,7 @@ http.interceptors.request.use( if (config.url.indexOf('/app-api/') !== -1) { config.header['Accept'] = '*/*' config.header['tenant-id'] = '1'; + config.header['terminal'] = '20'; config.header['Authorization'] = 'Bearer test247'; } return config; @@ -212,8 +213,8 @@ const request = (config) => { } // TODO 芋艿:额外拼接 if (config.url.indexOf('/app-api/') >= 0) { - config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 - // config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 + // config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 + config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 } return http.middleware(config); }; diff --git a/sheep/request2/index.js b/sheep/request2/index.js index d7d27b7..a525e9a 100644 --- a/sheep/request2/index.js +++ b/sheep/request2/index.js @@ -96,7 +96,8 @@ http.interceptors.request.use( if (config.url.indexOf('/app-api/') !== -1) { config.header['Accept'] = '*/*' config.header['tenant-id'] = '1'; - config.header['Authorization'] = 'Bearer test247'; + config.header['terminal'] = '20'; + config.header['Authorization'] = 'Bearer test247'; } // console.log(config, '看参数') return config; @@ -216,9 +217,9 @@ const request = (config) => { // TODO 芋艿:额外拼接 if (config.url.indexOf('/app-api/') >= 0) { // 设置接口地址 - config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 + // config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 // config.url = 'https://app.test.huizhizao.vip/prod-api' + config.url; // 调用【云端】 - // config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 + config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 } return http.middleware(config); }; From 953c8f96cb9ec435f03dd28de742a2567cd3fef6 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 13 Dec 2023 21:05:35 +0800 Subject: [PATCH 03/39] =?UTF-8?q?=E2=9C=A8=20=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=EF=BC=9A=E5=88=A0=E9=99=A4=E5=8D=95=E4=B8=AA=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=9A=84=E7=89=A9=E6=B5=81=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/detail.vue | 22 +-------- pages/order/dispatch/content.vue | 84 -------------------------------- 2 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 pages/order/dispatch/content.vue diff --git a/pages/order/detail.vue b/pages/order/detail.vue index ae792a3..c3165bc 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -56,18 +56,6 @@ :price="item.price" :num="item.count" > - + @@ -341,14 +329,6 @@ } // #endif - // 配送方式详情 - function onDetail(item) { - sheep.$router.go('/pages/order/dispatch/content', { - id: item.order_id, - item_id: item.id, - }); - } - // 评价 function onComment(orderSN, orderId) { sheep.$router.go('/pages/goods/comment/add', { diff --git a/pages/order/dispatch/content.vue b/pages/order/dispatch/content.vue deleted file mode 100644 index 5095c6c..0000000 --- a/pages/order/dispatch/content.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - From db19393427d8631863625cf57f0e6abe67a7222f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 13 Dec 2023 21:17:31 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E2=9C=A8=20=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=EF=BC=9A=E8=AE=A2=E5=8D=95=E9=A1=B9=E7=9A=84=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E7=8A=B6=E6=80=81=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 10 ---------- pages/order/detail.vue | 41 +++++++---------------------------------- pages/order/list.vue | 12 ++---------- 3 files changed, 9 insertions(+), 54 deletions(-) diff --git a/pages.json b/pages.json index 56d1201..74ed57a 100644 --- a/pages.json +++ b/pages.json @@ -209,16 +209,6 @@ "title": "发票详情" } }, - { - "path": "dispatch/content", - "style": { - "navigationBarTitleText": "发货内容" - }, - "meta": { - "auth": true, - "title": "发货内容" - } - }, { "path": "aftersale/apply", "style": { diff --git a/pages/order/detail.vue b/pages/order/detail.vue index c3165bc..b7becfb 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -58,7 +58,7 @@ > @@ -225,6 +216,7 @@ }); } + // 查看商品 function onGoodsDetail(id) { sheep.$router.go('/pages/goods/index', { id @@ -248,25 +240,6 @@ }); } - // 申请退款 - async function onRefund(orderId) { - uni.showModal({ - title: '提示', - content: '确定要申请退款吗?', - success: async function(res) { - if (res.confirm) { - const { - error, - data - } = await sheep.$api.order.applyRefund(orderId); - if (error === 0) { - getOrderDetail(data.order_sn); - } - } - }, - }); - } - // 查看物流 TODO 芋艿:待测试 async function onExpress(orderId) { sheep.$router.go('/pages/order/express/list', { diff --git a/pages/order/list.vue b/pages/order/list.vue index d1f9bb7..6e43676 100644 --- a/pages/order/list.vue +++ b/pages/order/list.vue @@ -34,7 +34,6 @@ - + - --> + diff --git a/pages/order/aftersale/list.vue b/pages/order/aftersale/list.vue index 4cf824b..1201386 100644 --- a/pages/order/aftersale/list.vue +++ b/pages/order/aftersale/list.vue @@ -3,92 +3,73 @@ - + - - + - 服务单号:{{ order.no }} - {{ status[order.status] }} + {{ formatAfterSaleStatus(order) }} - + - - {{ status2[order.way] }} - - {{ order.applyReason }} + {{ order.way === 10 ? '仅退款' : '退款退货' }} + {{ formatAfterSaleStatusDescription(order) }} - + v-if="order?.buttons.includes('cancel')">取消申请 - - - - --> + + }" @tap="loadMore" /> diff --git a/pages/order/detail.vue b/pages/order/detail.vue index bded792..ee179ec 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -1,568 +1,626 @@ + + + + + - - - - - - 订单编号: - {{ state.orderInfo.no }} - - - - - 下单时间: - + + + + + + 订单编号: + {{ state.orderInfo.no }} + + + + + 下单时间: + {{ sheep.$helper.timeFormat(state.orderInfo.createTime, 'yyyy-mm-dd hh:MM:ss') }} - - - 支付时间: - + + + 支付时间: + {{ sheep.$helper.timeFormat(state.orderInfo.payTime, 'yyyy-mm-dd hh:MM:ss') }} - - - 支付方式: - {{ state.orderInfo.payChannelName || '-' }} - - - + + + 支付方式: + {{ state.orderInfo.payChannelName || '-' }} + + + - - - - 商品总额 - - ¥{{ fen2yuan(state.orderInfo.totalPrice) }} - - - - 运费 - ¥{{ fen2yuan(state.orderInfo.deliveryPrice) }} - + + + + 商品总额 + + ¥{{ fen2yuan(state.orderInfo.totalPrice) }} + + + + 运费 + ¥{{ fen2yuan(state.orderInfo.deliveryPrice) }} + - - 优惠金额 - ¥{{ fen2yuan(state.orderInfo.discountPrice) }} - - - {{ state.orderInfo.payStatus ? '已付款' : '需付款' }} - ¥{{ fen2yuan(state.orderInfo.payPrice) }} - - - 已退款 - ¥{{ fen2yuan(state.orderInfo.refundPrice) }} - - + + 优惠金额 + ¥{{ fen2yuan(state.orderInfo.discountPrice) }} + + + {{ state.orderInfo.payStatus ? '已付款' : '需付款' }} + ¥{{ fen2yuan(state.orderInfo.payPrice) }} + + + 已退款 + ¥{{ fen2yuan(state.orderInfo.refundPrice) }} + + - - - - - - - - + - - - - - + + + \ No newline at end of file + .pay-btn { + width: 160rpx; + height: 60rpx; + font-size: 26rpx; + border-radius: 30rpx; + font-weight: 500; + color: #fff; + } + } + diff --git a/sheep/api/order.js b/sheep/api/order.js index 1bcf981..e3ce154 100644 --- a/sheep/api/order.js +++ b/sheep/api/order.js @@ -129,13 +129,6 @@ export default { }), // 售后 aftersale: { - // 申请售后 - apply: (data) => - request({ - url: 'order/aftersale', - method: 'POST', - data, - }), list: (params) => request({ url: '/app-api/trade/after-sale/page', @@ -145,15 +138,6 @@ export default { showLoading: false, }, }), - // list: (params) => - // request({ - // url: 'order/aftersale', - // method: 'GET', - // params, - // custom: { - // showLoading: false, - // }, - // }), //取消售后 cancel: (id) => request({ @@ -166,7 +150,7 @@ export default { url: 'order/aftersale/' + id, method: 'DELETE', }), - // 售后详情 + // 售后详情 DONE detail: (id) => request({ url: '/app-api/trade/after-sale/get?id=' + id, diff --git a/sheep/api/trade/afterSale.js b/sheep/api/trade/afterSale.js index 25aa31c..8207945 100644 --- a/sheep/api/trade/afterSale.js +++ b/sheep/api/trade/afterSale.js @@ -10,6 +10,26 @@ const AfterSaleApi = { data, }); }, + // 获得售后 + getAfterSale: (id) => { + return request2({ + url: `/app-api/trade/after-sale/get`, + method: 'GET', + params: { + id, + }, + }); + }, + // 取消售后 + cancelAfterSale: (id) => { + return request2({ + url: `/app-api/trade/after-sale/cancel`, + method: 'DELETE', + params: { + id, + }, + }); + } }; export default AfterSaleApi; diff --git a/sheep/hooks/useGoods.js b/sheep/hooks/useGoods.js index 1a98b08..eb13a47 100644 --- a/sheep/hooks/useGoods.js +++ b/sheep/hooks/useGoods.js @@ -182,6 +182,87 @@ export function handleOrderButtons(order) { } } +/** + * 格式化售后状态 + * + * @param afterSale 售后 + */ +export function formatAfterSaleStatus(afterSale) { + if (afterSale.status === 10) { + return '申请售后'; + } + if (afterSale.status === 20) { + return '商品待退货'; + } + if (afterSale.status === 30) { + return '商家待收货'; + } + if (afterSale.status === 40) { + return '等待退款'; + } + if (afterSale.status === 50) { + return '退款成功'; + } + if (afterSale.status === 61) { + return '买家取消'; + } + if (afterSale.status === 62) { + return '商家拒绝'; + } + if (afterSale.status === 63) { + return '商家拒收货'; + } + return '未知状态'; +} + +/** + * 格式化售后状态的描述 + * + * @param afterSale 售后 + */ +export function formatAfterSaleStatusDescription(afterSale) { + if (afterSale.status === 10) { + return '退款申请待商家处理'; + } + if (afterSale.status === 20) { + return '请退货并填写物流信息'; + } + if (afterSale.status === 30) { + return '退货退款申请待商家处理'; + } + if (afterSale.status === 40) { + return '等待退款'; + } + if (afterSale.status === 50) { + return '退款成功'; + } + if (afterSale.status === 61) { + return '退款关闭'; + } + if (afterSale.status === 62) { + return `商家不同意退款申请,拒绝原因:${afterSale.auditReason}`; + } + if (afterSale.status === 63) { + return `商家拒绝收货,不同意退款,拒绝原因:${afterSale.auditReason}`; + } + return '未知状态'; +} + +/** + * 处理售后的 button 操作按钮数组 + * + * @param afterSale 售后 + */ +export function handleAfterSaleButtons(afterSale) { + afterSale.buttons = []; + if ([10, 20, 30].includes(afterSale.status)) { // 取消订单 + afterSale.buttons.push('cancel'); + } + if (afterSale.status === 20) { // 退货信息 + afterSale.buttons.push('delivery'); + } +} + /** * 倒计时 * @param toTime 截止时间 From 3efb8ecf276c5606dc160ac0c45197c558ee7b0d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 14 Dec 2023 20:07:20 +0800 Subject: [PATCH 07/39] =?UTF-8?q?=E2=9C=A8=20=E5=94=AE=E5=90=8E=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=9A=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/order/aftersale/apply.vue | 2 +- pages/order/aftersale/log-item.vue | 42 +++++++----------------------- pages/order/aftersale/log.vue | 36 +++++++------------------ sheep/api/trade/afterSale.js | 10 +++++++ 4 files changed, 31 insertions(+), 59 deletions(-) diff --git a/pages/order/aftersale/apply.vue b/pages/order/aftersale/apply.vue index 7319f33..7512302 100644 --- a/pages/order/aftersale/apply.vue +++ b/pages/order/aftersale/apply.vue @@ -1,4 +1,4 @@ - +