|
@@ -7,7 +7,7 @@
|
|
|
</view>
|
|
|
<view class="login-info">
|
|
|
<view class="login-info-box">
|
|
|
- <text class="login-info-title">账号密码登陆</text>
|
|
|
+ <text class="login-info-title">账号密码登录</text>
|
|
|
<view class="login-info-form">
|
|
|
<u--form
|
|
|
labelWidth="0"
|
|
@@ -63,6 +63,7 @@
|
|
|
logoUrl: this.$commonConfig.staticUrl + "login/logo.png",
|
|
|
loading: false,
|
|
|
code: null,
|
|
|
+ h5OpenId: null,
|
|
|
form: {
|
|
|
name: '',
|
|
|
password: '',
|
|
@@ -89,7 +90,7 @@
|
|
|
},
|
|
|
onLoad(e) {
|
|
|
// #ifdef H5
|
|
|
- if(this.vuex_user_info && this.vuex_user_info.accessToken){
|
|
|
+ if(this.distribution_user_info && this.distribution_user_info.accessToken){
|
|
|
this.personsLoginCheck()
|
|
|
}else {
|
|
|
if(!e.code) { // 微信第三方登录失败
|
|
@@ -123,24 +124,23 @@
|
|
|
*/
|
|
|
async login(){
|
|
|
try{
|
|
|
- let openid = ''
|
|
|
// #ifdef H5
|
|
|
const node_dev = process.env.H_NODE_ENV;
|
|
|
- if(node_dev){
|
|
|
+ if(node_dev && !this.h5OpenId){
|
|
|
let wxinfo = await this.$u.api.wxinfoH5({code:this.code});
|
|
|
- openid = wxinfo.data.openid;
|
|
|
+ this.h5OpenId = wxinfo.data.openid;
|
|
|
}
|
|
|
// #endif
|
|
|
let res = await this.$u.api.login({
|
|
|
"mobile": this.form.name,
|
|
|
"password": this.form.password,
|
|
|
- "h5OpenId": openid
|
|
|
+ "h5OpenId": this.h5OpenId
|
|
|
})
|
|
|
if(res && res.code ===200) {
|
|
|
this.loading = false
|
|
|
if(res.data && res.data.accessToken){
|
|
|
- this.$u.vuex('vuex_user_info', res.data);
|
|
|
- let backUrl = uni.getStorageSync('backUrl')
|
|
|
+ this.$u.vuex('distribution_user_info', res.data);
|
|
|
+ let backUrl = uni.getStorageSync('backUrlDistribution')
|
|
|
console.log("backUrl===",backUrl)
|
|
|
if(backUrl && backUrl != '/pages/login/index') {
|
|
|
uni.reLaunch({
|
|
@@ -153,24 +153,33 @@
|
|
|
}
|
|
|
} else {
|
|
|
// 清空用户数据缓存
|
|
|
- uni.setStorageSync('lifeData',{}); // 清除缓存
|
|
|
- this.$u.vuex('vuex_user_info', {});
|
|
|
- this.redirectToAuth()
|
|
|
+ uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
|
|
|
+ this.$u.vuex('distribution_user_info', {});
|
|
|
+ this.$set(this.form,'password','')
|
|
|
+ if(!this.h5OpenId) {
|
|
|
+ this.redirectToAuth()
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
// 清空用户数据缓存
|
|
|
- uni.setStorageSync('lifeData',{}); // 清除缓存
|
|
|
- this.$u.vuex('vuex_user_info', {});
|
|
|
- this.redirectToAuth()
|
|
|
+ uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
|
|
|
+ this.$u.vuex('distribution_user_info', {});
|
|
|
+ this.$set(this.form,'password','')
|
|
|
+ if(!this.h5OpenId) {
|
|
|
+ this.redirectToAuth()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}catch(e){
|
|
|
//TODO handle the exception
|
|
|
console.error("e===",e)
|
|
|
this.loading = false
|
|
|
- uni.setStorageSync('lifeData',{}); // 清除缓存
|
|
|
- this.$u.vuex('vuex_user_info', {});
|
|
|
- this.redirectToAuth()
|
|
|
+ uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
|
|
|
+ this.$u.vuex('distribution_user_info', {});
|
|
|
+ this.$set(this.form,'password','')
|
|
|
+ if(!this.h5OpenId) {
|
|
|
+ this.redirectToAuth()
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
/** 公众号 微信授权登录 */
|
|
@@ -190,8 +199,8 @@
|
|
|
})
|
|
|
if(res && res.code ===200) {
|
|
|
if(res.data && res.data.accessToken){
|
|
|
- this.$u.vuex('vuex_user_info', res.data);
|
|
|
- let backUrl = uni.getStorageSync('backUrl')
|
|
|
+ this.$u.vuex('distribution_user_info', res.data);
|
|
|
+ let backUrl = uni.getStorageSync('backUrlDistribution')
|
|
|
if(backUrl) {
|
|
|
uni.reLaunch({
|
|
|
url: backUrl
|
|
@@ -203,20 +212,20 @@
|
|
|
}
|
|
|
} else {
|
|
|
// 清空用户数据缓存
|
|
|
- uni.setStorageSync('lifeData',{}); // 清除缓存
|
|
|
- this.$u.vuex('vuex_user_info', {});
|
|
|
+ uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
|
|
|
+ this.$u.vuex('distribution_user_info', {});
|
|
|
this.redirectToAuth()
|
|
|
}
|
|
|
} else {
|
|
|
// 清空用户数据缓存
|
|
|
- uni.setStorageSync('lifeData',{}); // 清除缓存
|
|
|
- this.$u.vuex('vuex_user_info', {});
|
|
|
+ uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
|
|
|
+ this.$u.vuex('distribution_user_info', {});
|
|
|
this.redirectToAuth()
|
|
|
}
|
|
|
}catch(e){
|
|
|
//TODO handle the exception
|
|
|
- uni.setStorageSync('lifeData',{}); // 清除缓存
|
|
|
- this.$u.vuex('vuex_user_info', {});
|
|
|
+ uni.setStorageSync('lifeDataDistribution',{}); // 清除缓存
|
|
|
+ this.$u.vuex('distribution_user_info', {});
|
|
|
this.redirectToAuth()
|
|
|
}
|
|
|
|