原生H5界面,怎么点击确定能跳转微信小程序呢,该怎么写还要传值给后台
<div class="hktshare">
<div>客厅div>
div>
<div class="del_mask" id="hktshare_pop" style="display: none;">
<div class="del_block">
<div class="del_content">即将打开"微信"小程序div>
<div>
<div class="del_cancel" v-on:click="delhkt()">取消div>
<div class="del_sure" v-on:click="surehkt()">确定div>
div>
div>
div>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js">script>
$(".hktshare").click(function(){
$("#hktshare_pop").show();
})
.hktshare{
width: 2.2rem;
height: 2.2rem;
border-radius: 50%;
background-color: #029dff;
position: absolute;
right: 1.5rem;
top: 18rem;
z-index: 99999999999999;
color: white;
}
.hktshare div{
margin: auto;
}
.del_mask {
z-index: 20;
background-color: rgba(0, 0, 0, 0.4);
}
.del_block {
top: 6.67rem;
position: absolute;
border-radius: 0.2rem;
background-color: white;
width: 85%;
text-align: center;
margin: 0 7.5%;
}
.del_content {
padding: 2rem 0.5rem;
color: #212121;
font-size: 0.6rem;
font-weight: 600;
}
.del_cancel {
float: left;
line-height: 1.6rem;
width: 49%;
color: #212121;
font-weight: 600;
}
.del_sure {
float: left;
line-height: 1.6rem;
width: 49%;
color: #4f7b97;
font-weight: 600;
}
这个功能使用微信开发能力中的开放标签 [wx-open-launch-weapp] 可以实现。
示例:
<wx-open-launch-weapp
id="launch-btn"
username="gh_xxxxxxxx"
path="pages/home/index?user=123&action=abc"
>
<script type="text/wxtag-template">
<style>.btn { padding: 12px }</style>
<button class="btn">打开小程序</button>
</script>
</wx-open-launch-weapp>
<script>
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', function (e) {
console.log('success');
});
btn.addEventListener('error', function (e) {
console.log('fail', e.detail);
});
</script>
具体参数含义可以看官方文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html#21