合并merchant文件
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
<<<<<<< HEAD
|
||||
<!-- 商家端 - 订单管理页面 -->
|
||||
=======
|
||||
<!-- 商家端 - 订单管理页面 -->
|
||||
>>>>>>> local-backup-root-cyj
|
||||
<template>
|
||||
<view class="orders-page">
|
||||
<!-- 标签页切换 -->
|
||||
@@ -96,14 +100,22 @@
|
||||
</view>
|
||||
<view class="order-actions">
|
||||
<view
|
||||
<<<<<<< HEAD
|
||||
v-if="order.order_status === 1"
|
||||
=======
|
||||
v-if="order.order_status === 2"
|
||||
>>>>>>> local-backup-root-cyj
|
||||
class="action-btn primary"
|
||||
@click.stop="shipOrder(order)"
|
||||
>
|
||||
发货
|
||||
</view>
|
||||
<view
|
||||
<<<<<<< HEAD
|
||||
v-if="order.order_status === 2"
|
||||
=======
|
||||
v-if="order.order_status === 3"
|
||||
>>>>>>> local-backup-root-cyj
|
||||
class="action-btn info"
|
||||
@click.stop="viewLogistics(order)"
|
||||
>
|
||||
@@ -147,7 +159,11 @@
|
||||
@change="onLogisticsChange"
|
||||
>
|
||||
<view class="picker-value">
|
||||
<<<<<<< HEAD
|
||||
{{ selectedLogistics.name || '请选择物流公司' }}
|
||||
=======
|
||||
{{ selectedLogistics?.name || '请选择物流公司' }}
|
||||
>>>>>>> local-backup-root-cyj
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
@@ -222,7 +238,11 @@
|
||||
{ name: '待发货', status: 2, count: 0 },
|
||||
{ name: '待收货', status: 3, count: 0 },
|
||||
{ name: '已完成', status: 4, count: 0 },
|
||||
<<<<<<< HEAD
|
||||
{ name: '退款', status: 0, count: 0 }
|
||||
=======
|
||||
{ name: '退款', status: 6, count: 0 }
|
||||
>>>>>>> local-backup-root-cyj
|
||||
] as TabType[],
|
||||
currentTab: -2,
|
||||
searchKeyword: '',
|
||||
@@ -257,7 +277,11 @@
|
||||
const statusMap: Record<string, number> = {
|
||||
'pending': 1,
|
||||
'shipped': 3,
|
||||
<<<<<<< HEAD
|
||||
'refund': 0,
|
||||
=======
|
||||
'refund': 6,
|
||||
>>>>>>> local-backup-root-cyj
|
||||
'completed': 4
|
||||
}
|
||||
this.currentTab = statusMap[type] ?? -2
|
||||
@@ -301,7 +325,11 @@
|
||||
.from('ml_orders')
|
||||
.select(`
|
||||
*,
|
||||
<<<<<<< HEAD
|
||||
order_items!inner (
|
||||
=======
|
||||
order_items (
|
||||
>>>>>>> local-backup-root-cyj
|
||||
id,
|
||||
order_id,
|
||||
product_id,
|
||||
@@ -320,8 +348,14 @@
|
||||
.limit(this.limit)
|
||||
|
||||
if (this.currentTab !== -2) {
|
||||
<<<<<<< HEAD
|
||||
if (this.currentTab === 0) {
|
||||
query = query.eq('order_status', 0)
|
||||
=======
|
||||
if (this.currentTab === 6) {
|
||||
// 退款状态同时查询 0 和 6
|
||||
query = query.in('order_status', [0, 6])
|
||||
>>>>>>> local-backup-root-cyj
|
||||
} else {
|
||||
query = query.eq('order_status', this.currentTab)
|
||||
}
|
||||
@@ -333,7 +367,11 @@
|
||||
|
||||
const response = await query.execute()
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (response.error != null) {
|
||||
=======
|
||||
if (response.error != null || (response.status ?? 200) >= 400) {
|
||||
>>>>>>> local-backup-root-cyj
|
||||
console.error('获取订单失败:', response.error)
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
return
|
||||
@@ -349,19 +387,32 @@
|
||||
const ordersData: OrderType[] = []
|
||||
for (let i = 0; i < rawData.length; i++) {
|
||||
const item = rawData[i]
|
||||
<<<<<<< HEAD
|
||||
const orderObj = item as UTSJSONObject
|
||||
=======
|
||||
const str = JSON.stringify(item)
|
||||
const orderObj = JSON.parse(str) as UTSJSONObject
|
||||
>>>>>>> local-backup-root-cyj
|
||||
|
||||
const order: OrderType = {
|
||||
id: orderObj.getString('id') || '',
|
||||
order_no: orderObj.getString('order_no') || '',
|
||||
user_id: orderObj.getString('user_id') || '',
|
||||
merchant_id: orderObj.getString('merchant_id') || '',
|
||||
<<<<<<< HEAD
|
||||
order_status: orderObj.getNumber('order_status') || 1,
|
||||
=======
|
||||
order_status: orderObj.getNumber('order_status') ?? (orderObj.get('order_status') == null ? 1 : (orderObj.get('order_status') as number)),
|
||||
>>>>>>> local-backup-root-cyj
|
||||
total_amount: orderObj.getNumber('total_amount') || 0,
|
||||
product_amount: orderObj.getNumber('product_amount') || 0,
|
||||
shipping_fee: orderObj.getNumber('shipping_fee') || 0,
|
||||
paid_amount: orderObj.getNumber('paid_amount') || 0,
|
||||
<<<<<<< HEAD
|
||||
shipping_address: orderObj.getString('shipping_address') || '',
|
||||
=======
|
||||
shipping_address: orderObj.get('shipping_address') != null ? (typeof orderObj.get('shipping_address') === 'string' ? orderObj.getString('shipping_address')! : JSON.stringify(orderObj.get('shipping_address'))) : '',
|
||||
>>>>>>> local-backup-root-cyj
|
||||
remark: orderObj.getString('remark') || '',
|
||||
created_at: orderObj.getString('created_at') || '',
|
||||
updated_at: orderObj.getString('updated_at') || '',
|
||||
@@ -372,7 +423,14 @@
|
||||
if (itemsObj != null && Array.isArray(itemsObj)) {
|
||||
const itemsArray = itemsObj as any[]
|
||||
for (let j = 0; j < itemsArray.length; j++) {
|
||||
<<<<<<< HEAD
|
||||
const orderItem = itemsArray[j] as UTSJSONObject
|
||||
=======
|
||||
const rawItem = itemsArray[j]
|
||||
const itemStr = JSON.stringify(rawItem)
|
||||
const orderItem = JSON.parse(itemStr) as UTSJSONObject
|
||||
|
||||
>>>>>>> local-backup-root-cyj
|
||||
order.items.push({
|
||||
id: orderItem.getString('id') || '',
|
||||
order_id: orderItem.getString('order_id') || '',
|
||||
@@ -424,13 +482,29 @@
|
||||
const rawData = response.data as any[]
|
||||
if (rawData != null) {
|
||||
for (let i = 0; i < rawData.length; i++) {
|
||||
<<<<<<< HEAD
|
||||
const item = rawData[i] as UTSJSONObject
|
||||
const status = item.getNumber('order_status') || 1
|
||||
=======
|
||||
const row = rawData[i]
|
||||
const istr = JSON.stringify(row)
|
||||
const item = JSON.parse(istr) as UTSJSONObject
|
||||
const status_val = item.get('order_status')
|
||||
let status = 1
|
||||
if (status_val != null) {
|
||||
status = (typeof status_val === 'number') ? (status_val as number) : parseInt(status_val.toString())
|
||||
}
|
||||
|
||||
>>>>>>> local-backup-root-cyj
|
||||
if (status === 1) counts[1]++
|
||||
else if (status === 2) counts[2]++
|
||||
else if (status === 3) counts[3]++
|
||||
else if (status === 4) counts[4]++
|
||||
<<<<<<< HEAD
|
||||
else if (status === 0) counts[0]++
|
||||
=======
|
||||
else if (status === 0 || status === 6) counts[0]++
|
||||
>>>>>>> local-backup-root-cyj
|
||||
total++
|
||||
}
|
||||
}
|
||||
@@ -500,7 +574,11 @@
|
||||
},
|
||||
|
||||
async confirmShip() {
|
||||
<<<<<<< HEAD
|
||||
if (!this.selectedLogistics.name) {
|
||||
=======
|
||||
if (this.selectedLogistics == null || !this.selectedLogistics?.name) {
|
||||
>>>>>>> local-backup-root-cyj
|
||||
uni.showToast({ title: '请选择物流公司', icon: 'none' })
|
||||
return
|
||||
}
|
||||
@@ -510,6 +588,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
<<<<<<< HEAD
|
||||
const response = await supa
|
||||
.from('ml_orders')
|
||||
.update({
|
||||
@@ -524,6 +603,31 @@
|
||||
|
||||
if (response.error != null) {
|
||||
uni.showToast({ title: '发货失败', icon: 'none' })
|
||||
=======
|
||||
const payloadStr = JSON.stringify({
|
||||
order_status: 3,
|
||||
shipping_status: 2,
|
||||
carrier_name: this.selectedLogistics?.name ?? '未知',
|
||||
tracking_no: this.trackingNumber,
|
||||
shipped_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString()
|
||||
});
|
||||
const payload = JSON.parse(payloadStr) as UTSJSONObject;
|
||||
console.log('--- PAYLOAD TO SEND ---', JSON.stringify(payload));
|
||||
const response = await supa.from('ml_orders').update(payload
|
||||
)
|
||||
.eq('id', this.currentOrder!.id)
|
||||
.execute()
|
||||
|
||||
if (response.error != null || (response.status ?? 200) >= 400) {
|
||||
let msg = '';
|
||||
if (response.error != null) msg = response.error!.message;
|
||||
else if (response.data != null) {
|
||||
const rData = response.data as UTSJSONObject;
|
||||
msg = rData.getString('message') ?? rData.getString('code') ?? JSON.stringify(rData);
|
||||
}
|
||||
if (!msg) msg = '请检查网络或登录状态'; uni.showToast({ title: '发货被拦截: ' + msg, icon: 'none', duration: 4500 }); console.error('SUPABASE API ERR:', response)
|
||||
>>>>>>> local-backup-root-cyj
|
||||
return
|
||||
}
|
||||
|
||||
@@ -531,14 +635,22 @@
|
||||
this.closeShipModal()
|
||||
this.loadOrders()
|
||||
this.loadOrderCounts()
|
||||
<<<<<<< HEAD
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '发货失败', icon: 'none' })
|
||||
}
|
||||
=======
|
||||
} catch (e) { uni.showToast({ title: '发货发生异常', icon: 'none' }); console.error(e) }
|
||||
>>>>>>> local-backup-root-cyj
|
||||
},
|
||||
|
||||
viewLogistics(order: OrderType) {
|
||||
uni.navigateTo({
|
||||
<<<<<<< HEAD
|
||||
url: `/pages/mall/merchant/logistics?orderId=${order.id}`
|
||||
=======
|
||||
url: `/pages/mall/consumer/logistics?orderId=${order.id}`
|
||||
>>>>>>> local-backup-root-cyj
|
||||
})
|
||||
},
|
||||
|
||||
@@ -555,7 +667,11 @@
|
||||
.eq('id', order.id)
|
||||
.execute()
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (response.error != null) {
|
||||
=======
|
||||
if (response.error != null || (response.status ?? 200) >= 400) {
|
||||
>>>>>>> local-backup-root-cyj
|
||||
uni.showToast({ title: '删除失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
@@ -576,7 +692,12 @@
|
||||
if (status === 2) return '待发货'
|
||||
if (status === 3) return '待收货'
|
||||
if (status === 4) return '已完成'
|
||||
<<<<<<< HEAD
|
||||
if (status === 0) return '退款中'
|
||||
=======
|
||||
if (status === 0 || status === 6) return '退款/售后'
|
||||
if (status === 7) return '退货完成'
|
||||
>>>>>>> local-backup-root-cyj
|
||||
if (status === 5 || status === -1) return '已取消'
|
||||
return '未知'
|
||||
},
|
||||
@@ -717,8 +838,14 @@
|
||||
|
||||
.order-card {
|
||||
background-color: #fff;
|
||||
<<<<<<< HEAD
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
=======
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 24rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
|
||||
>>>>>>> local-backup-root-cyj
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -817,22 +944,54 @@
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
.product-spec {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
margin-top: 8rpx;
|
||||
=======
|
||||
.product-name {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 8rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.product-spec {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
background-color: #f8f8f8;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 4rpx;
|
||||
align-self: flex-start;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.product-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
margin-left: 20rpx;
|
||||
min-width: 120rpx;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
<<<<<<< HEAD
|
||||
font-weight: 500;
|
||||
=======
|
||||
font-weight: bold;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.product-quantity {
|
||||
@@ -845,8 +1004,14 @@
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
<<<<<<< HEAD
|
||||
padding: 20rpx 24rpx;
|
||||
border-top: 1rpx solid #f5f5f5;
|
||||
=======
|
||||
padding: 24rpx;
|
||||
border-top: 1rpx solid #f8f8f8;
|
||||
background-color: #fafafa;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.order-amount {
|
||||
@@ -860,7 +1025,11 @@
|
||||
}
|
||||
|
||||
.amount-value {
|
||||
<<<<<<< HEAD
|
||||
font-size: 28rpx;
|
||||
=======
|
||||
font-size: 32rpx;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
color: #FF3B30;
|
||||
font-weight: bold;
|
||||
margin-left: 10rpx;
|
||||
@@ -872,14 +1041,27 @@
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
<<<<<<< HEAD
|
||||
padding: 12rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 28rpx;
|
||||
=======
|
||||
min-width: 120rpx;
|
||||
height: 56rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24rpx;
|
||||
border-radius: 28rpx;
|
||||
border: 1rpx solid #eee;
|
||||
padding: 0 20rpx;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.action-btn.primary {
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
.action-btn.info {
|
||||
@@ -890,6 +1072,21 @@
|
||||
.action-btn.default {
|
||||
background-color: #F5F5F5;
|
||||
color: #666;
|
||||
=======
|
||||
border: none;
|
||||
}
|
||||
|
||||
.action-btn.info {
|
||||
background-color: #fff;
|
||||
color: #007AFF;
|
||||
border-color: #007AFF;
|
||||
}
|
||||
|
||||
.action-btn.default {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
border-color: #ddd;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.load-more, .no-more {
|
||||
@@ -912,7 +1109,11 @@
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
<<<<<<< HEAD
|
||||
z-index: 1000;
|
||||
=======
|
||||
z-index: 99;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
@@ -920,6 +1121,11 @@
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
position: relative;
|
||||
z-index: 99;
|
||||
>>>>>>> local-backup-root-cyj
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
@@ -994,3 +1200,19 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
>>>>>>> local-backup-root-cyj
|
||||
|
||||
Reference in New Issue
Block a user