Commit a8ba5dbf by zhangquan

手机号解密失败

1 parent 0b4747c0
......@@ -45,13 +45,11 @@ class UsersApi {
}
/**授权手机号登录 */
async authUserPhone(detail, loginToken) {
console.log(221)
if (!loginToken) {
wx.$api.showToast('缺少loginToken')
Promise.reject()
return
}
console.log(111)
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
......
......@@ -42,7 +42,7 @@ Page({
this.init()
},
async init() {
async init(tip) {
try {
const {
data,
......@@ -51,12 +51,15 @@ Page({
} = await USERAPI.wxCodeLogin()
if (code == '0') {
this.loginToken = data
if(tip){
wx.$api.showToast(`${tip == 1 ? '登录':'注册'}信息已失效,请重试`)
}
} else this.reLogin(message)
wx.hideLoading()
} catch ({
errMsg
}) {
console.error(errMsg)
console.log(errMsg)
this.reLogin(errMsg)
}
},
......@@ -101,15 +104,15 @@ Page({
mobile: formData.phone,
code: formData.code
}
wx.showLoading()
if(this.data.showLoading || this.data.disabled) return;
this.setShowLoading(true)
USERAPI.phoneSmsLogin(obj).then(({
code,
data,
message,
errId
}) => {
this.setShowLoading(false)
wx.hideLoading()
if (code == '0') {
this.checkLoginUserInfo(data)
} else if(errId=='30990103') {
......@@ -120,7 +123,7 @@ Page({
wx.$api.showToast(message || '系统异常')
}
}).catch(err => {
this.setShowLoading(false)
wx.hideLoading()
wx.$api.showToast('系统异常')
})
},
......@@ -132,7 +135,7 @@ Page({
/**多个账号 */
console.log(loginUserInfoList,'loginUserInfoList')
if (loginUserInfoList.length > 1) wx.$router.go('/pages/authentication/accountItems/accountItems', {
if (loginUserInfoList.length > 1) wx.$router.reLaunch('/pages/authentication/accountItems/accountItems', {
sessionId,
...this.options
})
......@@ -184,8 +187,12 @@ Page({
// this.setData({
// smsLoading: false
// })
if (code == '0') this.countDown(countDown)
else wx.$api.showToast(message || '发送验证码失败')
if (code == '0') {
wx.$api.showToast('验证码已发送')
this.countDown(countDown)
}else{
wx.$api.showToast(message || '发送验证码失败')
}
}).catch(err => {
// this.setData({
// smsLoading: false
......@@ -220,27 +227,30 @@ Page({
detail
}) {
if (!detail.code || this.data.showLoading) return
this.setShowLoading(true)
// this.setShowLoading(true)
wx.showLoading()
USERAPI.authUserPhone(detail, this.loginToken).then(({
code,
data,
message,
errId
}) => {
this.setShowLoading(false)
wx.hideLoading()
if (code == '0'){
this.checkLoginUserInfo(data)
}else if(errId=='30990103'){
this.setData({
authorized:true
})
}else if(errId == '200122'){
this.init(1)
}else{
wx.$api.showToast(message || '系统异常')
}
}).catch(({
errMsg
}) => {
this.setShowLoading(false)
wx.hideLoading()
wx.$api.showToast('系统异常')
})
},
......
......@@ -22,7 +22,7 @@ Page({
headerHeight: height,
});
},
async init() {
async init(tip) {
try {
const {
data,
......@@ -30,10 +30,10 @@ Page({
message
} = await USERAPI.wxCodeLogin()
if (code == '0') {
this.setData({
disabled: false
})
this.loginToken = data
if(tip){
wx.$api.showToast(`${tip == 1 ? '登录':'注册'}信息已失效,请重试`)
}
} else this.reLogin(message)
wx.hideLoading()
} catch ({
......@@ -83,9 +83,12 @@ Page({
},
register(params,detail){
USERAPI.register(params).then((res) => {
console.log(res,'errId')
if (res.code == '0'){
this.toLogin(detail)
}else{
}else if(res.errId == '200122'){
this.init(2)
}else {
wx.$api.showToast(res.message || '系统异常')
}
})
......@@ -99,6 +102,8 @@ Page({
}) => {
if (code == '0'){
this.checkLoginUserInfo(data)
}else if(errId == '200122'){
this.init(1)
}else{
wx.$api.showToast(message || '系统异常')
}
......
......@@ -42,7 +42,7 @@ Page({
onLoad(options) {
this.init()
},
async init() {
async init(tip) {
try {
const {
data,
......@@ -51,6 +51,9 @@ Page({
} = await USERAPI.wxCodeLogin()
if (code == '0') {
this.loginToken = data
if(tip){
wx.$api.showToast(`${tip == 1 ? '登录':'注册'}信息已失效,请重试`)
}
} else this.reLogin(message)
wx.hideLoading()
} catch ({
......@@ -111,6 +114,8 @@ Page({
USERAPI.register(params).then((res) => {
if (res.code == '0'){
this.toLogin()
}else if(res.errId == '200122'){
this.init(2)
}else{
wx.$api.showToast(res.message || '系统异常')
}
......@@ -126,6 +131,8 @@ Page({
}) => {
if (code == '0'){
this.checkLoginUserInfo(data)
}else if(errId == '200122'){
this.init(1)
}else{
wx.$api.showToast(message || '系统异常')
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!