fix:修复bug

This commit is contained in:
2026-03-17 12:03:54 +08:00
parent 5d7b973ddd
commit 60df817de5
32 changed files with 654 additions and 528 deletions
+47 -24
View File
@@ -1,25 +1,57 @@
<script setup lang="ts">
import {appCouponExchangeCouponPost, appCouponUserCouponListPost} from "@/service";
const { t } = useI18n();
const { t, locale } = useI18n();
import { throttle } from "throttle-debounce";
import Config from "@/config";
import {dayjs} from "@/plugin";
function getList(pageNum: number, pageSize: number) {
return new Promise(resolve => {
appCouponUserCouponListPost({
params: {
pageNum,
pageSize,
}
}).then(res => {
resolve(res)
})
})
function isEnLocale() {
return String(locale.value || '').toLowerCase().startsWith('en')
}
const {paging, loading, firstLoaded, dataList, queryList} = usePage(getList)
function formatMoney(value: unknown) {
const n = Number(value)
if (!Number.isFinite(n)) return '0.00'
return n.toFixed(2)
}
function formatCouponDetail(item: any) {
const type = Number(item?.snapshotType)
const discount = Number(item?.snapshotDiscount)
const minAmount = Number(item?.snapshotMinAmount)
// 1-折扣券(percentage), 2-满减券(amount off with minimum spend)
if (type === 2) {
const hasMin = Number.isFinite(minAmount) && minAmount > 0
const discountText = `$${formatMoney(discount)}`
if (hasMin) {
const minText = `$${formatMoney(minAmount)}`
return isEnLocale()
? `Min ${minText} · Off ${discountText}`
: `${minText}${discountText}`
}
return isEnLocale() ? `Off ${discountText}` : `立减${discountText}`
}
if (type === 1) {
const pct = Number.isFinite(discount) ? Number(discount * 100).toFixed(0) : '0'
return `${pct}% ${t('pages-store.store.discount')}`
}
return t('pages-store.store.discount')
}
function getList(pageNum: number, pageSize: number) {
return appCouponUserCouponListPost({
params: {
pageNum,
pageSize,
}
}) as any
}
const {paging, loading, firstLoaded, dataList, queryList} = usePage<any>(getList)
const keyword = ref<string>("");
@@ -120,23 +152,14 @@ function handleSubmit() {
{{ item.snapshotMerchantId ? t('pages-user.coupon.merchant-specific') : t('pages-user.coupon.all-merchants') }}
</view>
<view class="text-24rpx lh-32rpx text-#999 my-18rpx">
{{ t('pages-user.coupon.expiry-date') }}{{ dayjs(Number(item.snapshotValidEnd))
.format('MM:DD HH:mm:ss') }}
{{ dayjs(Number(item.snapshotValidEnd)).format('YYYY-MM-DD HH:mm') }}{{ isEnLocale() ? ' expires' : '到期' }}
</view>
<view class="text-28rpx lh-28rpx text-#333 flex items-center">
<image
class="w-36rpx h-36rpx shrink-0 mr-10rpx"
src="@img/chef/106.png"
></image>
<template v-if="item.snapshotType === 2">
<!-- 满减-->
{{ item.snapshotDiscount }}
</template>
<template v-else>
{{ Number(item.snapshotDiscount * 100).toFixed(0) }}%
</template>
{{ t('pages-store.store.discount') }}
{{ formatCouponDetail(item) }}
</view>
</view>
<view class="h-84rpx lh-84rpx text-center text-28rpx text-#fff">