Commit 22918c9f authored by hewenhao's avatar hewenhao

refactor(native-bridge): 移除调试日志并优化微信转账功能

- 移除 $geek_excuteJS 函数中的调试日志,并添加错误处理时的日志记录 - 移除 onCallback 和 sendNativeMessage 中的调试日志 - 删除未使用的 WechatBaseResp 和 WechatOpenBusinessViewResp 接口 - 简化 requestMerchantTransfer 函数,移除不必要的 async/await 和日志 - 修改 requestMerchantTransfer 返回类型为 string,与实际实现保持一致
parent bddbf623
......@@ -20,10 +20,10 @@ const isAndroid = () => {
window.$geek_excuteJS = function (args: any) {
try {
console.log('$geek_excuteJS', args)
const params = JSON.parse(args)
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, params)
} catch (error) {
} catch (error: any) {
console.log('error in $geek_excuteJS', error.message, error.stack)
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATIVE_NAME, args)
}
}
......@@ -103,7 +103,6 @@ function invokeNativeMethod<T = any, P = any> (arg: { type: string; data?: P },
eventBus.on(GEEK_NATIVE_NAME, onCallback)
function onCallback (params?: NativeInvokeFuncParams) {
console.log('onCallback', params)
if (params?.method === callbackName) {
if (timer) {
clearTimeout(timer)
......@@ -117,8 +116,6 @@ function invokeNativeMethod<T = any, P = any> (arg: { type: string; data?: P },
}
}
console.log('sendNativeMessage', { ...arg, __callback__: callbackName })
sendNativeMessage({ ...arg, __callback__: callbackName })
})
}
......@@ -156,25 +153,6 @@ export interface RequestMerchantTransferParams {
package: string;
}
/** 微信各回调中常见的 errCode / errStr 结构 */
export interface WechatBaseResp {
errCode: number;
errStr?: string;
/** 其他字段因场景而异 */
[key: string]: unknown;
}
/** WXOpenBusinessView 回调(如商家转账确认) */
export interface WechatOpenBusinessViewResp extends WechatBaseResp {
type?: 'WXOpenBusinessView.Resp';
businessType?: string;
/** JSON 字符串,如 `{"result":"success"}`;result 可能为 success | fail | cancel */
extMsg?: string;
}
export async function requestMerchantTransfer (params: RequestMerchantTransferParams) {
const result = await invokeNativeMethod<WechatOpenBusinessViewResp, RequestMerchantTransferParams>({ type: 'requestMerchantTransfer', data: params }, -1)
console.log('requestMerchantTransfer result', result)
return result
export function requestMerchantTransfer (params: RequestMerchantTransferParams) {
return invokeNativeMethod<string, RequestMerchantTransferParams>({ type: 'requestMerchantTransfer', data: params }, -1)
}
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