You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
3 years ago
|
export default {
|
||
|
|
||
|
openMsg(){
|
||
|
var that = this
|
||
|
|
||
|
|
||
|
return console.log("test...");
|
||
|
|
||
|
wx.getSetting({
|
||
|
withSubscriptions: true, //是否获取用户订阅消息的订阅状态,默认false不返回
|
||
|
success(ret) {
|
||
|
// console.log(ret,'------------------')
|
||
|
// console.log(Object.keys(ret.subscriptionsSetting.itemSettings).length)
|
||
|
// if (JSON.stringify(ret.subscriptionsSetting.itemSettings).indexOf('accept')!=-1) {
|
||
|
if (ret.subscriptionsSetting.itemSettings) {
|
||
|
uni.setStorageSync('sendtaskMsg', true)
|
||
|
uni.openSetting({ // 打开设置页
|
||
|
success(rea) {
|
||
|
console.log(rea.authSetting)
|
||
|
}
|
||
|
});
|
||
|
} else { // 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
|
||
|
uni.setStorageSync('sendtaskMsg', false)
|
||
|
uni.showModal({
|
||
|
title: '提示',
|
||
|
content: '为了更好的体验,请绑定消息推送',
|
||
|
confirmText: '确定',
|
||
|
cancelText: '取消',
|
||
|
success: function(res) {
|
||
|
if (res.confirm) {
|
||
|
uni.requestSubscribeMessage({
|
||
|
tmplIds: that.arr,
|
||
|
success(re) {
|
||
|
// console.log(re,'**********')
|
||
|
var datas = JSON.stringify(re);
|
||
|
if (datas.indexOf("accept") != -1) {
|
||
|
console.log(re)
|
||
|
}
|
||
|
},
|
||
|
fail: (res) => {
|
||
|
console.log(res)
|
||
|
}
|
||
|
})
|
||
|
that.showModal = false
|
||
|
} else if (res.cancel) {
|
||
|
that.showModal = true
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
}
|