uniapp 微信小程序开发需要消息订阅
订阅接口api文档
订阅接口api文档
用户发生点击行为或者发起支付回调后,才可以调起订阅消息界面
微信小程序订阅消息参考文档(opens new window)
使用
<u-tabbar-item @click="GetWxMessageTemplateId" text="工作台" :badge="total" name="workbench">
<image class="u-page__item__slot-icon tabbarimg" slot="active-icon"
src="http://39.99.155.125:8082/buildingMaterialsCloud/static/footernav2_hover.png">
</image>
<image class="u-page__item__slot-icon tabbarimg" slot="inactive-icon"
src="http://39.99.155.125:8082/buildingMaterialsCloud/static/footernav2.png"></image>
</u-tabbar-item>
// 获取微信消息订阅模板
GetWxMessageTemplateId() {
var that = this;
GetWxMessageTemplateId({
params: {
accountId: this.AccountId
},
custom: {
auth: true
}
}).then(res => {
if (res.Code == 200) {
console.log('订阅信息1')
var data = _.chunk(res.Data, 3)
if (data[that.WxMessageTemplateActive].length > 0) {
wx.requestSubscribeMessage({
tmplIds: data[that.WxMessageTemplateActive],
success(res) {
console.log(res)
console.log('订阅信息')
that.WxMessageTemplateActive += 1
}
})
}
}
}).catch(err => {
})
},