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

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

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