s***@163.com
s***@163.com
  • 发布:2023-03-03 15:59
  • 更新:2023-03-03 16:55
  • 阅读:478

h5通过wx-open-launch-weapp标签无法跳转小程序

分类:uni-app

<wx-open-launch-weapp
id="launch-btn"
appid="wx0a5fb4923614e532"
username="gh_bd7186f7273b"
path="pages/tabbar/home/home.html"

<script type="text/wxtag-template">
<style>.btn {
width: 335px;
height: 45px;
line-height: 45px;
background: #707AFF;
border-radius: 22.5px;
margin-top: 40px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
}</style>
<button class="btn">点击打开微信小程序</button>
</script>
</wx-open-launch-weapp>
<button @click="handleOpenApplet">点击打开微信小程序</button>

handleOpenApplet(){
// window.location.href = 'https://sourl.cn/s7ri77'
const urlEncoded = encodeURIComponent(window.location.href);
getSharingSign(urlEncoded).then((res)=>{
console.log(res, '返回的参数')
const { code, data:{appId,timestamp,nonceStr,signature} } = res;
if(code == 200){
const wx = this.wx;
wx.config({
debug: true,
appId: appId,
timestamp: timestamp,
nonceStr: nonceStr,
signature: signature,
jsApiList: ['onMenuShareTimeline'], // 必填,需要使用的 JS 接口列表
openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
});
var btn = document.getElementById('launch-btn');
btn.addEventListener('ready', function (e) {
console.log('ready');
});
btn.addEventListener('launch', function (e) {
console.log('sssssss');
});
wx.ready(function(){
console.log('成功')
})
wx.error(function(res){
console.log(res,'dsadsadsadsad')
})
}
})
}

wx.ready打印出来了,但是wx.error也打印出来了报错config:invalid signature 有知道怎么解决的大佬吗

2023-03-03 15:59 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

要回复问题请先登录注册