diff --git a/src/pages/yyyflogin.vue b/src/pages/yyyflogin.vue index 7ed6294..53f4346 100644 --- a/src/pages/yyyflogin.vue +++ b/src/pages/yyyflogin.vue @@ -9,7 +9,7 @@ import Cookie from '@/common/cookie'; import {FILE_URL} from '@/api/app'; import {signInYyyf} from '@/api/yyyf'; - import {signUp,signIn} from '@/api/user'; + import {signUp, signIn} from '@/api/user'; import {Loading} from 'element-ui'; export default { @@ -47,7 +47,7 @@ this.loading = Loading.service({ lock: true, text: '初始化登录ing...', - background: 'rgba(204, 0, 0, 0.7)' + background: 'rgba(0,0,0,0.7)' }); }, endLoading: function () { //使用Element loading-close 方法 @@ -82,40 +82,80 @@ } 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) { - signInYyyf(params).then(res1 => { + signInYyyf(params).then(res => { + debugger; // console.log(res); - if (res1.data.code === 200) { - let status=res1.data.data.status; - if(status==1){ + if (res.data.code === 200) { + let status = res.data.data.status; + if (status == 1) { //保存登录的token到cookie // 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 != ''){ - signUp({ - tel: res1.data.data.tel, - nickName: res1.data.data.nickName, - code: res1.data.data.code, - password: res1.data.data.password, + if (code != undefined && code != '') { + let signParams = { + tel: tel, + nickName: res.data.data.nickName, + code: res.data.data.code, + password: password, internationalCode: null, 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() - location.href = '/';*/ - }else{ + this.login(tel, password); + + } else { this.$message.warning({ message: res.data.data.msg, onClose: function () { diff --git a/src/views/login/signIn.vue b/src/views/login/signIn.vue index af00fc0..17a692c 100644 --- a/src/views/login/signIn.vue +++ b/src/views/login/signIn.vue @@ -102,65 +102,6 @@ export default { this.login(this.phoneNum, this.password); } }, - login(num, pass) { - 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); - - getPayPassword().then(res => { - // console.log(res.data.data); - if (res.data.code === 200) { - // Cookie.set('is_pay', res.data.data); - localStorage.setItem('is_pay', res.data.data); - } - - //登录成功之后的页面跳转 - switch (this.backToUrl) { - case 'login': - window.location.href = '/personal'; - break; - case '': - case 'footer': - window.location.href = '/'; - break; - case undefined: - window.location.href = '/personal'; - break; - default: - window.location.href = this.backToUrl; - break; - } - }); - } else { - this.loading = false; - this.$message.warning(res.data.msg); - } - }); - }, motion(e) { Cookie.set('is_motion', e); },