Commit c1ae52ec authored by hewenhao's avatar hewenhao

feat: callback name

parent e7253e60
......@@ -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()) {
window.ReactNativeWebView &&
window.ReactNativeWebView.onMessage &&
......@@ -90,7 +90,7 @@ const INVOKE_NATIVE_METHOD_TIMEOUT = 10000;
function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }): Promise<T> {
return new Promise((resolve, reject) => {
const callbackName = `${arg.type}_callback`;
const callbackName = `${arg.type}_callback_${Math.random()}`.replace(/\./, "");
const timer = setTimeout(() => {
reject(new Error(`invoke ${arg.type} timeout`));
......@@ -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";
import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api";
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";
interface BonusState {
......@@ -244,10 +244,11 @@ const Bonus = defineComponent({
state.showWithdrawRules = true;
};
const phoneCall = () => {
sendNativeMessage({
type: "phoneCall",
data: "400—8777389"
});
makecall('400—8777389')
// sendNativeMessage({
// type: "phoneCall",
// data: "400—8777389"
// });
};
const bindWeChat = () => {
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