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

@@ -6,14 +6,14 @@
<view class="nav-container">
<!-- 头像 -->
<image
:src="userInfo.avatar_url || '/static/default-avatar.png'"
:src="userInfo.avatar_url != '' ? userInfo.avatar_url : '/static/default-avatar.png'"
class="nav-avatar"
@click="editProfile"
/>
<!-- 用户信息横向排列 (名字、积分、余额、优惠券) -->
<view class="nav-user-stats">
<text class="nav-user-name">{{ userInfo.nickname || userInfo.phone }}</text>
<text class="nav-user-name">{{ userInfo.nickname != '' ? userInfo.nickname : userInfo.phone }}</text>
<view class="nav-stat-item" @click="goToPoints">
<text class="nav-stat-label">积分</text>
@@ -40,6 +40,7 @@
</view>
</view>
<scroll-view class="profile-scroll-content" direction="vertical" style="flex:1; height: 0; width: 100%;">
<!-- 导航栏占位符 - 恢复 -->
<view :style="{ height: (statusBarHeight + 10) + 'px' }"></view>
@@ -243,6 +244,7 @@
</view>
</view>
</view> -->
</scroll-view>
</view>
</template>
@@ -381,8 +383,10 @@ export default {
// 按时间倒序 (created_at)
this.allOrders.sort((a: any, b: any) => {
const timeA = new Date(a.created_at || 0).getTime()
const timeB = new Date(b.created_at || 0).getTime()
const dateA = a['created_at']
const dateB = b['created_at']
const timeA = new Date(dateA != null ? dateA : 0).getTime()
const timeB = new Date(dateB != null ? dateB : 0).getTime()
return timeB - timeA
})
@@ -415,12 +419,13 @@ export default {
'shipped': '待收货订单',
'review': '待评价订单'
}
return titles[this.currentOrderTab] || '我的订单'
const title = titles[this.currentOrderTab]
return title != null ? title : '我的订单'
},
initPage() {
const systemInfo = uni.getSystemInfoSync()
this.statusBarHeight = systemInfo.statusBarHeight || 0
this.statusBarHeight = systemInfo.statusBarHeight ?? 0
},
async loadUserProfile() {
try {
@@ -436,19 +441,19 @@ export default {
let uGender = 0
if (profile instanceof UTSJSONObject) {
uId = profile.getString('user_id') || ''
uPhone = profile.getString('phone') || ''
uEmail = profile.getString('email') || ''
uNickname = profile.getString('nickname') || ''
uAvatar = profile.getString('avatar_url') || ''
uGender = profile.getNumber('gender') || 0
uId = profile.getString('user_id') ?? ''
uPhone = profile.getString('phone') ?? ''
uEmail = profile.getString('email') ?? ''
uNickname = profile.getString('nickname') ?? ''
uAvatar = profile.getString('avatar_url') ?? ''
uGender = profile.getNumber('gender') ?? 0
} else {
uId = (profile['user_id'] as string) || ''
uPhone = (profile['phone'] as string) || ''
uEmail = (profile['email'] as string) || ''
uNickname = (profile['nickname'] as string) || ''
uAvatar = (profile['avatar_url'] as string) || ''
uGender = (profile['gender'] as number) || 0
uId = (profile['user_id'] as string) ?? ''
uPhone = (profile['phone'] as string) ?? ''
uEmail = (profile['email'] as string) ?? ''
uNickname = (profile['nickname'] as string) ?? ''
uAvatar = (profile['avatar_url'] as string) ?? ''
uGender = (profile['gender'] as number) ?? 0
}
// 如果昵称为空,使用手机号脱敏显示
@@ -460,8 +465,8 @@ export default {
id: uId,
phone: uPhone,
email: uEmail,
nickname: uNickname || '微信用户',
avatar_url: uAvatar || '/static/default-avatar.png',
nickname: uNickname != '' ? uNickname : '微信用户',
avatar_url: uAvatar != '' ? uAvatar : '/static/default-avatar.png',
gender: uGender,
user_type: 1,
status: 1,
@@ -556,36 +561,50 @@ export default {
getUserLevel(): string {
const levels = ['新手', '铜牌会员', '银牌会员', '金牌会员', '钻石会员']
return levels[this.userStats.level] || '新手'
if (this.userStats.level >= 0 && this.userStats.level < levels.length) {
return levels[this.userStats.level]
}
return '新手'
},
getOrderStatusText(status: number): string {
const statusTexts = ['异常', '待支付', '待发货', '待收货', '已完成', '已取消']
return statusTexts[status] || '未知'
if (status >= 0 && status < statusTexts.length) {
return statusTexts[status]
}
return '未知'
},
getOrderStatusClass(status: number): string {
const statusClasses = ['error', 'pending', 'processing', 'shipping', 'completed', 'cancelled']
return statusClasses[status] || 'error'
if (status >= 0 && status < statusClasses.length) {
return statusClasses[status]
}
return 'error'
},
getOrderMainImage(order: any): string {
// 尝试从 ml_order_items 获取第一张图
const items = order['ml_order_items'] as any[]
if (items && items.length > 0) {
if (items != null && items.length > 0) {
const firstItem = items[0]
// 数据库字段通常是 image_url
const img = firstItem['image_url'] || firstItem['product_image']
if (img) return img as string
const imgUrl = firstItem['image_url'] as string
const prodImg = firstItem['product_image'] as string
const img = (imgUrl != null && imgUrl != '') ? imgUrl : prodImg
if (img != null && img != '') return img
}
return '/static/product1.jpg'
},
getOrderTitle(order: any): string {
const items = order['ml_order_items'] as any[]
if (items && items.length > 0) {
if (items != null && items.length > 0) {
const firstItem = items[0]
const name = (firstItem['product_name'] || '商品') as string
const pName = firstItem['product_name'] as string
const name = (pName != null && pName != '') ? pName : '商品'
if (items.length > 1) {
return `${name} 等${items.length}件商品`
}
@@ -787,9 +806,10 @@ export default {
<style>
.consumer-profile {
background-color: #f5f5f5;
min-height: 100vh;
flex: 1;
display: flex;
flex-direction: column;
}
/* 智能顶部导航栏 */
.smart-navbar {
position: fixed;
@@ -833,7 +853,8 @@ export default {
font-weight: bold;
color: white;
margin-right: 12px;
max-width: 30%; /* 限制名字宽度 */
/* max-width: 30%; REMOVED */
width: 100px; /* Use fixed width approx */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -886,7 +907,7 @@ export default {
height: 32px;
background: rgba(255, 255, 255, 0.2);
border-radius: 16px;
cursor: pointer;
/* cursor: pointer; REMOVED */
}
.action-icon {
@@ -1071,7 +1092,11 @@ export default {
.order-actions {
display: flex;
justify-content: flex-end;
gap: 15rpx;
/* gap: 15rpx; REMOVED */
}
.order-actions .action-btn {
margin-left: 15px; /* Replace gap */
}
.action-btn {
@@ -1100,7 +1125,7 @@ export default {
display: flex;
flex-direction: row;
flex-wrap: wrap; /* 允许换行 */
gap: 16px 0; /* 行间距16px列间距由 flex 控制 */
/* gap: 16px 0; REMOVED */
justify-content: flex-start; /* 从左开始排列 */
}
@@ -1111,6 +1136,7 @@ export default {
align-items: center;
position: relative;
box-sizing: border-box; /* 确保 padding 不影响宽度 */
margin-bottom: 16px; /* Replace gap row */
}
.service-icon {
@@ -1138,7 +1164,7 @@ export default {
.stats-period {
display: flex;
gap: 30rpx;
/* gap: 30rpx; REMOVED */
margin-bottom: 30rpx;
}
@@ -1147,6 +1173,7 @@ export default {
color: #666;
padding: 12rpx 24rpx;
border-radius: 20rpx;
margin-right: 30rpx; /* Replace gap */
background-color: #f0f0f0;
}
@@ -1157,7 +1184,7 @@ export default {
.stats-content {
display: flex;
gap: 20rpx;
/* gap: 20rpx; REMOVED */
}
.stat-card {
@@ -1166,6 +1193,11 @@ export default {
padding: 30rpx 0;
background-color: #f8f9fa;
border-radius: 10rpx;
margin-right: 20rpx; /* Replace gap */
}
.stat-card:last-child {
margin-right: 0;
}
.stat-value {