行业知识
H5跳小程序的三种方法
2026-11-09 12:54:09
来源:互联网转载
1、H5页面嵌入到小程序中,H5跳本小程序其他页面
wx.miniProgram.navigateTo({ url: '/pages/product/details?from=智能客服微信小程序&uits_source=智能客服微信小程序&productCode='+ code +'&uits_s01=28&uits_s02=XCX&uits_s03=buy' }) 2、H5页面在服务号内直接跳转其他小程序
需要调用微信jssdk中的方法
$.ajax({ //jssdk后台签名接口,需要后台提供 url: '/weixinsignature/getWXJWeiXinSignature?url=' + encodeURIComponent(location.href.split('#')[0]) + '&sysNum=' + sysNum + '&wxcId=' + wxcId, type: 'get', success: function (data) { wx.config({ appId: data.appid, timestamp: data.timestamp, nonceStr: data.nonceStr, signature: data.signature, jsApiList: ['startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'translateVoice', 'uploadVoice', 'chooseImage', 'uploadImage'], openTagList: ['wx-open-launch-weapp'] }) ready() } }) '+ data +'
3、H5页面嵌入到小程序中,H5跳其他小程序页面
此种不支持直接跳转其他小程序,需要先跳转到本小程序的一个空页面,然后在当前这个空页面的onload方法里面跳转其他第三方小程序
H5页面:
wx.miniProgram.redirectTo({ url: '/pages/xiaoJi/xiaoJi?productCode='+ code +'&url=' + encodeURIComponent(JSON.stringify(location.href))}) 小程序空页面:
onLoad(options) { this.navigateToWxc(options)},methods:{ navigateToWxc: function(options){ this.url = JSON.parse(decodeURIComponent(options.url)) let programPath; if(options.productCode.indexOf("600") > -1){ programPath = 'pages/global/detail' }else{ programPath = 'pages/product/details' } programPath += '?from=智能客服微信小程序&uits_source=智能客服微信小程序' + '&productCode=' + options.productCode + '&uits_s01=28&uits_s02=XCX&uits_s03=buy' wx.showModal({ title: '提示', content: '是否允许跳转第三方小程序?', success (res) { if (res.confirm) { wx.navigateToMiniProgram({ appId: programAppId, path: programPath, success(res) { console.log(res) }, fail(err) { console.log(err) } }) } else if (res.cancel) { console.log('用户点击取消') } } }) }}
上一篇:服务器怎么制作副本任务?
下一篇:hp服务器bios怎么进?