取消和确定这两个点击事件如何获取
代码
wx.request({
url: app.domainHost + ‘index/api/program’,
data: {
‘encryptedData’: e.detail.encryptedData,
‘iv’: e.detail.iv,
‘session_key’: res.data.session_key,
‘openid’: session_info.openid,
‘unionid’: session_info.unionid,
},
method: ‘GET’, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {
‘content-type’: ‘application/json’
}, // 设置请求的 header
success: function (res) {
console.log(‘写入手机号’,res);
wx.hideLoading();//隐藏加载
if (res.statusCode == 200 && res.data == -41002) {
console.log(‘未绑定手机号’);
wx.showModal({
title: ‘提示’,
showCancel: true,
content: ‘未绑定手机号’,
cancelText:‘跳过’,
success: function (res) {
if (res.confirm) {
//确定操作
} else if (res.cancel) {
//取消操作
self.setData({
auth_type: 0,
isLogin: true
});
}
}
});
return false
} else if (res.statusCode == 200 && res.data.phoneNumber) {
//用户手机号写入缓存
var user_phone = {};
user_phone[‘phone’] = res.data.phoneNumber;
user_phone[‘openid’] = session_info.openid;
user_phone[‘unionid’] = session_info.unionid;
wx.setStorageSync(‘user_phone’, user_phone);
//console.log(‘用户获取手机号’ + res.data.phoneNumber);
self.setData({
auth_type: 0,
isLogin: true
});
if (self.data.isShop == false) {
//未查询出店铺信息弹出跳转首页
wx.showModal({
title: ‘提示’,
showCancel: false,
content: ‘-’ + self.data.errorMsg,
success: function (res) {
wx.switchTab({
url: ‘…/index/index’
})
}
});
return false
}
}
},
fail: function (err) {
//console.log(‘用户取消授权手机号’);
wx.showModal({
title: ‘提示’,
content: ‘需要通过授权才能使用,请重新点击并授权!’,
showCancel: false,
success: function (res) {
console.log(‘弹框后点取消’)
}
})
}
})