修复bug

This commit is contained in:
2026-04-14 17:45:41 +08:00
parent d2077f5844
commit a89610c245
12 changed files with 454 additions and 125 deletions
+36 -51
View File
@@ -20,6 +20,16 @@ import dayjs from 'dayjs'
import useEventEmit from "@/hooks/useEventEmit";
const configStore = useConfigStore();
function fillI18nParams(template: string, params: Record<string, string | number>) {
let text = template
Object.keys(params).forEach((key) => {
const value = String(params[key] ?? '')
text = text.replace(new RegExp(`\\{${key}\\}`, 'g'), value)
text = text.replace(new RegExp(`\\$\\{${key}\\}`, 'g'), value)
})
return text
}
// 价格明细
const priceDetailRef = ref<InstanceType<typeof PriceDetail>>();
// 打开价格明细
@@ -128,6 +138,12 @@ const orderTotalItemCount = computed(() => {
return orderDishList.value.reduce((sum, item) => sum + (Number(item?.count) || 0), 0)
})
const orderTotalItemCountText = computed(() => {
return fillI18nParams(t('pages.order.totalItemCount'), {
count: orderTotalItemCount.value,
})
})
const orderTotalPrice = computed(() => {
const n = orderDetail.value?.paidAmount ?? orderDetail.value?.actualPrice ?? 0
return Number(n).toFixed(2)
@@ -292,55 +308,24 @@ const orderNavSecondaryLine = computed(() => {
const voucherChooseRef = ref<InstanceType<typeof ChooseImage>>()
const voucherSubmitting = ref(false)
// function openUploadVoucher() {
// voucherChooseRef.value?.init()
// }
function openUploadVoucher() {
voucherChooseRef.value?.init()
}
// function normalizeVoucherUrl(payload: unknown): string {
// if (Array.isArray(payload)) {
// const first = payload[0]
// return typeof first === 'string' ? first : ''
// }
// return typeof payload === 'string' ? payload : ''
// }
function normalizeVoucherUrl(payload: unknown): string {
if (Array.isArray(payload)) {
const first = payload[0]
return typeof first === 'string' ? first : ''
}
return typeof payload === 'string' ? payload : ''
}
// async function onVoucherImageUploaded(urls: unknown) {
// const zipPayVoucher = normalizeVoucherUrl(urls)
// if (!zipPayVoucher) {
// uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
// return
// }
// const id = orderDetail.value?.id
// if (id == null || String(id).trim() === '') {
// uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
// return
// }
// if (voucherSubmitting.value) return
// voucherSubmitting.value = true
// try {
// await appMerchantOrderZipPayVoucherPost({
// body: {
// orderId: Number(id),
// zipPayVoucher,
// },
// options: { hideErrorToast: true },
// })
// uni.showToast({ title: t('pages-store.order.voucherSubmitSuccess'), icon: 'none' })
// setTimeout(() => {
// appMerchantOrderDetail()
// }, 500)
// }
// catch {
// uni.showToast({ title: t('pages-store.order.voucherSubmitFailed'), icon: 'none' })
// }
// finally {
// voucherSubmitting.value = false
// }
// }
const FIXED_VOUCHER_URL = 'https://www.howhowfresh.com/prod-api/resource/oss/download/2037827804362121218'
async function openUploadVoucher() {
async function onVoucherImageUploaded(urls: unknown) {
const zipPayVoucher = normalizeVoucherUrl(urls)
if (!zipPayVoucher) {
uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
return
}
const id = orderDetail.value?.id
if (id == null || String(id).trim() === '') {
uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
@@ -352,7 +337,7 @@ async function openUploadVoucher() {
await appMerchantOrderZipPayVoucherPost({
body: {
orderId: id,
zipPayVoucher: FIXED_VOUCHER_URL,
zipPayVoucher,
},
options: { hideErrorToast: true },
})
@@ -575,7 +560,7 @@ async function openUploadVoucher() {
<view class="goods-price-right">
<text class="goods-price">${{ orderTotalPrice }}</text>
<text class="goods-count">
{{ t('pages.order.totalItemCount', { count: orderTotalItemCount }) }}
{{ orderTotalItemCountText }}
</text>
</view>
</view>
@@ -856,8 +841,8 @@ async function openUploadVoucher() {
<password-container @success="payPawSuccess" ref="passwordInputRef" />
<!-- 核销订单 -->
<use-code ref="useCodeRef" />
<!-- 支付凭证:相册/拍照(暂时不使用文件上传,改用固定URL -->
<choose-image ref="voucherChooseRef" :count="1" />
<!-- 支付凭证:相册/拍照,上传后回调真实 URL -->
<choose-image ref="voucherChooseRef" :count="1" @change="onVoucherImageUploaded" />
</view>
</view>
</template>