完成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

@@ -1,7 +1,7 @@
<!-- 消费者端 - 订单详情页 -->
<!-- 消费者端 - 订单详情页 -->
<template>
<view class="order-detail-page">
<scroll-view scroll-y="true" class="scroll-content">
<scroll-view direction="vertical" class="scroll-content">
<!-- 订单状态 -->
<view class="order-status" :class="getStatusClass()">
<view class="status-content">
@@ -65,7 +65,7 @@
<text class="arrow-right"></text>
</view>
<view v-for="item in orderItems" :key="item.id" class="product-item" @click="goToProduct(item.product_id)">
<image :src="item.image_url != null && item.image_url != '' ? item.image_url : '/static/default-product.png'" class="product-image" mode="aspectFill"/>
<image :src="item.image_url != null && item.image_url != '' ? item.image_url : '/static/images/default.png'" class="product-image" mode="aspectFill"/>
<view class="product-info">
<text class="product-name">{{ item.product_name }}</text>
<text v-if="item.specifications" class="product-spec">{{ getSpecText(item.specifications) }}</text>
@@ -170,6 +170,7 @@
import { ref, onMounted, computed } from 'vue'
import { onLoad, onBackPress } from '@dcloudio/uni-app'
import { supabaseService } from '@/utils/supabaseService.uts'
import { goToLogin } from '@/utils/utils.uts'
import supa from '@/components/supadb/aksupainstance.uts'
// 定义订单类型
@@ -342,7 +343,9 @@ const copyText = (text: string) => {
if(text == '') return
uni.setClipboardData({
data: text,
success: () => uni.showToast({ title: '已复制' })
success: () => {
uni.showToast({ title: '已复制' })
}
})
}
@@ -480,6 +483,11 @@ const loadOrderDetail = async () => {
// 动作函数
const contactService = () => {
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
goToLogin(`/pages/mall/consumer/order-detail?orderId=${orderId.value}`)
return
}
if (order.value != null && order.value?.merchant_id != '') {
// 跳转到商家的聊天窗口
uni.navigateTo({
@@ -502,6 +510,11 @@ const contactService = () => {
const payOrder = () => {
const totalAmount = order.value?.total_amount ?? 0
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
goToLogin(`/pages/mall/consumer/payment?orderId=${orderId.value}&amount=${totalAmount}`)
return
}
uni.navigateTo({
url: `/pages/mall/consumer/payment?orderId=${orderId.value}&amount=${totalAmount}`
})
@@ -606,6 +619,11 @@ const confirmReceive = () => {
}
const rePurchase = async () => {
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
goToLogin(`/pages/mall/consumer/order-detail?orderId=${orderId.value}`)
return
}
uni.showLoading({ title: '处理中' })
try {
const items = orderItems.value
@@ -645,6 +663,11 @@ const rePurchase = async () => {
}
const doApplyRefund = async (reason: string) => {
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
goToLogin(`/pages/mall/consumer/order-detail?orderId=${orderId.value}`)
return
}
try {
const success = await supabaseService.applyRefund(orderId.value, reason)
if (success) {
@@ -662,6 +685,11 @@ const doApplyRefund = async (reason: string) => {
}
const applyRefund = () => {
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
goToLogin(`/pages/mall/consumer/order-detail?orderId=${orderId.value}`)
return
}
uni.showModal({
title: '申请退款',
editable: true,
@@ -760,13 +788,15 @@ onBackPress((_): boolean => {
// 生命周期 - 在所有函数定义之后
onLoad((options) => {
const id = options['id']
const orderIdParam = options['orderId']
if (id != null && id != '') {
orderId.value = id as string
if (options == null) return
const optionsObj = (options instanceof UTSJSONObject) ? (options as UTSJSONObject) : (JSON.parse(JSON.stringify(options ?? {})) as UTSJSONObject)
const id = optionsObj.getString('id') ?? ''
const orderIdParam = optionsObj.getString('orderId') ?? ''
if (id != '') {
orderId.value = id
loadOrderDetail()
} else if (orderIdParam != null && orderIdParam != '') {
orderId.value = orderIdParam as string
} else if (orderIdParam != '') {
orderId.value = orderIdParam
loadOrderDetail()
}
})