update login index.vue
This commit is contained in:
parent
de33b5ac1f
commit
dc76d42867
@ -7,3 +7,11 @@ export function getSupport() {
|
||||
export function setSupport(isSupport) {
|
||||
return Cookies.set(SupportKey, isSupport,{ expires: 3 })
|
||||
}
|
||||
|
||||
export function setCookie(key,value,expires) {
|
||||
return Cookies.set(key, value,{ expires: expires})
|
||||
}
|
||||
|
||||
export function getCookie(key) {
|
||||
return Cookies.get(key)
|
||||
}
|
||||
|
@ -36,10 +36,13 @@
|
||||
</span>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-bottom: 60px">
|
||||
<el-button style="width: 100%" type="primary" :loading="loading" @click.native.prevent="handleLogin">
|
||||
<el-form-item style="margin-bottom: 60px;text-align: center">
|
||||
<el-button style="width: 45%" type="primary" :loading="loading" @click.native.prevent="handleLogin">
|
||||
登录
|
||||
</el-button>
|
||||
<el-button style="width: 45%" type="primary" @click.native.prevent="handleTry">
|
||||
获取体验账号
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@ -51,7 +54,8 @@
|
||||
:center="true"
|
||||
width="30%">
|
||||
<div style="text-align: center">
|
||||
<span class="font-title-large">mall全套学习教程连载中<span class="color-main font-extra-large">关注公众号</span>第一时间获取</span>
|
||||
<span class="font-title-large"><span class="color-main font-extra-large">关注公众号</span>回复<span class="color-main font-extra-large">体验</span>获取体验账号</span>
|
||||
<br>
|
||||
<img src="http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/banner/qrcode_for_macrozheng_258.jpg" width="160" height="160" style="margin-top: 10px">
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
@ -63,7 +67,7 @@
|
||||
|
||||
<script>
|
||||
import {isvalidUsername} from '@/utils/validate';
|
||||
import {setSupport,getSupport} from '@/utils/support';
|
||||
import {setSupport,getSupport,setCookie,getCookie} from '@/utils/support';
|
||||
import login_center_bg from '@/assets/images/login_center_bg.png'
|
||||
|
||||
export default {
|
||||
@ -85,8 +89,8 @@
|
||||
};
|
||||
return {
|
||||
loginForm: {
|
||||
username: 'admin',
|
||||
password: '123456',
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
loginRules: {
|
||||
username: [{required: true, trigger: 'blur', validator: validateUsername}],
|
||||
@ -99,6 +103,16 @@
|
||||
supportDialogVisible:false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loginForm.username = getCookie("username");
|
||||
this.loginForm.password = getCookie("password");
|
||||
if(this.loginForm.username === undefined||this.loginForm.username==null||this.loginForm.username===''){
|
||||
this.loginForm.username = 'admin';
|
||||
}
|
||||
if(this.loginForm.password === undefined||this.loginForm.password==null){
|
||||
this.loginForm.password = '';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showPwd() {
|
||||
if (this.pwdType === 'password') {
|
||||
@ -110,14 +124,16 @@
|
||||
handleLogin() {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
if (valid) {
|
||||
let isSupport = getSupport();
|
||||
if(isSupport===undefined||isSupport==null){
|
||||
this.dialogVisible =true;
|
||||
return;
|
||||
}
|
||||
// let isSupport = getSupport();
|
||||
// if(isSupport===undefined||isSupport==null){
|
||||
// this.dialogVisible =true;
|
||||
// return;
|
||||
// }
|
||||
this.loading = true;
|
||||
this.$store.dispatch('Login', this.loginForm).then(() => {
|
||||
this.loading = false;
|
||||
setCookie("username",this.loginForm.username,15);
|
||||
setCookie("password",this.loginForm.password,15);
|
||||
this.$router.push({path: '/'})
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
@ -128,6 +144,9 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
handleTry(){
|
||||
this.dialogVisible =true
|
||||
},
|
||||
dialogConfirm(){
|
||||
this.dialogVisible =false;
|
||||
setSupport(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user