|
|
@ -37,16 +37,19 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import memberApi from '@/api/member.js'; |
|
|
import memberApi from '@/api/member.js'; |
|
|
|
|
|
import Api from '@/api/api.js'; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
password: true, |
|
|
password: true, |
|
|
user: '18888888888', //账户 |
|
|
user: '15148228108', //账户 |
|
|
password1: '123456' //密码 |
|
|
password1: '123123', //密码 |
|
|
|
|
|
loginType:'',//登陆类型|1=教练,2=销售,3=学员 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onLoad() { |
|
|
onLoad(options) { |
|
|
|
|
|
this.loginType = options.loginType ?? '2'//登陆类型|1=教练,2=销售,3=学员 |
|
|
// uni.hideHomeButton() |
|
|
// uni.hideHomeButton() |
|
|
// console.log(uni.getStorageSync('um_id')) |
|
|
// console.log(uni.getStorageSync('um_id')) |
|
|
}, |
|
|
}, |
|
|
@ -63,51 +66,62 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
//登陆 |
|
|
//登陆 |
|
|
login() { |
|
|
async login() { |
|
|
let item = {}; |
|
|
let item = {}; |
|
|
item['username'] = this.user |
|
|
item['username'] = this.user |
|
|
item['password'] = this.password1 |
|
|
item['password'] = this.password1 |
|
|
//登陆 |
|
|
|
|
|
memberApi.login(item).then(res => { |
|
|
|
|
|
if (res.code == 1) { |
|
|
|
|
|
uni.setStorageSync('token', res.data.token); |
|
|
|
|
|
let userType = res.data.userType |
|
|
|
|
|
|
|
|
|
|
|
// userType = 3//测试完注释本行 |
|
|
let res |
|
|
console.log('用户类型', userType) |
|
|
//判断登陆类型|1=教练,2=销售,3=学员 |
|
|
|
|
|
if(this.loginType == 1){ |
|
|
|
|
|
}else if(this.loginType == 2){ |
|
|
|
|
|
//销售 |
|
|
|
|
|
let params = { |
|
|
|
|
|
'phone': this.user, |
|
|
|
|
|
'password': this.password1, |
|
|
|
|
|
'login_type': 2, |
|
|
|
|
|
} |
|
|
|
|
|
res = await Api.personnelLogin(params) |
|
|
|
|
|
console.log(123123,res) |
|
|
|
|
|
|
|
|
uni.setStorageSync('userType', userType); |
|
|
}else if (this.loginType == 3){ |
|
|
uni.setStorageSync('tabBerIndex', 0); |
|
|
} |
|
|
|
|
|
|
|
|
let url_path = '' |
|
|
if(!res.code){ |
|
|
switch (String(userType)) { |
|
|
uni.showToast({ |
|
|
case '1': //教练 |
|
|
title: res.msg, |
|
|
url_path = '/pages/coach/home/index' |
|
|
icon: 'none' |
|
|
break; |
|
|
}) |
|
|
case '2': //销售 |
|
|
return |
|
|
url_path = '/pages/market/index/index' |
|
|
} |
|
|
break; |
|
|
uni.setStorageSync('expires_time', res.data.expires_time);//token过期时间 |
|
|
case '3': //学员 |
|
|
uni.setStorageSync('token', res.data.token); |
|
|
url_path = '/pages/student/index/index' |
|
|
let userType = res.data.user_type |
|
|
break; |
|
|
console.log('用户类型', userType) |
|
|
default: |
|
|
uni.setStorageSync('userType', userType); |
|
|
uni.showToast({ |
|
|
uni.setStorageSync('tabBerIndex', 0); |
|
|
title: '用户类型错误', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uni.navigateTo({ |
|
|
let url_path = '' |
|
|
url: url_path |
|
|
switch (String(userType)) { |
|
|
}) |
|
|
case '1': //教练 |
|
|
} else { |
|
|
url_path = '/pages/coach/home/index' |
|
|
|
|
|
break; |
|
|
|
|
|
case '2': //销售 |
|
|
|
|
|
url_path = '/pages/market/index/index' |
|
|
|
|
|
break; |
|
|
|
|
|
case '3': //学员 |
|
|
|
|
|
url_path = '/pages/student/index/index' |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: res.msg, |
|
|
title: '用户类型错误', |
|
|
icon: 'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}) |
|
|
} |
|
|
return; |
|
|
}); |
|
|
} |
|
|
|
|
|
uni.navigateTo({ |
|
|
|
|
|
url: url_path |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
loginWx() { |
|
|
loginWx() { |
|
|
uni.login({ |
|
|
uni.login({ |
|
|
|