handleSubscript() {
let that = this
const template_id_1 = '模版id1'
const template_id_2 = '模版id2'
wx.requestSubscribeMessage({
tmplIds: [template_id_1, template_id_2],
success(res) {0
if (res[template_id_1] === 'accept') {
} else if (res[template_id_1] === 'reject') {
}
if (res[template_id_2] === 'accept') {
} else if (res[template_id_2] === 'reject') {
}
},
})
},
H5中的写法
<div id="subwrapper" >
<wx-open-subscribe template="模版id" @success="handleSuccess" id="subscribe-btn" style=" position: fixed;
z-index: 1;
bottom: 0;
width: 100%;
height: 49px;
display: flex;
justify-content: space-around;
align-items: center;
background-color: #fff;overflow:hidden;">
<script type="text/wxtag-template">
<style>
.footer::before {
position: absolute;
top: -10px;
content: "";
width: 100%;
height: 10px;
background-color: #f3f4f6;
}
.footer {
position: fixed;
z-index: 1;
bottom: 0;
width: 100%;
height: 49px;
display: flex;
justify-content: space-around;
align-items: center;
background-color: #fff;
}
.btn {
width: 232px;
height: 39px;
line-height: 39px;
text-align: center;
background-image: linear-gradient(90deg, #00b4ff 0%, #0055ff 100%);
border-radius: 20px;
font-family: PingFangSC-Medium;
font-size: 14px;
color: #ffffff;
}
.btn1{
background-color: #ebedf0;
background-image: linear-gradient(90deg, #00b3ff00 0%, #0055ff00 100%);
color: #999;
}
</style>
<div class="footer" >
<span class="btn" id='footerbtn' >订阅最新活动提醒</span>
</div>
</script>
</wx-open-subscribe>
</div>
</div>
data(){
return{
subTemplateId: ['模版id'],
}
}
handleSuccess(e) {
let that = this
let memberId = this.getUrlKey("memberId");
let subscribeDetails = JSON.parse(e.detail.subscribeDetails)
for (let i in this.subTemplateId) {
let subKey = subscribeDetails[this.subTemplateId[i]]
let status = JSON.parse(subKey)
switch (status.status) {
case 'reject':
this.$toast(`授权后可获取最新通知`)
break
case 'cancel':
this.$toast(`授权后可获取最新通知`)
break
default:
break
}
}
},