Commit c1ae52ec authored by hewenhao's avatar hewenhao

feat: callback name

parent e7253e60
...@@ -28,7 +28,7 @@ window.$geek_excuteJS = function(args) { ...@@ -28,7 +28,7 @@ window.$geek_excuteJS = function(args) {
} }
}; };
const sendNativeMessage = (data: { type: string; data?: any }) => { const sendNativeMessage = (data: { type: string; data?: any; __callback__?: string }) => {
if (isAndroid()) { if (isAndroid()) {
window.ReactNativeWebView && window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage && window.ReactNativeWebView.onMessage &&
...@@ -90,7 +90,7 @@ const INVOKE_NATIVE_METHOD_TIMEOUT = 10000; ...@@ -90,7 +90,7 @@ 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 }): Promise<T> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const callbackName = `${arg.type}_callback`; const callbackName = `${arg.type}_callback_${Math.random()}`.replace(/\./, "");
const timer = setTimeout(() => { const timer = setTimeout(() => {
reject(new Error(`invoke ${arg.type} timeout`)); reject(new Error(`invoke ${arg.type} timeout`));
...@@ -111,7 +111,7 @@ function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }): ...@@ -111,7 +111,7 @@ function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }):
} }
} }
sendNativeMessage(arg); sendNativeMessage({ ...arg, __callback__: callbackName });
}); });
} }
......
...@@ -169,7 +169,7 @@ import { Dialog, Button, Col, Row, Cell, List, Toast } from "vant"; ...@@ -169,7 +169,7 @@ import { Dialog, Button, Col, Row, Cell, List, Toast } from "vant";
import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus"; import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api"; import { bonusModel } from "@/server/api";
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant"; import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant";
import { useNativeBridge } from "@/util/use-native-bridge"; import { useNativeBridge, makecall } from "@/util/use-native-bridge";
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt"; import { formatBonusTipTxt } from "@/util/formatBonusTipTxt";
interface BonusState { interface BonusState {
...@@ -244,10 +244,11 @@ const Bonus = defineComponent({ ...@@ -244,10 +244,11 @@ const Bonus = defineComponent({
state.showWithdrawRules = true; state.showWithdrawRules = true;
}; };
const phoneCall = () => { const phoneCall = () => {
sendNativeMessage({ makecall('400—8777389')
type: "phoneCall", // sendNativeMessage({
data: "400—8777389" // type: "phoneCall",
}); // data: "400—8777389"
// });
}; };
const bindWeChat = () => { const bindWeChat = () => {
sendNativeMessage({ sendNativeMessage({
......
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