Commit 21a85664 authored by 潘永坪's avatar 潘永坪

登录优化

parent 438d3a35
......@@ -45,15 +45,22 @@ export default {
data.companyId=uni.getStorageSync('enterOptions').query.companyId||''
}
this.$request('wechat/wx/getUserInfoByCode', data).then(res => {
if (res.code == '00') {
let openid = res.data.openid
uni.setStorageSync('openid', openid)
let userId = res.data.userId || ''
this.login(openid,userId,source)
} else {
try{
if (res.code == '00') {
let openid = res.data.openid
uni.setStorageSync('openid', openid)
let userId = res.data.userId || ''
this.login(openid,userId,source)
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
}catch(e){
uni.showToast({
title: res.message,
icon: 'none'
title: e,
icon: 'none'
})
}
}).catch(err => {
......@@ -75,37 +82,44 @@ export default {
login(openid,userId,source){
let datas = {openid,userId,source}
this.$request('wechatUser/login/findWxUserAndLogin', datas).then(res => {
//通过openid获取token
if (res.code == '00') {
let token = res.data.token || ''
uni.setStorageSync('token', token)
let createUserId = res.data.personId || ''
uni.setStorageSync('createUserId', createUserId)
let userId = res.data.userId || ''
uni.setStorageSync('userId', userId)
let enterOptions = uni.getStorageSync('enterOptions')
let queryTotal = ''
for (let key in enterOptions.query) {
queryTotal += '&' + key + '=' + enterOptions.query[key]
}
queryTotal = queryTotal.substr(1)
if (token) {
uni.reLaunch({
url: '/' + enterOptions.path + '?' + queryTotal
})
//保存当前日期
let oldDate=this.$commonjs.today()
uni.setStorageSync('oldDate', oldDate)
// uni.navigateBack({
// delta:1
// })
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
try{
//通过openid获取token
if (res.code == '00') {
let token = res.data.token || ''
uni.setStorageSync('token', token)
let createUserId = res.data.personId || ''
uni.setStorageSync('createUserId', createUserId)
let userId = res.data.userId || ''
uni.setStorageSync('userId', userId)
let enterOptions = uni.getStorageSync('enterOptions')
let queryTotal = ''
for (let key in enterOptions.query) {
queryTotal += '&' + key + '=' + enterOptions.query[key]
}
queryTotal = queryTotal.substr(1)
if (token) {
uni.reLaunch({
url: '/' + enterOptions.path + '?' + queryTotal
})
//保存当前日期
let oldDate=this.$commonjs.today()
uni.setStorageSync('oldDate', oldDate)
// uni.navigateBack({
// delta:1
// })
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
}catch(e){
uni.showToast({
title: e,
icon: 'none'
})
}
}).catch(err => {
uni.showToast({
title: '登录失败,请退出并重新登录',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment