Commit 1007be26 authored by wykolor's avatar wykolor

Merge branch 'feature/2021_03_12_bonus' of dev.jiuaoedu.com:wykolor/GeekBonusH5…

Merge branch 'feature/2021_03_12_bonus' of dev.jiuaoedu.com:wykolor/GeekBonusH5 into feature/2021_03_12_bonus
parents 29080f33 38fa81e4
......@@ -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 });
});
}
......@@ -119,12 +119,12 @@ function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }):
* 微信登录
*/
export function bindWeChat() {
return invokeNativeMethod<{ code: string }>({ type: "bindWeChat" });
return invokeNativeMethod<{ code: string; userId: string }>({ type: "bindWechat" });
}
/**
* 打电话
*/
export function makecall(phone: string) {
export function makeCall(phone: string) {
return invokeNativeMethod<null, string>({ type: "makecall", data: phone });
}
......@@ -172,7 +172,7 @@ import { Dialog, Button, Col, Row, Cell, List, Loading } from "vant";
import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api";
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant";
import { bindWeChat, useNativeBridge } from "@/util/use-native-bridge";
import { bindWeChat, useNativeBridge, makeCall } from "@/util/use-native-bridge";
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt";
interface BonusState {
......@@ -253,10 +253,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 bindWeiChat = () => {
state.binding = true;
......
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