Commit eda7d6f2 authored by zengqiang's avatar zengqiang

Merge branch 'feature/2026-05-08-wechat-transfer' into 'test'

Feature/2026 05 08 wechat transfer See merge request wykolor/mall-webview!14
parents b258ad08 890c4c1a
......@@ -87,20 +87,25 @@ export { useNativeBridge }
const INVOKE_NATIVE_METHOD_TIMEOUT = 10000
function invokeNativeMethod<T = any, P = any> (arg: { type: string; data?: P }): Promise<T> {
function invokeNativeMethod<T = any, P = any> (arg: { type: string; data?: P }, timeout = INVOKE_NATIVE_METHOD_TIMEOUT): Promise<T> {
return new Promise((resolve, reject) => {
const callbackName = `${arg.type}_callback_${Math.random()}`.replace(/\./, '')
const timer = setTimeout(() => {
reject(new Error(`invoke ${arg.type} timeout`))
eventBus.off(GEEK_NATIVE_NAME, onCallback)
}, INVOKE_NATIVE_METHOD_TIMEOUT)
let timer: ReturnType<typeof setTimeout> | null = null
// 如果 timeout 大于 0,则设置一个定时器,如果超时则拒绝请求
if (timeout > 0) {
timer = setTimeout(() => {
reject(new Error(`invoke ${arg.type} timeout`))
eventBus.off(GEEK_NATIVE_NAME, onCallback)
}, timeout)
}
eventBus.on(GEEK_NATIVE_NAME, onCallback)
function onCallback (params?: NativeInvokeFuncParams) {
if (params?.method === callbackName) {
clearTimeout(timer)
if (timer) {
clearTimeout(timer)
}
if (params.error) {
reject(new Error(params.error))
} else {
......@@ -165,5 +170,5 @@ export interface WechatOpenBusinessViewResp extends WechatBaseResp {
}
export function requestMerchantTransfer (params: RequestMerchantTransferParams) {
return invokeNativeMethod<WechatOpenBusinessViewResp, RequestMerchantTransferParams>({ type: 'requestMerchantTransfer', data: params })
return invokeNativeMethod<WechatOpenBusinessViewResp, RequestMerchantTransferParams>({ type: 'requestMerchantTransfer', data: params }, -1)
}
......@@ -6,10 +6,6 @@
</div>
<template v-else>
<div class="upgrade-tip" v-if="showAppIdMismatchTip">
该提现需在微信小程序中确认收款,请前往微信小程序操作。
</div>
<div class="confirm-icon">💰</div>
<div class="confirm-title">提现申请已提交</div>
<div class="confirm-amount">¥{{ amount }}</div>
......@@ -21,7 +17,7 @@
<p class="timeout-hint">⏰ 请在24小时内确认,超时将自动退回</p>
</div>
<button class="btn-confirm" :disabled="showAppIdMismatchTip" :class="{ disabled: showAppIdMismatchTip }" @click="handleConfirm">👆 确认收款</button>
<button class="btn-confirm" @click="handleConfirm">👆 确认收款</button>
<button class="btn-back" @click="handleBack">返回奖励金首页</button>
<div class="confirm-faq">
......@@ -47,9 +43,6 @@ export default defineComponent({
packageInfo: '',
mchId: '',
appId: '',
// H5 APP 的 appId 固定值
currentAppId: 'wxce3ddfea994471b9',
showAppIdMismatchTip: false,
loading: true
}
},
......@@ -64,7 +57,7 @@ export default defineComponent({
this.packageInfo = decodeURIComponent(query.packageInfo as string)
this.mchId = (query.mchId as string) || ''
this.appId = (query.appId as string) || ''
this.checkAppIdMismatch()
this.loading = false
} else if (this.withdrawNo) {
// 场景2:从列表页进入,需要查询 packageInfo
await this.fetchPackageInfo()
......@@ -73,13 +66,6 @@ export default defineComponent({
}
},
methods: {
checkAppIdMismatch () {
// 检查 appId 是否与当前平台一致(暂时禁用,保留代码用于测试)
// if (this.appId && this.appId !== this.currentAppId) {
// this.showAppIdMismatchTip = true
// }
this.loading = false
},
async fetchPackageInfo () {
try {
console.log('fetchPackageInfo called, withdrawNo:', this.withdrawNo)
......@@ -90,23 +76,18 @@ export default defineComponent({
this.mchId = res.mchId || ''
this.appId = res.appId || ''
console.log('packageInfo:', this.packageInfo, 'mchId:', this.mchId, 'appId:', this.appId)
this.checkAppIdMismatch()
} else {
console.log('no data in response')
alert('获取提现信息失败')
this.loading = false
}
} catch (error) {
console.error('fetchPackageInfo error:', error)
alert('网络请求失败: ' + error)
} finally {
this.loading = false
}
},
async handleConfirm () {
if (this.showAppIdMismatchTip) {
return
}
if (!this.packageInfo || !this.mchId || !this.appId) {
console.error('Missing params:', { packageInfo: this.packageInfo, mchId: this.mchId, appId: this.appId })
alert('缺少必要参数,无法确认收款')
......@@ -163,18 +144,6 @@ export default defineComponent({
font-size: 4vw;
}
.upgrade-tip {
width: 100%;
background: #fff3e0;
color: #fa8c16;
padding: 3vw 4vw;
border-radius: 2vw;
font-size: 3.2vw;
text-align: left;
margin-bottom: 4vw;
box-sizing: border-box;
}
.confirm-icon {
font-size: 10vw;
margin-bottom: 4vw;
......@@ -238,11 +207,6 @@ export default defineComponent({
cursor: pointer;
}
.btn-confirm.disabled {
background: #ccc;
cursor: not-allowed;
}
.btn-back {
width: 100%;
padding: 3.5vw;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment