wx
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
<u-icon name="weixin-fill" color="#04be02" size="28"></u-icon>
|
||||
微信抬头一键导入
|
||||
</view>
|
||||
<view class="content_bottom" @click="saveMerchantBaseInfo">确定</view>
|
||||
<view class="content_bottom" @click="requestSubscribeMessage">确定</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -334,7 +334,99 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
async saveMerchantBaseInfo() {
|
||||
requestSubscribeMessage() {
|
||||
var this_ = this
|
||||
var tmplIds = 'LQ4X2dgvpxC6iuZhbxv8qtqVWT9_DFEBPxu-PmggjfY'
|
||||
uni.getSetting({
|
||||
withSubscriptions: true,
|
||||
success(res) {
|
||||
// 调起授权界面弹窗
|
||||
if (res.subscriptionsSetting.mainSwitch) { // 用户打开了订阅消息总开关
|
||||
if (res.subscriptionsSetting.itemSettings !=
|
||||
null) { // 用户同意总是保持是否推送消息的选择, 这里表示以后不会再拉起推送消息的授权
|
||||
let moIdState = res.subscriptionsSetting.itemSettings[tmplIds]; // 用户同意的消息模板id
|
||||
if (moIdState === 'accept') {
|
||||
uni.requestSubscribeMessage({ // 调起消息订阅界面
|
||||
tmplIds: [tmplIds],
|
||||
success(res) {
|
||||
if (res[tmplIds] == 'accept') {
|
||||
this_.overlayshowclick(1)
|
||||
} else if (res[tmplIds] == 'reject') {
|
||||
this_.overlayshowclick(0)
|
||||
} else if (res[tmplIds] == 'ban') {
|
||||
this_.overlayshowclick(0)
|
||||
} else if (res[tmplIds] == 'accept') {
|
||||
this_.overlayshowclick(0)
|
||||
} else {
|
||||
this_.overlayshowclick(0)
|
||||
}
|
||||
},
|
||||
fail(er) {
|
||||
this_.overlayshowclick(0)
|
||||
console.log(er);
|
||||
}
|
||||
})
|
||||
|
||||
} else if (moIdState === 'reject') {
|
||||
console.log("拒绝消息推送");
|
||||
this_.overlayshowclick(0)
|
||||
|
||||
} else if (moIdState === 'ban') {
|
||||
console.log("已被后台封禁");
|
||||
this_.overlayshowclick(0)
|
||||
}
|
||||
} else {
|
||||
// 当用户没有点击 ’总是保持以上选择,不再询问‘ 按钮。那每次执到这都会拉起授权弹窗
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请授权开通服务通知',
|
||||
showCancel: true,
|
||||
success: function(ress) {
|
||||
if (ress.confirm) {
|
||||
// console.log('用户点击确定')
|
||||
uni.requestSubscribeMessage({ // 调起消息订阅界面
|
||||
tmplIds: [tmplIds],
|
||||
success(res) {
|
||||
if (res[tmplIds] == 'accept') {
|
||||
this_.overlayshowclick(1)
|
||||
} else if (res[tmplIds] == 'reject') {
|
||||
this_.overlayshowclick(0)
|
||||
} else if (res[tmplIds] == 'ban') {
|
||||
this_.overlayshowclick(0)
|
||||
} else if (res[tmplIds] == 'accept') {
|
||||
this_.overlayshowclick(0)
|
||||
} else {
|
||||
this_.overlayshowclick(0)
|
||||
}
|
||||
},
|
||||
fail(er) {
|
||||
this_.overlayshowclick(0)
|
||||
console.log(er);
|
||||
}
|
||||
})
|
||||
|
||||
} else if (ress.cancel) {
|
||||
this_.overlayshowclick(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this_.overlayshowclick(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async overlayshowclick(e) {
|
||||
try {
|
||||
if (e == 1) {
|
||||
await this.api.userminidymessage({
|
||||
open_id: this.form.open_id,
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
if (this.form.user_name == null || this.form.user_name == '') {
|
||||
uni.showToast({
|
||||
title: '请输入名称',
|
||||
|
||||
Reference in New Issue
Block a user