Merge branch 'fanpeng' into 'develop'
fix: 修复手机号登录bug See merge request StarlockTeam/wx-starlock!33
This commit is contained in:
commit
5fbfa56826
@ -447,16 +447,34 @@
|
|||||||
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const result = await this.phoneLogin({
|
|
||||||
encryptedData: data.detail.encryptedData,
|
const that = this
|
||||||
iv: data.detail.iv
|
uni.showLoading({
|
||||||
|
title: '登录中'
|
||||||
|
})
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin',
|
||||||
|
async success(loginRes) {
|
||||||
|
const result = await that.phoneLogin({
|
||||||
|
encryptedData: data.detail.encryptedData,
|
||||||
|
iv: data.detail.iv,
|
||||||
|
code: loginRes.code
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
if (!result) {
|
||||||
|
uni.showToast({
|
||||||
|
title: result.message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败,请重试'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (!result) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '登录失败,请重试',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async nextPage() {
|
async nextPage() {
|
||||||
if (this.lockList.length < this.lockTotal) {
|
if (this.lockList.length < this.lockTotal) {
|
||||||
|
|||||||
@ -143,62 +143,90 @@
|
|||||||
if (res.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
if (res.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const result = await this.checkSession()
|
|
||||||
if (!result) {
|
const that = this
|
||||||
uni.showToast({
|
uni.showLoading({
|
||||||
title: '登录失败,请重试',
|
title: '登录中'
|
||||||
icon: 'none'
|
})
|
||||||
})
|
uni.login({
|
||||||
return
|
provider: 'weixin',
|
||||||
}
|
async success(loginRes) {
|
||||||
const openid = getStorage('openid')
|
const openid = getStorage('openid')
|
||||||
const { code, data, message } = await phoneLoginRequest({
|
const { code, data, message } = await phoneLoginRequest({
|
||||||
encryptedData: res.detail.encryptedData,
|
encryptedData: res.detail.encryptedData,
|
||||||
iv: res.detail.iv,
|
iv: res.detail.iv,
|
||||||
rebind: true,
|
rebind: true,
|
||||||
openid
|
openid,
|
||||||
|
js_code: loginRes.code
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
if (code === 0) {
|
||||||
|
removeStorage('userInfo')
|
||||||
|
removeStorage('lockList')
|
||||||
|
setStorage('token', data.accessToken)
|
||||||
|
that.updateLockSearch({
|
||||||
|
...that.lockSearch,
|
||||||
|
pageNo: 1
|
||||||
|
})
|
||||||
|
that.getUserInfo()
|
||||||
|
that.getLockList(that.lockSearch)
|
||||||
|
that.updateNotificationSearch({
|
||||||
|
pageNo: 1
|
||||||
|
})
|
||||||
|
that.getNotificationList(that.notificationSearch)
|
||||||
|
uni.showToast({
|
||||||
|
title: '账号切换成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else if (code === 438) {
|
||||||
|
/* empty */
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败,请重试'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (code === 0) {
|
|
||||||
removeStorage('userInfo')
|
|
||||||
removeStorage('lockList')
|
|
||||||
setStorage('token', data.accessToken)
|
|
||||||
this.updateLockSearch({
|
|
||||||
...this.lockSearch,
|
|
||||||
pageNo: 1
|
|
||||||
})
|
|
||||||
this.getUserInfo()
|
|
||||||
this.getLockList(this.lockSearch)
|
|
||||||
this.updateNotificationSearch({
|
|
||||||
pageNo: 1
|
|
||||||
})
|
|
||||||
this.getNotificationList(this.notificationSearch)
|
|
||||||
uni.showToast({
|
|
||||||
title: '账号切换成功',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
} else if (code === 438) {
|
|
||||||
/* empty */
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
title: message,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async getphonenumber(data) {
|
async getphonenumber(data) {
|
||||||
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const result = await this.phoneLogin({
|
|
||||||
encryptedData: data.detail.encryptedData,
|
const that = this
|
||||||
iv: data.detail.iv
|
uni.showLoading({
|
||||||
|
title: '登录中'
|
||||||
|
})
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin',
|
||||||
|
async success(loginRes) {
|
||||||
|
const result = await that.phoneLogin({
|
||||||
|
encryptedData: data.detail.encryptedData,
|
||||||
|
iv: data.detail.iv,
|
||||||
|
code: loginRes.code
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
if (!result) {
|
||||||
|
uni.showToast({
|
||||||
|
title: result.message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败,请重试'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (!result) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '登录失败,请重试',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
toUsereInfo() {
|
toUsereInfo() {
|
||||||
this.routeJump({
|
this.routeJump({
|
||||||
|
|||||||
@ -157,16 +157,34 @@
|
|||||||
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
if (data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const result = await this.phoneLogin({
|
|
||||||
encryptedData: data.detail.encryptedData,
|
const that = this
|
||||||
iv: data.detail.iv
|
uni.showLoading({
|
||||||
|
title: '登录中'
|
||||||
|
})
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin',
|
||||||
|
async success(loginRes) {
|
||||||
|
const result = await that.phoneLogin({
|
||||||
|
encryptedData: data.detail.encryptedData,
|
||||||
|
iv: data.detail.iv,
|
||||||
|
code: loginRes.code
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
if (!result) {
|
||||||
|
uni.showToast({
|
||||||
|
title: result.message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '登录失败,请重试'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (!result) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '登录失败,请重试',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
scroll() {
|
scroll() {
|
||||||
this.$refs.swipeItem.forEach(item => {
|
this.$refs.swipeItem.forEach(item => {
|
||||||
|
|||||||
@ -35,12 +35,12 @@ export const useUserStore = defineStore('user', {
|
|||||||
return code
|
return code
|
||||||
},
|
},
|
||||||
async phoneLogin(params) {
|
async phoneLogin(params) {
|
||||||
const { iv, encryptedData } = params
|
const { iv, encryptedData, code: js_code } = params
|
||||||
const openid = await getStorage('openid')
|
const openid = await getStorage('openid')
|
||||||
if (!openid) {
|
if (!openid) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const { code, data } = await phoneLoginRequest({ iv, encryptedData, openid })
|
const { code, data } = await phoneLoginRequest({ iv, encryptedData, openid, js_code })
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
setStorage('token', data.accessToken)
|
setStorage('token', data.accessToken)
|
||||||
this.getUserInfo()
|
this.getUserInfo()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user