|
|
@@ -39,8 +39,11 @@
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
- testSelect,
|
|
|
- testPic,
|
|
|
+ SignIn,
|
|
|
+ GenVerifyPic,
|
|
|
+ GetPhoneVFCode,
|
|
|
+ PhoneSignIn,
|
|
|
+ testSelect
|
|
|
} from '../api/getApiRes.js'
|
|
|
|
|
|
let qs = require('qs');
|
|
|
@@ -118,8 +121,36 @@
|
|
|
// alert(document.body.clientWidth);
|
|
|
this.getValImgSrc();
|
|
|
this.overtime = new Date();
|
|
|
+ // this.checkcode();
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取CODE
|
|
|
+ checkcode() {
|
|
|
+ // 0213tIFa1fBjAz0OVDIa1LfXwc03tIFK
|
|
|
+ console.log(this.getUrlKey('state'));
|
|
|
+ if (this.getUrlKey('state') == 123) {
|
|
|
+ // 取到值了
|
|
|
+ localStorage.code = this.getUrlKey('code');
|
|
|
+ console.log(localStorage.code);
|
|
|
+ } else {
|
|
|
+ // 第一次加载
|
|
|
+ this.GetOpenId();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取公众号ID
|
|
|
+ GetOpenId() {
|
|
|
+ let origin = location.href;
|
|
|
+ let urlNow = encodeURIComponent(origin);
|
|
|
+ let scope = 'snsapi_userinfo'; //snsapi_userinfo //静默授权 用户无感知
|
|
|
+ // let appid = 'wx36cb8b6661d71811';//正式
|
|
|
+ let appid = 'wx685402342cfa5650';//测试
|
|
|
+ let state = '123';
|
|
|
+ let url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' + urlNow + '&response_type=code&scope=' + scope + '&state=' + state + '#wechat_redirect';
|
|
|
+ self.location = url
|
|
|
+ },
|
|
|
+ getUrlKey(name) {
|
|
|
+ return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null;
|
|
|
+ },
|
|
|
// 获取验证码
|
|
|
getValidSmsBtn() {
|
|
|
let that = this;
|
|
|
@@ -133,7 +164,7 @@
|
|
|
that.Toast('手机号只能是11位');
|
|
|
return false
|
|
|
}
|
|
|
- if(!globalCheckPhone(phone)){
|
|
|
+ if (!globalCheckPhone(phone)) {
|
|
|
that.Toast('手机号格式不正确');
|
|
|
return false
|
|
|
}
|
|
|
@@ -147,16 +178,19 @@
|
|
|
}
|
|
|
let param = {
|
|
|
token: localStorage.token,
|
|
|
- uservalid: uservalid,
|
|
|
+ phone: phone,
|
|
|
+ codeType: 1,
|
|
|
+ picId: this.valImgId,
|
|
|
+ picCode: uservalid,
|
|
|
};
|
|
|
let postdata = qs.stringify(param);
|
|
|
- testSelect(postdata).then(res => {
|
|
|
+ GetPhoneVFCode(postdata).then(res => {
|
|
|
let json = res;
|
|
|
if (json.Code == 0) {
|
|
|
that.Toast('短信验证码已发送', 'success');
|
|
|
that.calcTime();
|
|
|
} else {
|
|
|
- that.$message.error(json.Memo);
|
|
|
+ that.Toast(json.Memo);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -189,27 +223,28 @@
|
|
|
let that = this;
|
|
|
let param = {
|
|
|
token: localStorage.token,
|
|
|
+ width: 100,
|
|
|
+ height: 30,
|
|
|
+ noiseCount: 10,
|
|
|
+ length: 4,
|
|
|
+ source: 123456789,
|
|
|
};
|
|
|
let postdata = qs.stringify(param);
|
|
|
- testPic(postdata).then(res => {
|
|
|
+ GenVerifyPic(postdata).then(res => {
|
|
|
let json = res;
|
|
|
- if (json.Code == 0) {
|
|
|
- that.valImgSrc = json.pic;
|
|
|
- that.valImgId = json.id;
|
|
|
- } else {
|
|
|
- that.$message.error(json.Memo);
|
|
|
- }
|
|
|
+ that.valImgSrc = json.Pic;
|
|
|
+ that.valImgId = json.Id;
|
|
|
})
|
|
|
},
|
|
|
// pwd登录
|
|
|
pwdLoginBtn() {
|
|
|
let that = this;
|
|
|
let phone = this.login.phone;
|
|
|
- let uservalid = this.login.uservalid;
|
|
|
+ let userpwd = this.login.userpwd;
|
|
|
// 重置验证码超时
|
|
|
that.overtime = new Date();
|
|
|
if (!that.globalValid(phone, 10, 12, '手机号', that)) return;
|
|
|
- if (!that.globalValid(uservalid, 3, 5, '短信验证码', that)) return;
|
|
|
+ if (!that.globalValid(userpwd, 5, 7, '短信验证码', that)) return;
|
|
|
this.loginInfo();
|
|
|
},
|
|
|
// 校验内容长度
|
|
|
@@ -232,39 +267,37 @@
|
|
|
return true
|
|
|
}
|
|
|
},
|
|
|
- // pwd登陆
|
|
|
+ // pwd登陆
|
|
|
loginInfo: function () {
|
|
|
const that = this;
|
|
|
- let url = headapi + 'v1/Auth/SignIn';
|
|
|
- let username = this.login.username;
|
|
|
- let userpwd = this.login.userpwd;
|
|
|
- let uservalid = this.login.uservalid;
|
|
|
- let picId = this.picId;
|
|
|
let current = new Date();
|
|
|
let betweenTime = current - that.overtime;
|
|
|
let s = 120;
|
|
|
if (betweenTime > s * 1000) {
|
|
|
that.changeValImg();
|
|
|
- that.$message.error('The verification code has timed out. Please re-enter');
|
|
|
+ that.$message.error('验证码已超时,请重新输入');
|
|
|
return false
|
|
|
}
|
|
|
let param = {
|
|
|
- 'verifyName': username,
|
|
|
- 'verifyCode': userpwd,
|
|
|
- 'picId': picId,
|
|
|
- 'picCode': uservalid,
|
|
|
- 'src': 'pc'
|
|
|
+ phone: that.login.phone,
|
|
|
+ code: that.login.userpwd,
|
|
|
+ channel: 3
|
|
|
};
|
|
|
let postdata = qs.stringify(param);
|
|
|
- testSelect(postdata).then(res => {
|
|
|
- let json = res;
|
|
|
- if (json.Code == 0) {
|
|
|
- localStorage.token = json.Rs.token;
|
|
|
- that.getUserInfo(json.Rs.token);
|
|
|
+ PhoneSignIn(postdata).then(res => {
|
|
|
+ if (res.Code == 0) {
|
|
|
+ that.res = res.Rs;
|
|
|
+ localStorage.userName = username;
|
|
|
+ localStorage.token = res.Rs.token;
|
|
|
+ that.$router.push({path: '/'});
|
|
|
} else {
|
|
|
- that.Toast(json.Memo + ',错误码:' + json.Code);
|
|
|
- that.getValImgSrc();//重置验证码
|
|
|
- that.clearLogin();
|
|
|
+ if (res.Code == 10005) {
|
|
|
+ that.$refs.userpwd.value = '';
|
|
|
+ that.Toast( '密码错误,请重新输入');
|
|
|
+ } else {
|
|
|
+ that.Toast( res.Memo + ',错误代码:' + res.Code);
|
|
|
+ that.form.valid = '';
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -388,7 +421,7 @@
|
|
|
position: relative;
|
|
|
float: right;
|
|
|
/*bottom: 54px;*/
|
|
|
- width: 121px;
|
|
|
+ width: 100px;
|
|
|
height: 50px;
|
|
|
background: #eee;
|
|
|
}
|
|
|
@@ -464,7 +497,7 @@
|
|
|
}
|
|
|
|
|
|
#getValidSms {
|
|
|
- width: 121px;
|
|
|
+ width: 100px;
|
|
|
height: 50px;
|
|
|
background: #fff;
|
|
|
border: 1px solid #fff;
|
|
|
@@ -474,8 +507,8 @@
|
|
|
float: right;
|
|
|
text-align: center;
|
|
|
color: #E75296;
|
|
|
- line-height: 50px;
|
|
|
- font-size: 16px;
|
|
|
+ line-height: 20px;
|
|
|
+ font-size: 12px;
|
|
|
}
|
|
|
|
|
|
#login .login_valid {
|
|
|
@@ -487,51 +520,64 @@
|
|
|
width: 173px;
|
|
|
float: left;
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 640px) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 480px) {
|
|
|
#login .login_valid {
|
|
|
width: 195px;
|
|
|
}
|
|
|
+
|
|
|
#login .login_pwd {
|
|
|
width: 195px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 415px) {
|
|
|
#login .login_valid {
|
|
|
width: 205px;
|
|
|
}
|
|
|
+
|
|
|
#login .login_pwd {
|
|
|
width: 205px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 400px) {
|
|
|
|
|
|
#login .login_valid {
|
|
|
width: 195px;
|
|
|
}
|
|
|
+
|
|
|
#login .login_pwd {
|
|
|
width: 195px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 375px) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 360px) {
|
|
|
#login .login_valid {
|
|
|
width: 160px;
|
|
|
}
|
|
|
+
|
|
|
#login .login_pwd {
|
|
|
width: 160px;
|
|
|
}
|
|
|
+
|
|
|
#getValidSms {
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (max-width: 320px) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@media only screen and (min-width: 641px) {
|
|
|
|
|
|
}
|