consumerm模块完成度90%,完善消费者和商家端数据库表,商品、聊天、订单数据对接好了supabase,和商家端对接了聊天功能,安卓端编译通过了css样式,剩余几个页面在处理函数规范问题

This commit is contained in:
cyh666666
2026-02-24 17:17:49 +08:00
parent e2f1dfb097
commit e606c597ca
174 changed files with 37917 additions and 4444 deletions

View File

@@ -103,6 +103,32 @@
import { ref, onMounted, watch } from 'vue'
import { supabaseService } from '@/utils/supabaseService.uts'
type RefundStatusHistoryItem = {
status: number
remark: string
created_at: string
}
type RefundProductInfo = {
images: string[]
}
type RefundOrderItem = {
id: string
product_name: string
sku_specifications: any
price: number
quantity: number
product?: RefundProductInfo
}
type RefundOrderInfo = {
id: string
order_no: string
created_at: string
order_items: RefundOrderItem[]
}
type RefundType = {
id: string
user_id: string
@@ -112,27 +138,9 @@ type RefundType = {
refund_reason: string
refund_amount: number
status: number // 1:待处理 2:处理中 3:已完成 4:已取消 5:已拒绝
status_history: Array<{
status: number
remark: string
created_at: string
}> | null
status_history: RefundStatusHistoryItem[] | null
created_at: string
order?: {
id: string
order_no: string
created_at: string
order_items: Array<{
id: string
product_name: string
sku_specifications: any
price: number
quantity: number
product?: {
images: string[]
}
}>
}
order?: RefundOrderInfo
}
type TabCountsType = {
@@ -178,7 +186,7 @@ const loadRefunds = async (loadMore: boolean = false) => {
try {
const userId = getCurrentUserId()
if (!userId) {
if (userId == '') {
uni.navigateTo({
url: '/pages/user/login'
})
@@ -198,28 +206,28 @@ const loadRefunds = async (loadMore: boolean = false) => {
// Map data to UI structure (RefundType)
const newRefunds = rawData.map((item: any): RefundType => {
const orderObj = item.order || {}
const dbItems = orderObj.ml_order_items || []
const uiItems = dbItems.map((di: any) : any => ({
id: di.id || '',
product_name: di.product_name,
sku_specifications: di.specifications,
const orderObj: any = item['order'] ?? {}
const dbItems: any[] = (orderObj['ml_order_items'] as any[]) ?? []
const uiItems = dbItems.map((di: any) : RefundOrderItem => ({
id: di['id'] ?? '',
product_name: di['product_name'] ?? '',
sku_specifications: di['specifications'],
price: 0,
quantity: di.quantity || 1,
product: { images: [di.image_url || '/static/default-product.png'] }
quantity: di['quantity'] ?? 1,
product: { images: [di['image_url'] ?? '/static/default-product.png'] }
}))
return {
id: item.id,
user_id: item.user_id,
order_id: item.order_id,
refund_no: item.refund_no,
refund_type: item.refund_type,
refund_reason: item.refund_reason,
refund_amount: Number(item.refund_amount),
status: item.status,
id: item['id'],
user_id: item['user_id'],
order_id: item['order_id'],
refund_no: item['refund_no'],
refund_type: item['refund_type'],
refund_reason: item['refund_reason'],
refund_amount: Number(item['refund_amount']),
status: item['status'],
// Handle missing timeline by defaulting or leaving empty
status_history: item.status_history || [],
status_history: (item['status_history'] as RefundStatusHistoryItem[]) ?? [],
created_at: item.created_at,
order: {
id: item.order_id,
@@ -249,7 +257,7 @@ const loadRefunds = async (loadMore: boolean = false) => {
// 加载标签页计数
const loadTabCounts = async () => {
const userId = getCurrentUserId()
if (!userId) return
if (userId == '') return
try {
const { count, error } = await supa
@@ -263,7 +271,7 @@ const loadTabCounts = async () => {
return
}
tabCounts.value.processing = count || 0
tabCounts.value.processing = count ?? 0
} catch (err) {
console.error('加载计数异常:', err)
}
@@ -272,7 +280,7 @@ const loadTabCounts = async () => {
// 获取当前用户ID
const getCurrentUserId = (): string => {
const userStore = uni.getStorageSync('userInfo')
return userStore?.id || ''
return userStore['id'] ?? ''
}
// 获取状态文本
@@ -284,7 +292,7 @@ const getStatusText = (status: number): string => {
4: '已取消',
5: '已拒绝'
}
return statusMap[status] || '未知状态'
return statusMap[status] ?? '未知状态'
}
// 获取状态样式类
@@ -296,21 +304,21 @@ const getStatusClass = (status: number): string => {
4: 'status-cancelled',
5: 'status-rejected'
}
return classMap[status] || 'status-unknown'
return classMap[status] ?? 'status-unknown'
}
// 获取商品图片
const getProductImage = (refund: RefundType): string => {
const firstItem = refund.order?.order_items?.[0]
if (!firstItem?.product?.images?.[0]) {
if (firstItem?.product?.images == null || firstItem?.product?.images.length == 0) {
return '/static/default-product.png'
}
return firstItem.product.images[0]
return firstItem.product!.images[0]
}
// 获取商品名称
const getProductName = (refund: RefundType): string => {
const items = refund.order?.order_items || []
const items = refund.order?.order_items ?? []
if (items.length === 0) return '未知商品'
if (items.length === 1) {
@@ -322,7 +330,7 @@ const getProductName = (refund: RefundType): string => {
// 格式化时间
const formatTime = (timeStr?: string): string => {
if (!timeStr) return ''
if (timeStr == null || timeStr == '') return ''
const date = new Date(timeStr)
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
@@ -401,7 +409,7 @@ const cancelRefund = (refund: RefundType) => {
.from('refunds')
.update({
status: 4, // 已取消
status_history: [...(refund.status_history || []), {
status_history: [...(refund.status_history ?? []), {
status: 4,
remark: '用户取消申请',
created_at: new Date().toISOString()
@@ -511,7 +519,7 @@ const goBack = () => {
.refund-page {
display: flex;
flex-direction: column;
height: 100vh;
flex: 1;
background-color: #f5f5f5;
}
@@ -551,16 +559,7 @@ const goBack = () => {
.refund-tab.active {
color: #007aff;
}
.refund-tab.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 2px;
background-color: #007aff;
border-bottom: 2px solid #007aff;
}
.tab-text {
@@ -725,7 +724,7 @@ const goBack = () => {
.refund-amount {
display: flex;
align-items: baseline;
align-items: flex-end;
}
.amount-label {
@@ -783,32 +782,30 @@ const goBack = () => {
color: #333333;
font-weight: bold;
margin-bottom: 3px;
display: block;
}
.step-time {
font-size: 12px;
color: #999999;
margin-bottom: 3px;
display: block;
}
.step-desc {
font-size: 12px;
color: #666666;
display: block;
}
.refund-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
/* gap: 10px; removed for uni-app-x */
padding-top: 15px;
border-top: 1px solid #f5f5f5;
}
.action-btn {
padding: 8px 15px;
margin-left: 10px;
padding: 6px 15px;
border-radius: 15px;
font-size: 12px;
border: 1px solid;