学生党一枚,刚接触小程序,有很多地方不懂,望得到各位指点
authorization(e) {
let that = this
console.log("abaaba",this.data.open_id.result.openid)
console.log(e)
if (wx.requestSubscribeMessage) {
wx.requestSubscribeMessage({
tmplIds: ['QPLrrmYm_Kt8giQiZHLJhPW-wQXxy5a4CrwgNSpMZe4'],
success(res) {
if (res['QPLrrmYm_Kt8giQiZHLJhPW-wQXxy5a4CrwgNSpMZe4'] === 'accept') {
console.log("授权成功",res)
that.send_pop(e)
} else if (res['QPLrrmYm_Kt8giQiZHLJhPW-wQXxy5a4CrwgNSpMZe4'] ==='reject') {
console.log("取消授权")
} else {
wx.showToast({
title: '授权订阅消息有误',
icon: 'none'
})
}
},
fail(res) {
if (res.errCode == 20004) {
// 显示引导设置弹窗
that.setData({
isShowSetModel: true
})
}else{
// 其他错误信息码,对应文档找出原因
wx.showModal({
title: '提示',
content: res.errMsg,
showCancel: false
})
}
}
})
} else {
wx.showModal({
title: '提示',
content: '请更新您微信版本,来获取订阅消息功能',
showCancel: false
})
}
}
//拉起弹窗
send_pop(e) {
console.log("拉起弹窗",e)
const position = e.currentTarget.dataset.position
let customStyle = ''
let duration = this.data.duration
switch(position) {
case 'top':
case 'bottom':
customStyle = 'height: 80%;'
break
case 'right':
break
}
this.setData({
position,
show: true,
customStyle,
duration
})
},
你这是长期订阅还是一次性的 一次性每次都要点击授权才能发送订阅消息 一次性有次数限制的