hookehuyr

feat(orders): 添加确认收货功能并更新订单状态

实现买家确认收货功能,替换原有的微信组件调用方式
新增RECEIVE_ORDER接口用于处理确认收货请求
更新订单状态为已完成(11)并显示成功提示
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-08-04 15:24:12 4 + * @LastEditTime: 2025-08-06 13:56:19
5 * @FilePath: /jgdl/src/api/orders.js 5 * @FilePath: /jgdl/src/api/orders.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -15,6 +15,7 @@ const Api = { ...@@ -15,6 +15,7 @@ const Api = {
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', 17 SHIP_ORDER: '/srv/?a=order&t=ship',
18 + RECEIVE_ORDER: '/srv/?a=order&t=receive',
18 RECEIPT_ORDER_STATUS: '/srv/?a=order&t=receipt_status', 19 RECEIPT_ORDER_STATUS: '/srv/?a=order&t=receipt_status',
19 } 20 }
20 21
...@@ -80,3 +81,10 @@ export const shipOrderAPI = (params) => fn(fetch.post(Api.SHIP_ORDER, params)); ...@@ -80,3 +81,10 @@ export const shipOrderAPI = (params) => fn(fetch.post(Api.SHIP_ORDER, params));
80 * @returns data{ status 3=待支付, 5=已支付待发货, 7=已取消, 9=已发货/待收货, 11=已收货 } 81 * @returns data{ status 3=待支付, 5=已支付待发货, 7=已取消, 9=已发货/待收货, 11=已收货 }
81 */ 82 */
82 export const receiptOrderStatusAPI = (params) => fn(fetch.get(Api.RECEIPT_ORDER_STATUS, params)); 83 export const receiptOrderStatusAPI = (params) => fn(fetch.get(Api.RECEIPT_ORDER_STATUS, params));
84 +
85 +/**
86 + * @description: 确认收货订单
87 + * @param order_id 订单ID
88 + * @returns data{}
89 + */
90 +export const receiveOrderAPI = (params) => fn(fetch.post(Api.RECEIVE_ORDER, params));
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-04 18:04:34 4 + * @LastEditTime: 2025-08-06 14:03:17
5 * @FilePath: /jgdl/src/pages/myOrders/index.vue 5 * @FilePath: /jgdl/src/pages/myOrders/index.vue
6 * @Description: 订单管理页面 6 * @Description: 订单管理页面
7 --> 7 -->
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
17 <view class="toggle-option" :class="{ active: viewMode === 'sell' }" @click="setViewMode('sell')"> 17 <view class="toggle-option" :class="{ active: viewMode === 'sell' }" @click="setViewMode('sell')">
18 我卖的车 18 我卖的车
19 </view> 19 </view>
20 - <view class="toggle-option" :class="{ active: viewMode === 'verification' }" @click="setViewMode('verification')"> 20 + <view class="toggle-option" :class="{ active: viewMode === 'verification' }"
21 + @click="setViewMode('verification')">
21 我的认证 22 我的认证
22 </view> 23 </view>
23 </view> 24 </view>
...@@ -28,22 +29,28 @@ ...@@ -28,22 +29,28 @@
28 <view class="tab-item" :class="{ active: activeTab === '' }" @click="setActiveTab('')"> 29 <view class="tab-item" :class="{ active: activeTab === '' }" @click="setActiveTab('')">
29 全部 30 全部
30 </view> 31 </view>
31 - <view v-if="viewMode === 'buy' || viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 3 }" @click="setActiveTab(3)"> 32 + <view v-if="viewMode === 'buy' || viewMode === 'verification'" class="tab-item"
33 + :class="{ active: activeTab === 3 }" @click="setActiveTab(3)">
32 待支付 34 待支付
33 </view> 35 </view>
34 - <view v-if="viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 5 }" @click="setActiveTab(5)"> 36 + <view v-if="viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 5 }"
37 + @click="setActiveTab(5)">
35 已付款 38 已付款
36 </view> 39 </view>
37 - <view v-if="viewMode === 'buy' || viewMode === 'sell'" class="tab-item" :class="{ active: activeTab === 9 }" @click="setActiveTab(9)"> 40 + <view v-if="viewMode === 'buy' || viewMode === 'sell'" class="tab-item" :class="{ active: activeTab === 9 }"
41 + @click="setActiveTab(9)">
38 待收货 42 待收货
39 </view> 43 </view>
40 - <view v-if="viewMode === 'buy' || viewMode === 'sell'" class="tab-item" :class="{ active: activeTab === 11 }" @click="setActiveTab(11)"> 44 + <view v-if="viewMode === 'buy' || viewMode === 'sell'" class="tab-item" :class="{ active: activeTab === 11 }"
45 + @click="setActiveTab(11)">
41 已完成 46 已完成
42 </view> 47 </view>
43 - <view v-if="viewMode === 'buy' || viewMode === 'sell' || viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 7 }" @click="setActiveTab(7)"> 48 + <view v-if="viewMode === 'buy' || viewMode === 'sell' || viewMode === 'verification'" class="tab-item"
49 + :class="{ active: activeTab === 7 }" @click="setActiveTab(7)">
44 已取消 50 已取消
45 </view> 51 </view>
46 - <view v-if="viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 15 }" @click="setActiveTab(15)"> 52 + <view v-if="viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 15 }"
53 + @click="setActiveTab(15)">
47 退款 54 退款
48 </view> 55 </view>
49 </view> 56 </view>
...@@ -81,10 +88,13 @@ ...@@ -81,10 +88,13 @@
81 <view class="vehicle-details"> 88 <view class="vehicle-details">
82 <text class="vehicle-name">{{ order.details.vehicle.brand }} {{ order.details.vehicle.model }}</text> 89 <text class="vehicle-name">{{ order.details.vehicle.brand }} {{ order.details.vehicle.model }}</text>
83 <text class="vehicle-specs"> 90 <text class="vehicle-specs">
84 - <text v-if="order.details.vehicle.manufacture_year">{{ order.details.vehicle.manufacture_year }}年 | </text>续航{{ order.details.vehicle.range_km }}km 91 + <text v-if="order.details.vehicle.manufacture_year">{{ order.details.vehicle.manufacture_year }}年 |
92 + </text>续航{{ order.details.vehicle.range_km }}km
85 </text> 93 </text>
86 - <text v-if="order.details.vehicle.battery_capacity_ah" class="vehicle-battery">电池容量:{{ order.details.vehicle.battery_capacity_ah }}Ah</text> 94 + <text v-if="order.details.vehicle.battery_capacity_ah" class="vehicle-battery">电池容量:{{
87 - <text v-if="order.details.vehicle.price" class="vehicle-price">¥{{ order.details.vehicle.price }}</text> 95 + order.details.vehicle.battery_capacity_ah }}Ah</text>
96 + <text v-if="order.details.vehicle.price" class="vehicle-price">¥{{ order.details.vehicle.price
97 + }}</text>
88 </view> 98 </view>
89 </nut-col> 99 </nut-col>
90 </nut-row> 100 </nut-row>
...@@ -179,7 +189,8 @@ ...@@ -179,7 +189,8 @@
179 订单详情 189 订单详情
180 </nut-button> 190 </nut-button>
181 <!-- 只有买车订单才显示评价按钮,卖车订单不显示 --> 191 <!-- 只有买车订单才显示评价按钮,卖车订单不显示 -->
182 - <nut-button v-if="viewMode === 'buy'" type="primary" size="small" @click="rateOrder(order.id)" class="ml-2" color="orange" plain> 192 + <nut-button v-if="viewMode === 'buy'" type="primary" size="small" @click="rateOrder(order.id)"
193 + class="ml-2" color="orange" plain>
183 {{ order.details.review ? '查看评价' : '评价' }} 194 {{ order.details.review ? '查看评价' : '评价' }}
184 </nut-button> 195 </nut-button>
185 </template> 196 </template>
...@@ -208,7 +219,8 @@ ...@@ -208,7 +219,8 @@
208 </template> 219 </template>
209 220
210 <!-- 认证模式:已取消状态 --> 221 <!-- 认证模式:已取消状态 -->
211 - <template v-if="viewMode === 'verification' && (order.status === 7 || order.status === 15 || order.status === 5)"> 222 + <template
223 + v-if="viewMode === 'verification' && (order.status === 7 || order.status === 15 || order.status === 5)">
212 <nut-button type="default" size="small" @click="viewOrderDetail(order.id)"> 224 <nut-button type="default" size="small" @click="viewOrderDetail(order.id)">
213 订单详情 225 订单详情
214 </nut-button> 226 </nut-button>
...@@ -334,12 +346,15 @@ ...@@ -334,12 +346,15 @@
334 <view class="product-detail-content"> 346 <view class="product-detail-content">
335 <text class="product-detail-name">{{ currentOrderDetail?.details?.vehicle?.brand }} {{ 347 <text class="product-detail-name">{{ currentOrderDetail?.details?.vehicle?.brand }} {{
336 currentOrderDetail?.details?.vehicle?.model }}</text> 348 currentOrderDetail?.details?.vehicle?.model }}</text>
337 - <text class="product-detail-specs"><text v-if="currentOrderDetail?.details?.vehicle?.manufacture_year">{{ currentOrderDetail?.details?.vehicle?.manufacture_year }}年 · </text>续航: 349 + <text class="product-detail-specs"><text
350 + v-if="currentOrderDetail?.details?.vehicle?.manufacture_year">{{
351 + currentOrderDetail?.details?.vehicle?.manufacture_year }}年 · </text>续航:
338 {{ 352 {{
339 currentOrderDetail?.details?.vehicle?.range_km }}km/h</text> 353 currentOrderDetail?.details?.vehicle?.range_km }}km/h</text>
340 <text class="product-detail-battery">电池容量: {{ currentOrderDetail?.details?.vehicle?.battery_capacity_ah 354 <text class="product-detail-battery">电池容量: {{ currentOrderDetail?.details?.vehicle?.battery_capacity_ah
341 - }}Ah</text> 355 + }}Ah</text>
342 - <text v-if="currentOrderDetail?.details?.vehicle?.price" class="product-detail-price">¥ {{ currentOrderDetail?.details?.vehicle?.price }}</text> 356 + <text v-if="currentOrderDetail?.details?.vehicle?.price" class="product-detail-price">¥ {{
357 + currentOrderDetail?.details?.vehicle?.price }}</text>
343 </view> 358 </view>
344 </view> 359 </view>
345 </view> 360 </view>
...@@ -406,7 +421,8 @@ ...@@ -406,7 +421,8 @@
406 <nut-button plain class="flex-1" size="small" @click="showConfirmModal = false"> 421 <nut-button plain class="flex-1" size="small" @click="showConfirmModal = false">
407 取消 422 取消
408 </nut-button> 423 </nut-button>
409 - <nut-button type="warning" class="flex-1" size="small" color="orange" @click="performDeleteOrder(pendingDeleteOrderId)"> 424 + <nut-button type="warning" class="flex-1" size="small" color="orange"
425 + @click="performDeleteOrder(pendingDeleteOrderId)">
410 确认 426 确认
411 </nut-button> 427 </nut-button>
412 </view> 428 </view>
...@@ -426,7 +442,8 @@ ...@@ -426,7 +442,8 @@
426 <nut-button plain class="flex-1" size="small" @click="showCancelConfirmModal = false"> 442 <nut-button plain class="flex-1" size="small" @click="showCancelConfirmModal = false">
427 我再想想 443 我再想想
428 </nut-button> 444 </nut-button>
429 - <nut-button type="warning" class="flex-1" size="small" color="orange" @click="performCancelOrder(pendingCancelOrderId)"> 445 + <nut-button type="warning" class="flex-1" size="small" color="orange"
446 + @click="performCancelOrder(pendingCancelOrderId)">
430 确定取消 447 确定取消
431 </nut-button> 448 </nut-button>
432 </view> 449 </view>
...@@ -446,7 +463,8 @@ ...@@ -446,7 +463,8 @@
446 <nut-button plain class="flex-1" size="small" @click="showShipConfirmModal = false"> 463 <nut-button plain class="flex-1" size="small" @click="showShipConfirmModal = false">
447 取消 464 取消
448 </nut-button> 465 </nut-button>
449 - <nut-button type="warning" class="flex-1" size="small" color="orange" @click="performConfirmShip(pendingShipOrderId)"> 466 + <nut-button type="warning" class="flex-1" size="small" color="orange"
467 + @click="performConfirmShip(pendingShipOrderId)">
450 确认发货 468 确认发货
451 </nut-button> 469 </nut-button>
452 </view> 470 </view>
...@@ -466,7 +484,8 @@ ...@@ -466,7 +484,8 @@
466 <nut-button plain class="flex-1" size="small" @click="showReceiveConfirmModal = false"> 484 <nut-button plain class="flex-1" size="small" @click="showReceiveConfirmModal = false">
467 取消 485 取消
468 </nut-button> 486 </nut-button>
469 - <nut-button type="warning" class="flex-1" size="small" color="orange" @click="performConfirmReceive(pendingReceiveOrderId)"> 487 + <nut-button type="warning" class="flex-1" size="small" color="orange"
488 + @click="performConfirmReceive(pendingReceiveOrderId)">
470 确认收货 489 确认收货
471 </nut-button> 490 </nut-button>
472 </view> 491 </view>
...@@ -482,7 +501,7 @@ import './index.less' ...@@ -482,7 +501,7 @@ import './index.less'
482 import { $ } from '@tarojs/extend' 501 import { $ } from '@tarojs/extend'
483 import payCard from '@/components/payCard.vue' 502 import payCard from '@/components/payCard.vue'
484 // 导入接口 503 // 导入接口
485 -import { getOrderListAPI, getOrderDetailAPI, reviewOrderAPI, cancelOrderAPI, deleteOrderAPI, shipOrderAPI, receiptOrderStatusAPI } from '@/api/orders' 504 +import { getOrderListAPI, getOrderDetailAPI, reviewOrderAPI, cancelOrderAPI, deleteOrderAPI, shipOrderAPI, receiptOrderStatusAPI, receiveOrderAPI } from '@/api/orders'
486 import { DEFAULT_COVER_IMG } from '@/utils/config' 505 import { DEFAULT_COVER_IMG } from '@/utils/config'
487 506
488 const scrollStyle = ref({ 507 const scrollStyle = ref({
...@@ -1259,35 +1278,21 @@ const performConfirmReceive = async (orderId) => { ...@@ -1259,35 +1278,21 @@ const performConfirmReceive = async (orderId) => {
1259 try { 1278 try {
1260 const order = boughtOrders.value.find(o => o.id === orderId) 1279 const order = boughtOrders.value.find(o => o.id === orderId)
1261 1280
1262 - if (wx.openBusinessView) { 1281 + // 调用确认收货API
1263 - wx.openBusinessView({ 1282 + if (order) {
1264 - businessType: 'weappOrderConfirm', 1283 + // 调用买家查询收货状态接口
1265 - extraData: { 1284 + const response = await receiveOrderAPI({ order_id: order.id })
1266 - merchant_id: order.merchant_id || '', 1285 +
1267 - merchant_trade_no: order.id, 1286 + if (response.code) {
1268 - transaction_id: order.transaction_id || '' 1287 + // 接口返回状态为11,确认收货成功
1269 - }, 1288 + order.status = 11 // 更新为已完成状态
1270 - success() { 1289 +
1271 - // 确认收货组件调用成功 1290 + Taro.showToast({
1272 - }, 1291 + title: '确认收货成功',
1273 - fail(err) { 1292 + icon: 'success',
1274 - Taro.showToast({ 1293 + duration: 2000
1275 - title: '确认收货失败', 1294 + })
1276 - icon: 'error', 1295 + }
1277 - duration: 2000
1278 - })
1279 - },
1280 - complete() {
1281 - receivingOrderId.value = ''
1282 - }
1283 - });
1284 - } else {
1285 - // 引导用户升级微信版本
1286 - Taro.showModal({
1287 - title: '提示',
1288 - content: '当前微信版本过低,请升级微信版本后重试',
1289 - showCancel: false
1290 - })
1291 } 1296 }
1292 } catch (error) { 1297 } catch (error) {
1293 Taro.showToast({ 1298 Taro.showToast({
......