本文总结两种跳转方法:!!!适合自己的才是最好的 1、根据微信开放文档提供的方法获取小程序的URL (两种) ! 小程序的URL Scheme weixin://dl/business/?t= *TICKET*
本文总结两种跳转方法:!!!适合自己的才是最好的
! 小程序的URL Scheme
weixin://dl/business/?t= *TICKET*
!! 小程序的URL Link
https://wxaurl.cn/*TICKET* 或 Https://wxmpurl.cn/*TICKET*
methods: {getUniappURL() {let params = {// path:要跳转到的小程序的目标页面纯路径(不要拼接参数)// 注意:如果该链接要打开的版本是正式版,则这个path一定要已经发布到了正式版,不然无法访问到该页面则链接无法生成成功path: '/pages/index/insex',query: 'a=1&b=2', // 短链的入参env_version: "release", // 正式版expire_type: 1,expire_interval: 30,}this.getAppLink(params)},getAppLink(params) {// AppID(小程序ID)const appid = 'wx******cf'// AppSecret(小程序密钥)const secret = 'afe3D06*******975dcbe4'let tokenURL = ''let urllink = ''// #ifdef APPtokenURL = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${secret}`// #endif// 先发起请求获取凭证2小时内有效uni.request({url: tokenURL,method: 'GET',success(res) {// #ifdef APPurllink = `https://api.weixin.qq.com/wxa/generate_urllink?access_token=${res.data.access_token}`//获取 URL Link //urllink = `https://api.weixin.qq.com/wxa/generatescheme?access_token=${res.data.access_token}`//获取 URL Scheme// #endif// 再发起请求获取urluni.request({url: urllink,method: 'POST',data: {...params},success(result) {console.log('生成网址:', result.data.url_link);// #ifdef APP //通过uniapp内置组件WEB-view跳转该链接uni.navigateTo({ url: `/pages/webView/webView?url=${result.data.url_link}`,});// #endif},fail(err) {console.log(err);}})},fail(err) {console.log(err);}})},}
以上可以拿到小程序的两种URL 链接
!!!打包App时需要在manifest.JSON中APP模块配置Share中微信分享保持开启
!!!打包App时需要在manifest.json中APP模块配置Share中微信分享保持开启
!!!打包App时需要在manifest.json中APP模块配置Share中微信分享保持开启
$appJumpMiniPro(url)方法: !!!记得在main.js上挂载 否则无效~
Vue.prototype.$appJumpMiniPro = function(url) {// 获取分享服务列表plus.share.getServices(res => {let sweixin = '';for (var i = 0; i < res.length; i++) {let t = res[i];if (t.id == 'weixin') {sweixin = t;}}if (sweixin) {sweixin.launchMiniProgram({id: 'gh_****ab42', // 要跳转小程序的原始IDpath: url, // 可带参数type: 2 // 微信小程序版本类型可取值: 0-正式版; 1-测试版; 2-体验版。 默认值为0。},// 目标小程序点击返回App后执行的回调,在此接收微信小程序传递的参数res2 => {console.log(typeof res2, res2)// res2是微信小程序传递回来的参数 类型为string 需转化为js对象使用let result = JSON.parse(res2)console.log(result)// 拿到参数后执行你需要的逻辑},err2 => {console.log(err2)});} else { // 没有获取到微信分享服务uni.showToast({icon: 'none',title: '当前环境不支持微信操作!'})}},err => { // 获取分享服务列表失败console.log(err)})}
到此结束~以上是App跳转微信小程序的两种方法,适合自己的才是最好的
来源地址:https://blog.csdn.net/2201_75870706/article/details/132058988
--结束END--
本文标题: uniapp开发的App(安卓)端跳转uniapp微信小程序
本文链接: https://www.lsjlt.com/news/423006.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0