提交 a3a4366e authored 作者: hexi's avatar hexi

用户手机号没有绑定微信弹出提示框

上级 5754ccd9
......@@ -13,8 +13,7 @@ const BindAccount = {
/* 点击确定 */
accountConfirm: function (e) {
const _that = this, _bind = _that.data.bindaccount
const _that = this, _bind = _that.data.bindaccount;
/* 调用接口 - 使用账号登录 */
wx.request({
url: util.config.URL_PATH2 + '/user_center/login',
......@@ -24,11 +23,12 @@ const BindAccount = {
service: 'applet.ezijing.com' }, method: 'POST', header: {
'tenant': util.config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'version':util.config.version,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N'
},
success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
wx.hideToast()
wx.hideToast();
wx.setStorageSync('userSession', { sessionKey: res.data.ticket });
let _token = wx.getStorageSync('userSession').sessionKey
......@@ -43,10 +43,26 @@ const BindAccount = {
token: _token,
tenant: util.config.tenant,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
'version':util.config.version,
unionid: wx.getStorageSync('union_id')
},
success: res => {
if (res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
if (res.statusCode != 200 && res.statusCode != 401) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
if (res.statusCode && res.statusCode == 401) {
// 401特殊处理,这种情况,理解为手机号绑定错误
wx.hideToast();
wx.showModal({
title: '提示',
content: res.data.message,
showCancel:false,
complete (res) {
_that.setData({
'bindaccount.pwd': '',
});
}
})
return ;
}
let _userInfo = {
avatarUrl: res.data.avatar || _that.tempUserInfo.avatarUrl || '无',
nickName: res.data.nickname || _that.tempUserInfo.nickName || '无'
......
......@@ -46,7 +46,7 @@ const BindPhone = {
},
/* 点击确定 */
codeConfirm: function (e) {
const _that = this, _bind = _that.data.bindphone
const _that = this, _bind = _that.data.bindphone;
if (!_bind.phone || !/^1[3-9][0-9]{9}$/.test(_bind.phone)) { wx.showToast({ title: '请填入正确手机号', icon: 'none' }); return ; }
if (!_bind.code || !/^\d{4}$/.test(_bind.code)) { wx.showToast({ title: '请填入正确验证码', icon: 'none' }); return ; }
wx.showToast({ title: '验证中', icon: 'none' })
......@@ -56,11 +56,12 @@ const BindPhone = {
data: { mobile: _bind.phone, code: _bind.code, service: 'applet.ezijing.com' }, method: 'POST', header: {
'tenant': util.config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'version':util.config.version,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N'
},
success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return ; }
wx.hideToast()
wx.hideToast();
clearInterval(_that.timer);
wx.setStorageSync('userSession', { sessionKey: res.data.ticket });
......@@ -76,10 +77,26 @@ const BindPhone = {
token: _token,
'tenant': util.config.tenant,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
'version':util.config.version,
unionid: wx.getStorageSync('union_id')
},
success: res => {
if (res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
if (res.statusCode != 200 && res.statusCode != 401) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
if (res.statusCode && res.statusCode == 401) {
// 401特殊处理,这种情况,理解为手机号绑定错误
wx.hideToast();
wx.showModal({
title: '提示',
content: res.data.message,
showCancel:false,
complete (res) {
_that.setData({
'bindphone.code': '',
});
}
})
return ;
}
let _userInfo = {
avatarUrl: res.data.avatar || _that.tempUserInfo.avatarUrl || '无',
nickName: res.data.nickname || _that.tempUserInfo.nickName || '无'
......
......@@ -11,7 +11,7 @@ const config = {
URL_PATH2: 'https://sso.ezijing.com', // 正式域名 - 由于项目变动域名
outSiteLink: 'https://e-learning.ezijing.com', // 正式外链
tenant: 'sofia',
version: '3.0.5'
version: '3.0.7'
};
/* 请求接口统一 重定义 */
const requestApi = (obj) => {
......@@ -133,32 +133,36 @@ const loginApi = (obj, callback) => {
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N'
},
success: res1 => {
let _token = res1.data.ticket;
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return ;
}
wx.setStorageSync('userSession', { 'sessionKey': _token });
if (res1.statusCode == 200) {
let _token = res1.data.ticket;
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return ;
}
wx.setStorageSync('userSession', { 'sessionKey': _token });
/* 获取用户信息 */
wx.request({
url: config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: {
token: _token,
tenant: config.tenant,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
unionid: res.data.union_id
},
success: res2 => {
if (res2.statusCode != 200) { wx.showToast({ title: res.data.message||'获取用户信息失败', icon: 'none' }); return; }
/* 获取用户信息 */
wx.request({
url: config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: {
token: _token,
tenant: config.tenant,
'version': config.version,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
unionid: res.data.union_id
},
success: res2 => {
if (res2.statusCode != 200) { wx.showToast({ title: res.data.message||'获取用户信息失败', icon: 'none' }); return; }
wx.setStorageSync("sid", res2.data.id);
wx.setStorageSync("uid", res1.data.uid);
callback(res1, obj);
}
})
}else{
callback(res1, obj);
}
wx.setStorageSync("sid", res2.data.id);
wx.setStorageSync("uid", res1.data.uid);
callback(res1, obj);
}
})
}
})
} else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论