hookehuyr

feat(订单): 添加认证订单功能并更新业务类型枚举

更新订单API的业务类型枚举值从'sell'改为'buy_sell'
在订单管理页面添加认证订单视图模式和相关逻辑
添加认证状态映射和订单列表过滤逻辑
更新订单状态显示文本以适应认证订单场景
......@@ -39,7 +39,7 @@ export const getOrderDetailAPI = (params) => fn(fetch.get(Api.GET_ORDER_DETAIL,
* @description: 创建订单
* @param vehicle_id 车辆ID
* @param total_amount 总价
* @param business_type 业务类型(sell=买车订单, verification=认证订单)
* @param business_type buy_sell=买车订单, verification=认证订单)
* @returns data{ id }
*/
export const createOrderAPI = (params) => fn(fetch.post(Api.CREATE_ORDER, params));
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-29 16:57:13
* @LastEditTime: 2025-08-01 14:31:38
* @FilePath: /jgdl/src/pages/myCar/index.vue
* @Description: 文件描述
-->
......@@ -171,6 +171,7 @@ const themeVars = {
// 认证状态映射
const verifyStatus = ref({
1: '未认证',
2: '认证待付款',
3: '认证待审核',
5: '已认证',
7: '认证失败'
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-30 11:06:55
* @LastEditTime: 2025-08-01 14:43:46
* @FilePath: /jgdl/src/pages/myOrders/index.vue
* @Description: 订单管理页面
-->
......@@ -17,6 +17,9 @@
<view class="toggle-option" :class="{ active: viewMode === 'sell' }" @click="setViewMode('sell')">
我卖的车
</view>
<view class="toggle-option" :class="{ active: viewMode === 'verification' }" @click="setViewMode('verification')">
我的认证
</view>
</view>
</view>
......@@ -25,19 +28,19 @@
<view class="tab-item" :class="{ active: activeTab === '' }" @click="setActiveTab('')">
全部
</view>
<view v-if="viewMode === 'buy'" class="tab-item" :class="{ active: activeTab === 3 }" @click="setActiveTab(3)">
<view v-if="viewMode === 'buy' || viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 3 }" @click="setActiveTab(3)">
待支付
</view>
<view class="tab-item" :class="{ active: activeTab === 5 }" @click="setActiveTab(5)">
待发
<view v-if="viewMode === 'buy' || viewMode === 'sell' || viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 5 }" @click="setActiveTab(5)">
{{ viewMode === 'verification' ? '已付款' : '待收货' }}
</view>
<view class="tab-item" :class="{ active: activeTab === 9 }" @click="setActiveTab(9)">
<view v-if="viewMode === 'buy' || viewMode === 'sell'" class="tab-item" :class="{ active: activeTab === 9 }" @click="setActiveTab(9)">
待收货
</view>
<view class="tab-item" :class="{ active: activeTab === 11 }" @click="setActiveTab(11)">
<view v-if="viewMode === 'buy' || viewMode === 'sell'" class="tab-item" :class="{ active: activeTab === 11 }" @click="setActiveTab(11)">
已完成
</view>
<view class="tab-item" :class="{ active: activeTab === 7 }" @click="setActiveTab(7)">
<view v-if="viewMode === 'buy' || viewMode === 'sell' || viewMode === 'verification'" class="tab-item" :class="{ active: activeTab === 7 }" @click="setActiveTab(7)">
已取消
</view>
</view>
......@@ -75,10 +78,10 @@
<view class="vehicle-details">
<text class="vehicle-name">{{ order.details.vehicle.brand }} {{ order.details.vehicle.model }}</text>
<text class="vehicle-specs">
{{ order.details.vehicle.manufacture_year }}年 | 续航{{ order.details.vehicle.range_km }}km
<text>{{ order.details.vehicle.manufacture_year }}年 | </text>续航{{ order.details.vehicle.range_km }}km
</text>
<text class="vehicle-battery">电池容量:{{ order.details.vehicle.battery_capacity_ah }}Ah</text>
<text class="vehicle-price">¥{{ order.details.vehicle.price }}</text>
<text v-if="order.details.vehicle.price" class="vehicle-price">¥{{ order.details.vehicle.price }}</text>
</view>
</nut-col>
</nut-row>
......@@ -95,6 +98,18 @@
</text>
</view>
<!-- 认证模式: 支付剩余时间 -->
<view v-if="viewMode === 'verification' && order.status === 3" class="payment-countdown">
<text class="countdown-text">剩余支付时间:{{ formatCountdown(order.remain_time) }}</text>
</view>
<!-- 认证模式: 认证剩余时间 - 文字描述 -->
<view v-if="viewMode === 'verification' && order.status === 9" class="auto-receipt-countdown">
<text class="countdown-text">
{{ order.receiving_deadline_desc }}
</text>
</view>
<!-- 操作按钮 -->
<view v-if="!order.is_sold" class="order-actions">
<!-- 买车模式:待支付状态 -->
......@@ -108,6 +123,17 @@
</nut-button>
</template>
<!-- 认证模式:待支付状态 -->
<template v-if="viewMode === 'verification' && order.status === 3">
<nut-button type="default" size="small" @click="handleCancelOrder(order.id)"
:loading="cancelingOrderId === order.id" :disabled="cancelingOrderId === order.id">
{{ cancelingOrderId === order.id ? '取消中...' : '取消订单' }}
</nut-button>
<nut-button type="primary" size="small" @click="handlePayment(order)" color="orange" class="ml-2">
去支付
</nut-button>
</template>
<!-- 买车模式:待收货状态 -->
<template v-if="viewMode === 'buy' && order.status === 9">
<nut-button type="default" size="small" @click="viewOrderDetail(order.id)">
......@@ -486,6 +512,9 @@ const boughtOrders = ref([])
// 订单数据 - 我卖的车
const soldOrders = ref([])
// 订单数据 - 我认证的车
const verificationOrders = ref([])
// 分页相关状态
const currentPage = ref(0)
const pageLimit = ref(10)
......@@ -497,7 +526,7 @@ const countdownIntervals = ref(new Map()) // 摮瘥葵霈W恣摰
* 根据当前视图模式和筛选条件获取过滤后的订单列表
*/
const filteredOrders = computed(() => {
const orders = viewMode.value === 'buy' ? boughtOrders.value : soldOrders.value
const orders = viewMode.value === 'buy' ? boughtOrders.value : viewMode.value === 'verification' ? verificationOrders.value : soldOrders.value
if (activeTab.value === '') {
return orders
......@@ -544,7 +573,7 @@ const loadOrderData = async (isLoadMore = false) => {
try {
loading.value = true
const type = viewMode.value === 'buy' ? 'buy' : 'sell'
const type = viewMode.value === 'buy' ? 'buy' : viewMode.value === 'verification' ? 'verification' : 'sell'
const status = activeTab.value || undefined
const page = isLoadMore ? currentPage.value + 1 : 0
......@@ -612,7 +641,7 @@ const loadOrderData = async (isLoadMore = false) => {
return processedOrder
})
const targetOrders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const targetOrders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
if (isLoadMore) {
targetOrders.value = [...targetOrders.value, ...newOrders]
......@@ -663,6 +692,7 @@ const resetListState = (resetData = false) => {
// 清空订单数据
boughtOrders.value = []
soldOrders.value = []
verificationOrders.value = []
// 重新加载数据
loadOrderData(false)
}
......@@ -698,7 +728,7 @@ const getStatusText = (status) => {
case 3:
return '待支付'
case 5:
return '待发货'
return viewMode.value === 'verification' ? '已付款' : '待收货'
case 9:
return '待收货'
case 11:
......@@ -762,7 +792,7 @@ const startCountdown = (order) => {
}
const timer = setInterval(async () => {
const orders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const orders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const targetOrderIndex = orders.value.findIndex(o => o.id === order.id)
if (targetOrderIndex !== -1) {
......@@ -808,7 +838,7 @@ const handleTimeoutCancel = async (order) => {
}
// 更新订单状态为已取消
const orders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const orders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const targetOrderIndex = orders.value.findIndex(o => o.id === order.id)
if (targetOrderIndex !== -1) {
......@@ -881,7 +911,7 @@ const onPayClose = () => {
*/
const onPaySuccess = ({ orderId }) => {
// 找到对应的订单并更新状态
const orders = viewMode.value === 'buy' ? boughtOrders.value : soldOrders.value
const orders = viewMode.value === 'buy' ? boughtOrders.value : viewMode.value === 'verification' ? verificationOrders.value : soldOrders.value
const order = orders.find(o => o.id === orderId)
if (order) {
......@@ -901,7 +931,7 @@ const onPaySuccess = ({ orderId }) => {
*/
const viewOrderDetail = async (orderId) => {
// 找到对应的订单
const orders = viewMode.value === 'buy' ? boughtOrders.value : soldOrders.value
const orders = viewMode.value === 'buy' ? boughtOrders.value : viewMode.value === 'verification' ? verificationOrders.value : soldOrders.value
const order = orders.find(o => o.id === orderId)
if (order) {
......@@ -926,7 +956,7 @@ const closeOrderDetailPopup = () => {
*/
const rateOrder = (orderId) => {
// 找到对应的订单
const orders = viewMode.value === 'buy' ? boughtOrders.value : soldOrders.value
const orders = viewMode.value === 'buy' ? boughtOrders.value : viewMode.value === 'verification' ? verificationOrders.value : soldOrders.value
const order = orders.find(o => o.id === orderId)
if (order) {
......@@ -983,7 +1013,7 @@ const submitRate = async () => {
})
if (response.code) {
// API提交成功后的处理
const currentOrders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const currentOrders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const order = currentOrders.value.find(o => o.id === currentRateOrder.value.id)
if (order) {
// 创建评价数据对象
......@@ -1109,7 +1139,7 @@ const performCancelOrder = async (orderId) => {
if (response.code) {
// API取消成功后的处理
const orders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const orders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const order = orders.value.find(o => o.id === orderId)
if (order) {
......@@ -1120,7 +1150,7 @@ const performCancelOrder = async (orderId) => {
}
// 更新订单状态为已取消
const orders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const orders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const targetOrderIndex = orders.value.findIndex(o => o.id === orderId)
if (targetOrderIndex !== -1) {
......@@ -1281,7 +1311,7 @@ const performConfirmShip = async (orderId) => {
if (response.code) {
// API发货成功后的处理
const orders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const orders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const order = orders.value.find(o => o.id === orderId)
if (order) {
......@@ -1329,7 +1359,7 @@ const performDeleteOrder = async (orderId) => {
if (response.code) {
// API删除成功后的处理
const orders = viewMode.value === 'buy' ? boughtOrders : soldOrders
const orders = viewMode.value === 'buy' ? boughtOrders : viewMode.value === 'verification' ? verificationOrders : soldOrders
const orderIndex = orders.value.findIndex(order => order.id === orderId)
if (orderIndex !== -1) {
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-31 15:29:14
* @LastEditTime: 2025-08-01 14:35:15
* @FilePath: /jgdl/src/pages/productDetail/index.vue
* @Description: 商品详情页
-->
......@@ -485,7 +485,7 @@ const handlePurchase = async () => {
const onPay = async ({ id, remain_time, price }) => {
try {
const { code, data } = await createOrderAPI({
business_type: 'sell',
business_type: 'buy_sell',
vehicle_id: id,
total_amount: price
})
......