You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//跳转app方法
export function useAppBridge() { const fullClose = (n, m) => { let result = Math.random() * (m + 1 - n) + n while (result > m) { result = Math.random() * (m + 1 - n) + n } return Math.floor(result) }
const packageFun = (funName, fun = () => {}, platform, data = {}) => { const JWrandom = fullClose(10000, 99999) data.JWrandom = JWrandom
window[funName + JWrandom] = fun
try { const params = { name: funName, extra: { data } }
switch (platform) { case 2: // app apicloud
window.api.sendEvent(params) break case 3: // app ios
window.webkit.messageHandlers.getTouJiaoData.postMessage(JSON.stringify(params)) break case 4: // app android
window.android.getTouJiaoData(JSON.stringify(params)) break case 5: // app uniapp
window.uni.postMessage({ data: { val: JSON.stringify(params) } }) break } } catch (e) { console.error('Error in packageFun:', e) } }
return { packageFun, fullClose } }
|