
<wx-open-launch-app id="launch-btn" :appid="common.launchAppId" :extinfo="id" style='position: fixed;bottom: 30px;left: 50%;width: 100vw;transform: translate(-50%);z-index: 999;'>
<script type="text/wxtag-template">
<style>
.openApp{
background: linear-gradient(103deg, #FF9A14 0%, #FF5410 100%);
border:none;
width:60%;
height:45px;
display:block;
color:#FFFFFF;
font-size: 14px !important;
letter-spacing: 1px;
border-radius: 328px;
margin: auto;
}
</style>
<button class="openApp"> App内打开 </button>
</script>
</wx-open-launch-app>
mounted() {
setTimeout(() => {
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', (e)=>{
console.log('success成功');
});
btn.addEventListener('error', (e) => {
console.log('fail', e.detail);
uni.showModal({
title: '系统消息',
content: '您的手机未找到当前应用,是否去下载?',
success: (res) => {
if (res.confirm) {
this.modalStatus = true
return
}else{
uni.showToast({
icon:'none',
title:'用户点击取消'
})
}
}
});
});
}, 1000)
},
wxjs() { let signLink = window.location.href.split("#")[0] || window.location.href; let data = { module: 'WechatShare', action: 'getSignPackage', prms: { url: signLink } } common.request(data, this.wxjsCb.bind(this)) }, wxjsCb(res) { if (res.code ==0) { appid = res.data.appId common.gzhAppId = appid wx.config({ debug: false, //测试时候用true 能看见wx.config的状态是否是config:ok appId: res.data.appId, // 必填,公众号的唯一标识(公众号的APPid) timestamp: res.data.timestamp, // 必填,生成签名的时间戳 nonceStr: res.data.nonceStr, // 必填,生成签名的随机串 signature: res.data.signature, // 必填,签名 jsApiList: ['onMenuShareTimeline','chooseWXPay'], // 必填,随意一个接口即可 openTagList: ['wx-open-launch-app'], }); wx.ready((e) => { // alert('wxsdk加载完成') console.log('初始化完成', e) }) wx.error((res) => { console.log('初始化错误', res); }) } }