hookehuyr

feat(订单): 添加订单发货和收货功能

- 在订单列表中添加待发货/待收货状态展示
- 实现卖家发货和买家收货功能
- 添加相关API接口和状态处理
- 更新订单状态显示和样式
- 处理微信小程序确认收货组件回调
1 /* 1 /*
2 * @Date: 2025-07-03 17:21:45 2 * @Date: 2025-07-03 17:21:45
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-14 14:43:05 4 + * @LastEditTime: 2025-07-28 11:51:11
5 * @FilePath: /jgdl/src/api/orders.js 5 * @FilePath: /jgdl/src/api/orders.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -14,6 +14,8 @@ const Api = { ...@@ -14,6 +14,8 @@ const Api = {
14 REVIEW_ORDER: '/srv/?a=order&t=review', 14 REVIEW_ORDER: '/srv/?a=order&t=review',
15 DELETE_ORDER: '/srv/?a=order&t=del', 15 DELETE_ORDER: '/srv/?a=order&t=del',
16 CANCEL_ORDER: '/srv/?a=order&t=cancel', 16 CANCEL_ORDER: '/srv/?a=order&t=cancel',
17 + SHIP_ORDER: '/srv/?a=order&t=ship',
18 + RECEIPT_ORDER_STATUS: '/srv/?a=order&t=receipt_status',
17 } 19 }
18 20
19 /** 21 /**
...@@ -21,7 +23,7 @@ const Api = { ...@@ -21,7 +23,7 @@ const Api = {
21 * @param page 页码,从0开始 23 * @param page 页码,从0开始
22 * @param page_size 每页数量 24 * @param page_size 每页数量
23 * @param type 列表类型。buy=我买的,sell=我卖的 25 * @param type 列表类型。buy=我买的,sell=我卖的
24 - * @param status 订单状态(3=待支付, 5=已完成, 7=已取消 26 + * @param status 订单状态(3=待支付, 5=已支付待发货, 7=已取消, 9=已发货/待收货, 11=已收货
25 * @returns data{ list[{ id, title, total_amount, status, create_time, payment_time, details{ id, vehicle_id, quantity, vehicle{} } }] } 27 * @returns data{ list[{ id, title, total_amount, status, create_time, payment_time, details{ id, vehicle_id, quantity, vehicle{} } }] }
26 */ 28 */
27 export const getOrderListAPI = (params) => fn(fetch.get(Api.GET_ORDER_LIST, params)); 29 export const getOrderListAPI = (params) => fn(fetch.get(Api.GET_ORDER_LIST, params));
...@@ -63,3 +65,17 @@ export const deleteOrderAPI = (params) => fn(fetch.post(Api.DELETE_ORDER, params ...@@ -63,3 +65,17 @@ export const deleteOrderAPI = (params) => fn(fetch.post(Api.DELETE_ORDER, params
63 * @returns data{} 65 * @returns data{}
64 */ 66 */
65 export const cancelOrderAPI = (params) => fn(fetch.post(Api.CANCEL_ORDER, params)); 67 export const cancelOrderAPI = (params) => fn(fetch.post(Api.CANCEL_ORDER, params));
68 +
69 +/**
70 + * @description: 发货订单
71 + * @param order_id 订单ID
72 + * @returns data{}
73 + */
74 +export const shipOrderAPI = (params) => fn(fetch.post(Api.SHIP_ORDER, params));
75 +
76 +/**
77 + * @description: 确认收货订单状态
78 + * @param order_id 订单ID
79 + * @returns data{ status 3=待支付, 5=已支付待发货, 7=已取消, 9=已发货/待收货, 11=已收货 }
80 + */
81 +export const receiptOrderStatusAPI = (params) => fn(fetch.get(Api.RECEIPT_ORDER_STATUS, params));
......
1 /* 1 /*
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-14 16:45:23 4 + * @LastEditTime: 2025-07-25 15:53:11
5 * @FilePath: /jgdl/src/app.js 5 * @FilePath: /jgdl/src/app.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -42,6 +42,32 @@ const App = createApp({ ...@@ -42,6 +42,32 @@ const App = createApp({
42 } 42 }
43 }, 43 },
44 onShow(options) { 44 onShow(options) {
45 + // 处理确认收货组件回调
46 + if (options && options.referrerInfo && options.referrerInfo.extraData) {
47 + const { status, errormsg, req_extradata } = options.referrerInfo.extraData
48 +
49 + if (status === 'success') {
50 + // 确认收货成功,通过事件总线通知订单页面
51 + Taro.eventCenter.trigger('confirmReceiveSuccess', {
52 + merchantId: req_extradata.merchant_id,
53 + transactionId: req_extradata.transaction_id,
54 + merchantTradeNo: req_extradata.merchant_trade_no,
55 + })
56 +
57 + Taro.showToast({
58 + title: '确认收货成功',
59 + icon: 'success',
60 + duration: 2000
61 + })
62 + } else if (status === 'fail') {
63 + Taro.showToast({
64 + title: errormsg || '确认收货失败',
65 + icon: 'error',
66 + duration: 2000
67 + })
68 + }
69 + // status === 'cancel' 时用户取消操作,不需要特殊处理
70 + }
45 }, 71 },
46 // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖 72 // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
47 }); 73 });
......
1 <!-- 1 <!--
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-24 14:21:19 4 + * @LastEditTime: 2025-07-28 09:32:03
5 * @FilePath: /jgdl/src/pages/index/index.vue 5 * @FilePath: /jgdl/src/pages/index/index.vue
6 * @Description: 捡个电驴首页 6 * @Description: 捡个电驴首页
7 --> 7 -->
...@@ -153,8 +153,8 @@ useDidShow(() => { ...@@ -153,8 +153,8 @@ useDidShow(() => {
153 153
154 useReady(async () => { 154 useReady(async () => {
155 // 版本更新检查 155 // 版本更新检查
156 - if (!wx.canIUse("getUpdateManager")) { 156 + if (!Taro.canIUse("getUpdateManager")) {
157 - wx.showModal({ 157 + Taro.showModal({
158 title: "提示", 158 title: "提示",
159 content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试", 159 content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试",
160 showCancel: false, 160 showCancel: false,
...@@ -163,7 +163,7 @@ useReady(async () => { ...@@ -163,7 +163,7 @@ useReady(async () => {
163 } 163 }
164 164
165 // https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html 165 // https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html
166 - const updateManager = wx.getUpdateManager(); 166 + const updateManager = Taro.getUpdateManager();
167 167
168 updateManager.onCheckForUpdate((res) => { 168 updateManager.onCheckForUpdate((res) => {
169 // 请求完新版本信息的回调 169 // 请求完新版本信息的回调
......
...@@ -224,6 +224,10 @@ ...@@ -224,6 +224,10 @@
224 color: #f97316; 224 color: #f97316;
225 } 225 }
226 226
227 + &.status-shipping {
228 + color: #f97316;
229 + }
230 +
227 &.status-completed { 231 &.status-completed {
228 color: #10b981; 232 color: #10b981;
229 } 233 }
......
This diff is collapsed. Click to expand it.