|
|
|
@ -143,11 +143,6 @@ |
|
|
|
// return this.$refs.agreements.popup(this.pwdLogin) |
|
|
|
// } |
|
|
|
|
|
|
|
let data = { |
|
|
|
"password": this.password, |
|
|
|
"phone": this.username |
|
|
|
} |
|
|
|
|
|
|
|
// if (/^1\d{10}$/.test(this.username)) { |
|
|
|
// data.mobile = this.username |
|
|
|
// } else if (/@/.test(this.username)) { |
|
|
|
@ -155,74 +150,47 @@ |
|
|
|
// } else { |
|
|
|
// data.username = this.username |
|
|
|
// } |
|
|
|
|
|
|
|
if(this.userType=='user'){ |
|
|
|
API.login(data, res=>{ |
|
|
|
console.log(res); |
|
|
|
// this.loginSuccess() |
|
|
|
let url = '', newUrl = ''; |
|
|
|
let data = {}; |
|
|
|
switch (this.userType){ |
|
|
|
case 'user': |
|
|
|
url = '/passport/login'; |
|
|
|
data = {phone: this.username, password: this.password}; |
|
|
|
newUrl = '/pages/home/home'; |
|
|
|
break; |
|
|
|
case 'agent': |
|
|
|
url = '/passport/agentLogin'; |
|
|
|
data = {phone: this.username, password: this.password}; |
|
|
|
newUrl = '/pages/list/team'; |
|
|
|
break; |
|
|
|
case 'background': |
|
|
|
url = '/passport/adminLogin'; |
|
|
|
data = {account_number: this.username, password: this.password}; |
|
|
|
newUrl = '/pages/home/home'; |
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
title: res.msg |
|
|
|
}) |
|
|
|
uni.setStorageSync('user_token', res.data.token); |
|
|
|
let accounts = uni.getStorageSync('accounts') || []; |
|
|
|
accounts.push(this.username); |
|
|
|
uni.setStorageSync('accounts', accounts); |
|
|
|
uni.setStorageSync('userType', 'user'); |
|
|
|
// updateTabBar.changeUser(); |
|
|
|
setTimeout(()=>{ |
|
|
|
uni.switchTab({ |
|
|
|
url:'/pages/home/home' |
|
|
|
}) |
|
|
|
}, 1500) |
|
|
|
}) |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if(this.userType=='agent'){ |
|
|
|
API.request('/passport/agentLogin', { |
|
|
|
phone: this.username, |
|
|
|
password: this.password |
|
|
|
}, res=>{ |
|
|
|
console.log(res); |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg |
|
|
|
API.request(url, data, res=>{ |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg |
|
|
|
}) |
|
|
|
|
|
|
|
let accounts = uni.getStorageSync('accounts') || []; |
|
|
|
accounts.push(this.username); |
|
|
|
accounts = Array.from(new Set(accounts)); |
|
|
|
uni.setStorageSync('accounts', accounts); |
|
|
|
|
|
|
|
uni.setStorageSync('user_token', res.data.token); |
|
|
|
uni.setStorageSync('userType', this.userType); |
|
|
|
|
|
|
|
setTimeout(()=>{ |
|
|
|
uni.switchTab({ |
|
|
|
url:newUrl |
|
|
|
}) |
|
|
|
uni.setStorageSync('user_token', res.data.token); |
|
|
|
let accounts = uni.getStorageSync('accounts') || []; |
|
|
|
accounts.push(this.username); |
|
|
|
uni.setStorageSync('accounts', accounts); |
|
|
|
uni.setStorageSync('userType', 'agent'); |
|
|
|
// updateTabBar.changeAgent(); |
|
|
|
setTimeout(()=>{ |
|
|
|
uni.switchTab({ |
|
|
|
url:'/pages/list/team' |
|
|
|
}) |
|
|
|
}, 1500) |
|
|
|
}, fail=>{}, false) |
|
|
|
} |
|
|
|
}, 1500) |
|
|
|
}, fail=>{}, false) |
|
|
|
|
|
|
|
if(this.userType=='background'){ |
|
|
|
API.request('/passport/adminLogin', { |
|
|
|
account_number: this.username, |
|
|
|
password: this.password |
|
|
|
}, res=>{ |
|
|
|
console.log(res); |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg |
|
|
|
}) |
|
|
|
uni.setStorageSync('user_token', res.data.token); |
|
|
|
let accounts = uni.getStorageSync('accounts') || []; |
|
|
|
accounts.push(this.username); |
|
|
|
uni.setStorageSync('accounts', accounts); |
|
|
|
uni.setStorageSync('userType', 'background'); |
|
|
|
// updateTabBar.changebackground(); |
|
|
|
setTimeout(()=>{ |
|
|
|
uni.switchTab({ |
|
|
|
url:'/pages/home/home' |
|
|
|
}) |
|
|
|
}, 1500) |
|
|
|
}, fail=>{}, false) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// uniIdCo.login(data).then(e => { |
|
|
|
|