consumer模块完成度95%,安卓端大部分页面能正常获取数据,页面样式显示基本正常,逐渐完善;消费者端的积分、余额、评价、优惠券等小模块正在完善

This commit is contained in:
cyh666666
2026-03-02 17:21:19 +08:00
parent df84fd8642
commit 7e74b88e1e
34 changed files with 17088 additions and 1751 deletions

View File

@@ -40,9 +40,9 @@
</view>
</view>
<scroll-view class="profile-scroll-content" direction="vertical" style="flex:1; height: 0; width: 100%;">
<!-- 导航栏占位符 - 恢复 -->
<view :style="{ height: (statusBarHeight + 10) + 'px' }"></view>
<scroll-view class="profile-scroll-content" :scroll-y="true">
<!-- 导航栏占位符 - 需要包含statusBarHeight + 导航栏高度44px -->
<view :style="{ height: (statusBarHeight + 44) + 'px' }"></view>
<!-- 我的服务 (移到订单上方) -->
<view class="my-services" style="margin-top: 10px;">
@@ -249,7 +249,7 @@
</template>
<script>
import { UserType, OrderType } from '@/types/mall-types.uts'
import { UserType } from '@/types/mall-types.uts'
import supabaseService from '@/utils/supabaseService.uts'
type UserStatsType = {
@@ -283,6 +283,15 @@ type StatsPeriodType = {
label: string
}
type OrderItemType = {
id: string
order_no: string
status: number
actual_amount: number
created_at: string
ml_order_items: any | null
}
export default {
data() {
return {
@@ -313,7 +322,7 @@ export default {
coupons: 0,
favorites: 0
} as ServiceCountsType,
recentOrders: [] as Array<OrderType>,
recentOrders: [] as Array<OrderItemType>,
statsPeriods: [
{ key: 'month', label: '本月' },
{ key: 'quarter', label: '本季度' },
@@ -328,8 +337,8 @@ export default {
save_amount: 0
} as ConsumptionStatsType,
statusBarHeight: 0,
currentOrderTab: 'all' as string, // 当前选中的订单Tab
allOrders: [] as Array<OrderType> // 存储所有订单数据
currentOrderTab: 'all' as string,
allOrders: [] as Array<OrderItemType>
}
},
onLoad() {
@@ -348,8 +357,8 @@ export default {
uni.$off('orderUpdated', this.handleOrderUpdated)
},
computed: {
filteredOrders(): Array<OrderType> {
const result: Array<OrderType> = []
filteredOrders(): Array<OrderItemType> {
const result: Array<OrderItemType> = []
if (this.currentOrderTab === 'all') {
for (let i: number = 0; i < this.allOrders.length; i++) {
result.push(this.allOrders[i])
@@ -377,29 +386,37 @@ export default {
}
},
methods: {
// 加载订单数据
async loadOrders() {
try {
const orders = await supabaseService.getOrders()
const mappedOrders: Array<OrderType> = []
const mappedOrders: Array<OrderItemType> = []
for (let i: number = 0; i < orders.length; i++) {
const o = orders[i] as UTSJSONObject
const orderObj = new UTSJSONObject()
const rawItem = orders[i]
const o = JSON.parse(JSON.stringify(rawItem)) as UTSJSONObject
const keys = UTSJSONObject.keys(o)
for (let j: number = 0; j < keys.length; j++) {
const key = keys[j]
orderObj.set(key, o.get(key))
let status = o.getNumber('status')
if (status == null) {
const orderStatus = o.getNumber('order_status')
status = orderStatus != null ? orderStatus : 0
}
if (o.getNumber('status') == null && o.getNumber('order_status') != null) {
orderObj.set('status', o.getNumber('order_status'))
let actualAmount = o.getNumber('actual_amount')
if (actualAmount == null) {
const totalAmount = o.getNumber('total_amount')
actualAmount = totalAmount != null ? totalAmount : 0
}
if (o.getNumber('actual_amount') == null && o.getNumber('total_amount') != null) {
orderObj.set('actual_amount', o.getNumber('total_amount'))
const orderItem: OrderItemType = {
id: o.getString('id') ?? '',
order_no: o.getString('order_no') ?? '',
status: status,
actual_amount: actualAmount,
created_at: o.getString('created_at') ?? '',
ml_order_items: o.get('ml_order_items')
}
mappedOrders.push(orderObj as OrderType)
mappedOrders.push(orderItem)
}
for (let i: number = 0; i < mappedOrders.length; i++) {
@@ -418,7 +435,7 @@ export default {
this.allOrders = mappedOrders
const recentList: Array<OrderType> = []
const recentList: Array<OrderItemType> = []
const limit = mappedOrders.length < 5 ? mappedOrders.length : 5
for (let i: number = 0; i < limit; i++) {
recentList.push(mappedOrders[i])
@@ -627,30 +644,28 @@ export default {
return 'error'
},
getOrderMainImage(order: any): string {
const orderObj = order as UTSJSONObject
const itemsRaw = orderObj.get('ml_order_items')
getOrderMainImage(order: OrderItemType): string {
const itemsRaw = order.ml_order_items
if (itemsRaw == null) return '/static/product1.jpg'
const items = itemsRaw as any[]
if (items.length > 0) {
const firstItem = items[0] as UTSJSONObject
const imgUrl = firstItem.getString('image_url') ?? ''
const prodImg = firstItem.getString('product_image') ?? ''
const img = imgUrl !== '' ? imgUrl : prodImg
if (img !== '') return img
const firstItem = items[0] as Record<string, any>
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 orderObj = order as UTSJSONObject
const itemsRaw = orderObj.get('ml_order_items')
getOrderTitle(order: OrderItemType): string {
const itemsRaw = order.ml_order_items
if (itemsRaw == null) return '精选商品'
const items = itemsRaw as any[]
if (items.length > 0) {
const firstItem = items[0] as UTSJSONObject
const pName = firstItem.getString('product_name') ?? ''
const name = pName !== '' ? pName : '商品'
const firstItem = items[0] as Record<string, any>
const pName = firstItem['product_name'] as string
const name = (pName != null && pName !== '') ? pName : '商品'
if (items.length > 1) {
return `${name} 等${items.length}件商品`
@@ -712,19 +727,19 @@ export default {
})
},
viewOrderDetail(order: OrderType) {
viewOrderDetail(order: OrderItemType) {
uni.navigateTo({
url: `/pages/mall/consumer/order-detail?orderId=${order.id}`
})
},
payOrder(order: OrderType) {
payOrder(order: OrderItemType) {
uni.navigateTo({
url: `/pages/mall/consumer/payment?orderId=${order.id}`
})
},
confirmReceive(order: OrderType) {
confirmReceive(order: OrderItemType) {
uni.showModal({
title: '确认收货',
content: '确认已收到商品吗?',
@@ -740,7 +755,7 @@ export default {
})
},
reviewOrder(order: OrderType) {
reviewOrder(order: OrderItemType) {
uni.navigateTo({
url: `/pages/mall/consumer/review?orderId=${order.id}`
})
@@ -855,6 +870,12 @@ export default {
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
}
.profile-scroll-content {
flex: 1;
}
/* 智能顶部导航栏 */
.smart-navbar {
@@ -862,13 +883,12 @@ export default {
top: 0;
left: 0;
right: 0;
background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
background-color: #4CAF50;
z-index: 1000;
box-shadow: 0 2px 12px rgba(76, 175, 80, 0.15);
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
flex-direction: column;
justify-content: flex-start;
}
.nav-container {