完善下单逻辑及其ui展示,修复支付倒计时显示错误bug
This commit is contained in:
@@ -28,6 +28,27 @@ const orderId = ref('')
|
||||
const orderNo = ref('')
|
||||
const amount = ref(0)
|
||||
|
||||
const getOptionString = (options: UTSJSONObject, key: string): string => {
|
||||
try {
|
||||
const value = options.getString(key)
|
||||
if (value != null) {
|
||||
return value
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
try {
|
||||
const normalized = JSON.parse(JSON.stringify(options)) as UTSJSONObject
|
||||
const value = normalized.getString(key)
|
||||
if (value != null) {
|
||||
return value
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
// 定义 loadOrderInfo 函数(必须在 onMounted 之前)
|
||||
const loadOrderInfo = async () => {
|
||||
try {
|
||||
@@ -60,12 +81,12 @@ onLoad((options) => {
|
||||
if (options == null) return
|
||||
|
||||
const optionsObj = options as UTSJSONObject
|
||||
const orderIdValue = optionsObj.getString('orderId') ?? ''
|
||||
const orderIdValue = getOptionString(optionsObj, 'orderId')
|
||||
if (orderIdValue != '') {
|
||||
orderId.value = orderIdValue
|
||||
orderNo.value = orderIdValue
|
||||
|
||||
const amountValue = optionsObj.getString('amount') ?? ''
|
||||
const amountValue = getOptionString(optionsObj, 'amount')
|
||||
if (amountValue != '') {
|
||||
const amountStr = amountValue
|
||||
console.log('[payment-success] amountStr:', amountStr)
|
||||
|
||||
Reference in New Issue
Block a user