修复bug
This commit is contained in:
@@ -80,6 +80,9 @@
|
||||
<text class="amount-large">{{ totalAmount }}</text>
|
||||
<text class="pay-text">{{ $t('payment.payNow') }}</text>
|
||||
</view>
|
||||
<view class="cancel-btn" @click="handleCancelOrder">
|
||||
{{ $t('order.cancelOrder') }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -96,6 +99,7 @@
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
queryById,
|
||||
cancelOrder,
|
||||
createWxPayment,
|
||||
getWxPaymentStatus,
|
||||
createAliPayment,
|
||||
@@ -113,6 +117,12 @@
|
||||
import {
|
||||
useI18n
|
||||
} from '@/utils/i18n.js'
|
||||
import {
|
||||
fetchAndCacheDanaPaymentConfig,
|
||||
DANA_TOTAL_STORAGE_KEY,
|
||||
DANA_SINGLE_STORAGE_KEY,
|
||||
parseDanaStorageNumber
|
||||
} from '@/utils/danaPaymentConfig.js'
|
||||
|
||||
const {
|
||||
t
|
||||
@@ -125,7 +135,23 @@
|
||||
const passedTotalAmount = ref(null)
|
||||
const passedDepositAmount = ref(null)
|
||||
const currencyCode = ref('USD')
|
||||
const IDR_DEPOSIT_DISPLAY = 99000
|
||||
const IDR_DEPOSIT_DISPLAY = ref(99000)
|
||||
const IDR_SINGLE_DISPLAY = ref(6000)
|
||||
|
||||
const loadDanaTotalCache = () => {
|
||||
try {
|
||||
const cachedTotal = parseDanaStorageNumber(uni.getStorageSync(DANA_TOTAL_STORAGE_KEY))
|
||||
const cachedSingle = parseDanaStorageNumber(uni.getStorageSync(DANA_SINGLE_STORAGE_KEY))
|
||||
if (cachedTotal !== null && cachedTotal > 0) {
|
||||
IDR_DEPOSIT_DISPLAY.value = cachedTotal
|
||||
}
|
||||
if (cachedSingle !== null && cachedSingle > 0) {
|
||||
IDR_SINGLE_DISPLAY.value = cachedSingle
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('读取 DANA 预支付缓存失败,使用默认值:', e)
|
||||
}
|
||||
}
|
||||
|
||||
// 支付方式相关(微信/支付宝/H5-Antom 多平台)
|
||||
const paymentMethods = ref([])
|
||||
@@ -152,7 +178,7 @@
|
||||
|
||||
const totalAmount = computed(() => {
|
||||
if (currencyCode.value === 'IDR') {
|
||||
return `${IDR_DEPOSIT_DISPLAY}`
|
||||
return `${IDR_DEPOSIT_DISPLAY.value}`
|
||||
}
|
||||
if (passedTotalAmount.value !== null) {
|
||||
return parseFloat(passedTotalAmount.value).toFixed(2);
|
||||
@@ -258,7 +284,7 @@
|
||||
orderInfo.value.deposit = deviceInfo.value.depositAmount;
|
||||
}
|
||||
if (currencyCode.value === 'IDR') {
|
||||
orderInfo.value.deposit = `${IDR_DEPOSIT_DISPLAY}`
|
||||
orderInfo.value.deposit = `${IDR_DEPOSIT_DISPLAY.value}`
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -509,6 +535,52 @@
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancelOrder = () => {
|
||||
if (!orderId.value) {
|
||||
uni.showToast({
|
||||
title: t('order.orderNotExist'),
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: t('order.confirmCancel'),
|
||||
content: t('order.confirmCancelContent'),
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return;
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: t('common.processing')
|
||||
});
|
||||
const result = await cancelOrder({
|
||||
orderId: orderId.value
|
||||
});
|
||||
if (result && result.code === 200) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: t('order.cancelSuccess'),
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 800);
|
||||
} else {
|
||||
throw new Error(result?.msg || t('order.cancelFailed'));
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: error.message || t('order.cancelFailed'),
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 轮询定时器
|
||||
let pollingTimer = null;
|
||||
|
||||
@@ -641,6 +713,10 @@
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
loadDanaTotalCache()
|
||||
void fetchAndCacheDanaPaymentConfig()
|
||||
.then(() => loadDanaTotalCache())
|
||||
.catch((e) => console.warn('DANA 配置刷新失败:', e))
|
||||
// 设置导航栏标题为待支付
|
||||
uni.setNavigationBarTitle({
|
||||
title: t('payment.waitingForPayment')
|
||||
@@ -909,6 +985,25 @@
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
width: 100%;
|
||||
//height: 84rpx;
|
||||
margin-top: 16rpx;
|
||||
//border-radius: 42rpx;
|
||||
//border: 2rpx solid #d9d9d9;
|
||||
//background: #fff;
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user