|
@@ -66,54 +66,54 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import Cookies from "js-cookie";
|
|
|
+ import Cookies from 'js-cookie';
|
|
|
import {
|
|
|
mapActions
|
|
|
- } from "vuex";
|
|
|
+ } from 'vuex';
|
|
|
import {
|
|
|
validUsername,
|
|
|
isLoginName
|
|
|
- } from "@/utils/validate";
|
|
|
+ } from '@/utils/validate';
|
|
|
import {
|
|
|
getVerifyCode,
|
|
|
getCheckInfo,
|
|
|
getlogin
|
|
|
} from '@/api/user'
|
|
|
- import SIdentify from "./sidentify";
|
|
|
+ import SIdentify from './sidentify';
|
|
|
export default {
|
|
|
- name: "Login",
|
|
|
+ name: 'Login',
|
|
|
components: {
|
|
|
SIdentify,
|
|
|
},
|
|
|
data() {
|
|
|
const validateUsername = (rule, value, callback) => {
|
|
|
if (!validUsername(value)) {
|
|
|
- callback(new Error("请输入正确的账号"));
|
|
|
+ callback(new Error('请输入正确的账号'));
|
|
|
} else {
|
|
|
callback();
|
|
|
}
|
|
|
};
|
|
|
const validatePassword = (rule, value, callback) => {
|
|
|
if (value.length < 6) {
|
|
|
- callback(new Error("请输入正确的密码"));
|
|
|
+ callback(new Error('请输入正确的密码'));
|
|
|
} else {
|
|
|
callback();
|
|
|
}
|
|
|
};
|
|
|
const validateCode = (rule, value, callback) => {
|
|
|
if (this.identifyCode !== value) {
|
|
|
- this.loginForm.code = "";
|
|
|
+ this.loginForm.code = '';
|
|
|
this.refreshCode();
|
|
|
- callback(new Error("请输入正确的验证码"));
|
|
|
+ callback(new Error('请输入正确的验证码'));
|
|
|
} else {
|
|
|
callback();
|
|
|
}
|
|
|
};
|
|
|
const checkCode = (rule, value, callback) => {
|
|
|
if (this.identifyCode !== value || value.length != 6) {
|
|
|
- this.loginForm.checkCode = "";
|
|
|
+ this.loginForm.checkCode = '';
|
|
|
this.refreshCode();
|
|
|
- callback(new Error("请输入正确的手机验证码"));
|
|
|
+ callback(new Error('请输入正确的手机验证码'));
|
|
|
} else {
|
|
|
callback();
|
|
|
}
|
|
@@ -121,49 +121,49 @@
|
|
|
return {
|
|
|
isDebugLogin: false,
|
|
|
loginForm: {
|
|
|
- username: "",
|
|
|
- password: "",
|
|
|
- code: "",
|
|
|
+ username: '',
|
|
|
+ password: '',
|
|
|
+ code: '',
|
|
|
},
|
|
|
- identifyCodes: "1234567890",
|
|
|
- identifyCode: "",
|
|
|
+ identifyCodes: '1234567890',
|
|
|
+ identifyCode: '',
|
|
|
loginRules: {
|
|
|
username: [{
|
|
|
required: true,
|
|
|
- trigger: "blur",
|
|
|
- message: "请输入账号",
|
|
|
+ trigger: 'blur',
|
|
|
+ message: '请输入账号',
|
|
|
},
|
|
|
{
|
|
|
min: 11,
|
|
|
max: 11,
|
|
|
- message: "请输入11位手机号",
|
|
|
- trigger: "blur",
|
|
|
+ message: '请输入11位手机号',
|
|
|
+ trigger: 'blur',
|
|
|
},
|
|
|
{
|
|
|
validator: isLoginName,
|
|
|
- trigger: "blur",
|
|
|
+ trigger: 'blur',
|
|
|
},
|
|
|
],
|
|
|
password: [{
|
|
|
required: true,
|
|
|
- message: "请输入密码",
|
|
|
- trigger: "blur",
|
|
|
+ message: '请输入密码',
|
|
|
+ trigger: 'blur',
|
|
|
},
|
|
|
{
|
|
|
min: 1,
|
|
|
max: 100,
|
|
|
- message: "长度在1-100字符之间",
|
|
|
- trigger: "blur",
|
|
|
+ message: '长度在1-100字符之间',
|
|
|
+ trigger: 'blur',
|
|
|
},
|
|
|
],
|
|
|
code: [{
|
|
|
required: true,
|
|
|
- message: "请输入验证码",
|
|
|
- trigger: "blur",
|
|
|
+ message: '请输入验证码',
|
|
|
+ trigger: 'blur',
|
|
|
},
|
|
|
{
|
|
|
validator: validateCode,
|
|
|
- trigger: "blur",
|
|
|
+ trigger: 'blur',
|
|
|
},
|
|
|
],
|
|
|
// checkCode: [{
|
|
@@ -181,21 +181,23 @@
|
|
|
},
|
|
|
loading: false,
|
|
|
rememberMe: true,
|
|
|
- passwordType: "password",
|
|
|
+ passwordType: 'password',
|
|
|
redirect: undefined,
|
|
|
- codeText: "获取验证码",
|
|
|
+ codeText: '获取验证码',
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
$route: {
|
|
|
handler: function(route) {
|
|
|
+ console.log('route',route)
|
|
|
this.redirect = route.query && route.query.redirect;
|
|
|
+ console.log('this.redirect,this.redirect')
|
|
|
},
|
|
|
immediate: true,
|
|
|
},
|
|
|
isDebugLogin(v) {
|
|
|
if (v) {
|
|
|
- this.loginForm.password = "123";
|
|
|
+ this.loginForm.password = '123';
|
|
|
this.refreshCode();
|
|
|
}
|
|
|
},
|
|
@@ -222,12 +224,12 @@
|
|
|
checkClick() { //获取验证码
|
|
|
let that = this;
|
|
|
if (that.identifyCode !== that.loginForm.code) {
|
|
|
- this.loginForm.code = "";
|
|
|
- that.$message.error("请输入正确的图片验证码")
|
|
|
+ this.loginForm.code = '';
|
|
|
+ that.$message.error('请输入正确的图片验证码')
|
|
|
return
|
|
|
}
|
|
|
if (/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(that.loginForm.username)) {
|
|
|
- if (that.codeText == "获取验证码" || that.codeText == "重新发送") {
|
|
|
+ if (that.codeText == '获取验证码' || that.codeText == '重新发送') {
|
|
|
getVerifyCode({
|
|
|
phone: that.loginForm.username,
|
|
|
identification: 3
|
|
@@ -238,7 +240,7 @@
|
|
|
if (that.codeText > 0) {
|
|
|
that.codeText -= 1;
|
|
|
} else {
|
|
|
- that.codeText = "重新发送";
|
|
|
+ that.codeText = '重新发送';
|
|
|
}
|
|
|
}, 1000);
|
|
|
} else {
|
|
@@ -247,15 +249,15 @@
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- that.$message.error("请输入正确的手机")
|
|
|
+ that.$message.error('请输入正确的手机')
|
|
|
}
|
|
|
},
|
|
|
- ...mapActions("user", ["login"]),
|
|
|
+ ...mapActions('user', ['login']),
|
|
|
randomNum(min, max) {
|
|
|
return Math.floor(Math.random() * (max - min) + min);
|
|
|
},
|
|
|
refreshCode() {
|
|
|
- this.identifyCode = "";
|
|
|
+ this.identifyCode = '';
|
|
|
this.makeCode(this.identifyCodes, 4);
|
|
|
},
|
|
|
makeCode(o, l) {
|
|
@@ -265,10 +267,10 @@
|
|
|
}
|
|
|
},
|
|
|
showPwd() {
|
|
|
- if (this.passwordType === "password") {
|
|
|
- this.passwordType = "";
|
|
|
+ if (this.passwordType === 'password') {
|
|
|
+ this.passwordType = '';
|
|
|
} else {
|
|
|
- this.passwordType = "password";
|
|
|
+ this.passwordType = 'password';
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.password.focus();
|
|
@@ -333,38 +335,38 @@
|
|
|
let that = this
|
|
|
this.$refs.loginForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- this.loginForm.companyName = "黑龙江中天昊元贸易有限公司";
|
|
|
+ this.loginForm.companyName = '黑龙江中天昊元贸易有限公司';
|
|
|
this.loading = true;
|
|
|
// this.$store.dispatch('user/login', this.loginForm)
|
|
|
// const res = await this.$store.dispatch('user/login', this.loginForm)、
|
|
|
const res = await getlogin({
|
|
|
loginName: this.loginForm.username,
|
|
|
loginPassword: this.loginForm.password,
|
|
|
- compId: "2710b21efc1e4393930c5dc800010dc4",
|
|
|
+ compId: '2710b21efc1e4393930c5dc800010dc4',
|
|
|
})
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
const res1 = await this.$store.dispatch('user/login', this.loginForm)
|
|
|
localStorage.setItem('UserInfo', JSON.stringify(res1.data))
|
|
|
- localStorage.setItem("ws_login_type", 2);
|
|
|
- Cookies.set("ws_login_companyShortName", this.loginForm.companyName, {
|
|
|
+ localStorage.setItem('ws_login_type', 2);
|
|
|
+ Cookies.set('ws_login_companyShortName', this.loginForm.companyName, {
|
|
|
expires: 365,
|
|
|
});
|
|
|
- Cookies.set("ws_login_account", this.loginForm.username, {
|
|
|
+ Cookies.set('ws_login_account', this.loginForm.username, {
|
|
|
expires: 365,
|
|
|
});
|
|
|
if (this.rememberMe) {
|
|
|
- Cookies.set("ws_login_pwd", this.loginForm.password, {
|
|
|
+ Cookies.set('ws_login_pwd', this.loginForm.password, {
|
|
|
expires: 365,
|
|
|
});
|
|
|
- Cookies.set("ws_login_rememberMe", 1, {
|
|
|
+ Cookies.set('ws_login_rememberMe', 1, {
|
|
|
expires: 365,
|
|
|
});
|
|
|
} else {
|
|
|
- Cookies.remove("ws_login_companyShortName");
|
|
|
- Cookies.remove("ws_login_account");
|
|
|
- Cookies.remove("ws_login_pwd");
|
|
|
- Cookies.set("ws_login_rememberMe", 0, {
|
|
|
+ Cookies.remove('ws_login_companyShortName');
|
|
|
+ Cookies.remove('ws_login_account');
|
|
|
+ Cookies.remove('ws_login_pwd');
|
|
|
+ Cookies.set('ws_login_rememberMe', 0, {
|
|
|
expires: 365,
|
|
|
});
|
|
|
}
|
|
@@ -372,7 +374,7 @@
|
|
|
if (redirect) {
|
|
|
this.$router.push(redirect);
|
|
|
} else {
|
|
|
- this.$router.push("/");
|
|
|
+ this.$router.push('/');
|
|
|
}
|
|
|
} else {
|
|
|
this.$message.error(response.message)
|
|
@@ -388,7 +390,7 @@
|
|
|
// this.loading = false
|
|
|
// })
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
+ console.log('error submit!!');
|
|
|
return false;
|
|
|
}
|
|
|
});
|