|
|
@ -9,7 +9,7 @@ |
|
|
|
import Cookie from '@/common/cookie'; |
|
|
|
import Cookie from '@/common/cookie'; |
|
|
|
import {FILE_URL} from '@/api/app'; |
|
|
|
import {FILE_URL} from '@/api/app'; |
|
|
|
import {signInYyyf} from '@/api/yyyf'; |
|
|
|
import {signInYyyf} from '@/api/yyyf'; |
|
|
|
import {signUp,signIn} from '@/api/user'; |
|
|
|
import {signUp, signIn} from '@/api/user'; |
|
|
|
import {Loading} from 'element-ui'; |
|
|
|
import {Loading} from 'element-ui'; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
@ -47,7 +47,7 @@ |
|
|
|
this.loading = Loading.service({ |
|
|
|
this.loading = Loading.service({ |
|
|
|
lock: true, |
|
|
|
lock: true, |
|
|
|
text: '初始化登录ing...', |
|
|
|
text: '初始化登录ing...', |
|
|
|
background: 'rgba(204, 0, 0, 0.7)' |
|
|
|
background: 'rgba(0,0,0,0.7)' |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
endLoading: function () { //使用Element loading-close 方法 |
|
|
|
endLoading: function () { //使用Element loading-close 方法 |
|
|
@ -82,40 +82,80 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
return params; |
|
|
|
return params; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
sign(params) { |
|
|
|
|
|
|
|
signUp(params).then(res => { |
|
|
|
|
|
|
|
// console.log(res.data) |
|
|
|
|
|
|
|
if (res.data.code !== 200) { |
|
|
|
|
|
|
|
this.$message.warning(res.data.msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
login(num, pass) { |
|
|
|
|
|
|
|
debugger; |
|
|
|
|
|
|
|
signIn({ |
|
|
|
|
|
|
|
tel: num, |
|
|
|
|
|
|
|
password: pass, |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
// console.log(res); |
|
|
|
|
|
|
|
if (res.data.code === 200) { |
|
|
|
|
|
|
|
//判断是否保存自动登录 |
|
|
|
|
|
|
|
// if( this.checked === true ){ |
|
|
|
|
|
|
|
// Cookie.set('phoneNum',num) |
|
|
|
|
|
|
|
// Cookie.set('password',pass) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
|
|
//保存登录的token到cookie |
|
|
|
|
|
|
|
// Cookie.set('token', res.data.data.token); |
|
|
|
|
|
|
|
localStorage.setItem('token', res.data.data.token); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存登录的用户信息到cookie |
|
|
|
|
|
|
|
// Cookie.set('userData', res.data.data); |
|
|
|
|
|
|
|
localStorage.setItem('userData', JSON.stringify(res.data.data)); |
|
|
|
|
|
|
|
// console.log(JSON.parse(localStorage.getItem('userData'))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存userID的信息到cookie |
|
|
|
|
|
|
|
// Cookie.set('userID', res.data.data.id); |
|
|
|
|
|
|
|
localStorage.setItem('userID', res.data.data.id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存邀请码信息 |
|
|
|
|
|
|
|
localStorage.setItem('invitationCode', res.data.data.invitationCode); |
|
|
|
|
|
|
|
this.endLoading() |
|
|
|
|
|
|
|
location.href = '/'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.$message.warning(res.data.msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
loginFromYyyf: function (params) { |
|
|
|
loginFromYyyf: function (params) { |
|
|
|
signInYyyf(params).then(res1 => { |
|
|
|
signInYyyf(params).then(res => { |
|
|
|
|
|
|
|
debugger; |
|
|
|
// console.log(res); |
|
|
|
// console.log(res); |
|
|
|
if (res1.data.code === 200) { |
|
|
|
if (res.data.code === 200) { |
|
|
|
let status=res1.data.data.status; |
|
|
|
let status = res.data.data.status; |
|
|
|
if(status==1){ |
|
|
|
if (status == 1) { |
|
|
|
//保存登录的token到cookie |
|
|
|
//保存登录的token到cookie |
|
|
|
// Cookie.set('token', res.data.data.token); |
|
|
|
// Cookie.set('token', res.data.data.token); |
|
|
|
localStorage.setItem('yyyfToken', res1.data.data.yyyfUserToken); |
|
|
|
localStorage.setItem('yyyfToken', res.data.data.yyyfUserToken); |
|
|
|
|
|
|
|
|
|
|
|
let code=res1.data.data.code; |
|
|
|
let code = res.data.data.code; |
|
|
|
|
|
|
|
let tel = res.data.data.tel; |
|
|
|
|
|
|
|
let password = res.data.data.password; |
|
|
|
//注册 |
|
|
|
//注册 |
|
|
|
if(code!=undefined && code != ''){ |
|
|
|
if (code != undefined && code != '') { |
|
|
|
signUp({ |
|
|
|
let signParams = { |
|
|
|
tel: res1.data.data.tel, |
|
|
|
tel: tel, |
|
|
|
nickName: res1.data.data.nickName, |
|
|
|
nickName: res.data.data.nickName, |
|
|
|
code: res1.data.data.code, |
|
|
|
code: res.data.data.code, |
|
|
|
password: res1.data.data.password, |
|
|
|
password: password, |
|
|
|
internationalCode: null, |
|
|
|
internationalCode: null, |
|
|
|
invitationCode: '', |
|
|
|
invitationCode: '', |
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
// console.log(res.data) |
|
|
|
|
|
|
|
if (res.data.code === 200) { |
|
|
|
|
|
|
|
this.$router.replace('/signIn'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
|
|
this.$message.warning(res.data.msg); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
this.sign(signParams); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*this.endLoading() |
|
|
|
this.login(tel, password); |
|
|
|
location.href = '/';*/ |
|
|
|
|
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
this.$message.warning({ |
|
|
|
this.$message.warning({ |
|
|
|
message: res.data.data.msg, |
|
|
|
message: res.data.data.msg, |
|
|
|
onClose: function () { |
|
|
|
onClose: function () { |
|
|
|