完成consumer端同步

This commit is contained in:
2026-05-14 15:28:09 +08:00
parent 612fb3d360
commit 0ffbc53902
197 changed files with 92657 additions and 7564 deletions

View File

@@ -21,7 +21,7 @@
<view class="products-section">
<view v-for="(item, index) in orderItems" :key="item.id" class="product-review">
<view class="product-header">
<image class="product-image" :src="item.product_image ?? '/static/default-product.png'" />
<image class="product-image" :src="item.product_image ?? '/static/images/default.png'" />
<view class="product-info">
<text class="product-name">{{ item.product_name }}</text>
<text v-if="item.sku_specifications != null" class="product-spec">{{ getSpecText(item.sku_specifications) }}</text>
@@ -49,7 +49,7 @@
v-model="contents[index]"
placeholder="请写下您的使用感受,分享给其他小伙伴吧"
maxlength="500"></textarea>
<text class="word-count">{{ contents[index]?.length || 0 }}/500</text>
<text class="word-count">{{ contents[index]?.length ?? 0 }}/500</text>
</view>
<!-- 图片上传 -->
@@ -163,7 +163,7 @@ type OrderItemType = {
product_id: number
product_name: string
product_image: string
sku_specifications: any | null
sku_specifications: UTSJSONObject | string | null
price: number
quantity: number
}
@@ -225,7 +225,7 @@ const loadOrderData = async (): Promise<void> => {
console.log('[loadOrderData] itemsRaw:', JSON.stringify(itemsRaw))
if (itemsRaw != null) {
const itemsList = itemsRaw as any[]
const itemsList = itemsRaw as Array<UTSJSONObject>
const processedItems: Array<OrderItemType> = []
for (let i: number = 0; i < itemsList.length; i++) {
@@ -241,7 +241,7 @@ const loadOrderData = async (): Promise<void> => {
price: (item.getNumber('price') ?? 0) as number,
quantity: (item.getNumber('quantity') ?? 1) as number,
sku_specifications: skuSpec,
product_image: item.getString('product_image') ?? item.getString('image_url') ?? '/static/default-product.png'
product_image: item.getString('product_image') ?? item.getString('image_url') ?? '/static/images/default.png'
} as OrderItemType)
}
orderItems.value = processedItems
@@ -292,7 +292,7 @@ const canSubmit = computed((): boolean => {
return true
})
onLoad((options: any) => {
onLoad((options) => {
if (options != null) {
const optObj = options as UTSJSONObject
orderId.value = optObj.getString('orderId') ?? ''
@@ -310,14 +310,16 @@ const formatTime = (timeStr?: string): string => {
return `${year}-${month}-${day}`
}
const getSpecText = (specs: any | null): string => {
const getSpecText = (specs: UTSJSONObject | string | null): string => {
if (specs == null) return ''
if (typeof specs === 'string') return specs as string
try {
const specObj = JSON.parse(JSON.stringify(specs)) as UTSJSONObject
const jsonStr = JSON.stringify(specObj)
const jsonStr = JSON.stringify(specs)
if (jsonStr == '{}' || jsonStr == 'null') return ''
if (jsonStr.startsWith('"') && jsonStr.endsWith('"') && jsonStr.length >= 2) {
return jsonStr.substring(1, jsonStr.length - 1)
}
// 简单解析:直接返回 JSON 字符串(去除大括号)
const cleanStr = jsonStr.replace(/^\{|\}$/g, '').replace(/"/g, '').replace(/:/g, ': ').replace(/,/g, '; ')
@@ -359,12 +361,8 @@ const setMerchantRating = (type: string, rating: number) => {
}
// 切换匿名
const toggleAnonymous = (event: any) => {
const eventObj = event as UTSJSONObject
const detailRaw = eventObj.get('detail')
const detail = detailRaw != null ? (detailRaw as UTSJSONObject) : (new UTSJSONObject())
const valueRaw = detail.get('value')
anonymous.value = valueRaw != null ? (valueRaw as boolean) : false
const toggleAnonymous = (event: UniSwitchChangeEvent) => {
anonymous.value = event.detail.value as boolean
}
// 上传图片