Commit 00d4ebd8 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 64d7469d ab937710
...@@ -17,7 +17,7 @@ const isAndroid = () => { ...@@ -17,7 +17,7 @@ const isAndroid = () => {
return android; return android;
}; };
window.$geek_excuteJS = function(args) { window.$geek_excuteJS = function (args) {
try { try {
const params = JSON.parse(args); const params = JSON.parse(args);
eventBus.emit<NativeInvokeFuncParams>(GEEK_NATVIE_NAME, params); eventBus.emit<NativeInvokeFuncParams>(GEEK_NATVIE_NAME, params);
...@@ -37,11 +37,11 @@ const sendNativeMessage = (data: { type: string; data: any }) => { ...@@ -37,11 +37,11 @@ const sendNativeMessage = (data: { type: string; data: any }) => {
window.ReactNativeWebView.postMessage(JSON.stringify(data)); window.ReactNativeWebView.postMessage(JSON.stringify(data));
}; };
function useNativeBridage( function useNativeBridge(
eventType: string, eventType: string,
listener: (this: ComponentInternalInstance | null, ...arg: any[]) => any listener: (this: ComponentInternalInstance | null, ...arg: any[]) => any
): [typeof sendNativeMessage, typeof eventBus] { ): [typeof sendNativeMessage, typeof eventBus] {
const _listener = function(this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) { const _listener = function (this: ComponentInternalInstance | null, arg?: NativeInvokeFuncParams) {
if (!arg) return; if (!arg) return;
if (eventType === arg.method) { if (eventType === arg.method) {
listener.apply(this, [arg.data]); listener.apply(this, [arg.data]);
...@@ -66,4 +66,4 @@ function useNativeBridage( ...@@ -66,4 +66,4 @@ function useNativeBridage(
return [sendNativeMessage, eventBus]; return [sendNativeMessage, eventBus];
} }
export { useNativeBridage }; export { useNativeBridge };
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref } from "vue";
import { useNativeBridage } from "@/util/use-native-bridage"; import { useNativeBridge } from "@/util/use-native-bridge";
const [sendNativeMessage, eventBus] = useNativeBridage("bindWechatChange", function(arg) { const [sendNativeMessage, eventBus] = useNativeBridge("bindWechatChange", function(arg) {
console.log(this, arg); console.log(this, arg);
}); });
const count = ref(1000); const count = ref(1000);
......
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