Comparing version
@@ -262,5 +262,113 @@ (function (global, factory) { | ||
/** | ||
* 打开原生页面 | ||
*/ | ||
function bridgeToNativePage(agrs) { | ||
const { ios_url, android_url, miniProgram_url, jump_url } = agrs || {}; | ||
if (platform.isIOS) { | ||
if (window.webkit && window.webkit.messageHandlers) { | ||
window.webkit.messageHandlers.iOSOpenNativePageEvent.postMessage(ios_url); | ||
} | ||
return | ||
} | ||
if (platform.isAndroid) { | ||
uni.postMessage({ | ||
data: { | ||
action: 'openNativePage', | ||
data: { | ||
url: android_url, | ||
}, | ||
}, | ||
}); | ||
} | ||
if (platform.isMiniprogram) { | ||
wx.miniProgram.navigateTo({ | ||
url: miniProgram_url, | ||
}); | ||
} | ||
if (jump_url) { | ||
location.href = jump_url; | ||
} | ||
} | ||
/** | ||
* 打开广告位跳转 | ||
*/ | ||
function bridgeToAdvertPage(data) { | ||
const { ios_url, android_url, mini_type, mini_program_page, jump_type, jump_url } = data; | ||
if (platform.isIOS) { | ||
if (window.webkit && window.webkit.messageHandlers) { | ||
window.webkit.messageHandlers.iOSJumpNativePageEvent.postMessage({ ...data }); | ||
} | ||
return | ||
} | ||
if (platform.isAndroid) { | ||
uni.postMessage({ | ||
data: { | ||
action: 'jumpAd', | ||
data, | ||
}, | ||
}); | ||
return | ||
} | ||
if (platform.isMiniprogram) { | ||
wx.miniProgram.redirectTo({ | ||
url: mini_type === 1 ? mini_program_page : android_url, | ||
}); | ||
return | ||
} | ||
location.href = jump_url; | ||
} | ||
/** | ||
* 分享 | ||
*/ | ||
function bridgeToShare(data) { | ||
if (platform.isIOS) { | ||
if (window.webkit && window.webkit.messageHandlers) { | ||
window.webkit.messageHandlers.iOSShareWeChatFriendOrCircle.postMessage({ | ||
title: data.title, | ||
content: data.desc, | ||
link: data.link, | ||
image: data.imgUrl, | ||
type: data.type, | ||
}); | ||
} | ||
return | ||
} | ||
if (platform.isAndroid) { | ||
uni.postMessage({ | ||
data: { | ||
action: 'toShare', | ||
data: { | ||
title: data.title, | ||
content: data.desc, | ||
link: data.link, | ||
image: data.imgUrl, | ||
type: data.type, | ||
}, | ||
}, | ||
}); | ||
} | ||
if (platform.isWechat) { | ||
console.log(this); | ||
} | ||
} | ||
var jbridge = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
bridgeToLogin: bridgeToLogin | ||
bridgeToAdvertPage: bridgeToAdvertPage, | ||
bridgeToLogin: bridgeToLogin, | ||
bridgeToNativePage: bridgeToNativePage, | ||
bridgeToShare: bridgeToShare | ||
}); | ||
@@ -267,0 +375,0 @@ |
{ | ||
"name": "xfb-sdk", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"author": "wangfei", | ||
@@ -5,0 +5,0 @@ "description": "", |
10956
28.89%338
39.09%