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

@@ -279,21 +279,63 @@ const loadOrderDetail = async () => {
try {
const data = await supabaseService.getOrderDetail(orderId.value)
if (data != null) {
const dataObj = data as Record<string, any>
// 使用 JSON.parse(JSON.stringify()) 转换数据
const dataObj = JSON.parse(JSON.stringify(data)) as UTSJSONObject
order.value = data as OrderType
const items = dataObj['ml_order_items']
orderItems.value = items != null ? (items as OrderItemType[]) : []
deliveryAddress.value = dataObj['shipping_address'] as AddressType
// 解析订单商品
const itemsRaw = dataObj.get('ml_order_items')
if (itemsRaw != null && Array.isArray(itemsRaw)) {
const items = itemsRaw as any[]
orderItems.value = []
for (let i = 0; i < items.length; i++) {
const item = items[i]
const itemObj = JSON.parse(JSON.stringify(item)) as UTSJSONObject
const orderItem: OrderItemType = {
id: (itemObj.get('id') ?? '') as string,
product_id: (itemObj.get('product_id') ?? '') as string,
product_name: (itemObj.get('product_name') ?? '') as string,
price: (itemObj.get('price') ?? 0) as number,
quantity: (itemObj.get('quantity') ?? 1) as number,
image_url: (itemObj.get('image_url') ?? '') as string,
specifications: (itemObj.get('specifications') ?? '') as string
}
orderItems.value.push(orderItem)
}
}
// 解析收货地址
const addressRaw = dataObj.get('shipping_address')
if (addressRaw != null) {
const addressObj = JSON.parse(JSON.stringify(addressRaw)) as UTSJSONObject
const province = (addressObj.get('province') ?? '') as string
const city = (addressObj.get('city') ?? '') as string
const district = (addressObj.get('district') ?? '') as string
const detail = (addressObj.get('detail') ?? '') as string
deliveryAddress.value = {
name: (addressObj.get('name') ?? '') as string,
phone: (addressObj.get('phone') ?? '') as string,
province: province,
city: city,
district: district,
detail: detail,
address: province + city + district + detail
} as AddressType
}
// 获取店铺信息
const merchantId = dataObj['merchant_id'] as string
const merchantId = dataObj.get('merchant_id') as string
if (merchantId != null && merchantId != '') {
loadShopInfo(merchantId)
}
console.log('订单详情加载成功,商品数量:', orderItems.value.length)
} else {
uni.showToast({ title: '订单不存在', icon: 'none' })
}
} catch (e) {
console.error('加载订单详情失败:', e)
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
uni.hideLoading()