Skip to content

Commit

Permalink
登录逻辑修改
Browse files Browse the repository at this point in the history
  • Loading branch information
macrozheng committed Apr 9, 2019
1 parent 9cf474a commit 6b86a9a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/utils/support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Cookies from "js-cookie";
const SupportKey='supportKey';
export const SupportUrl='https://e.coding.net/?utm_source=macrozheng&utm_medium=banner&utm_campaign=march2019';
export function getSupport() {
return Cookies.get(SupportKey)
}

export function setSupport(isSupport) {
return Cookies.set(SupportKey, isSupport,{ expires: 3 })
}
30 changes: 28 additions & 2 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,22 @@
</el-form>
</el-card>
<img :src="login_center_bg" class="login-center-layout">
<el-dialog
title="特别赞助"
:visible.sync="dialogVisible"
width="30%">
<span>mall项目已由CODING特别赞助,点击去支持,页面加载完后点击<span class="color-main font-medium">免费试用</span>按钮即可完成支持,谢谢!</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogCancel">残忍拒绝</el-button>
<el-button type="primary" @click="dialogConfirm">去支持</el-button>
</span>
</el-dialog>
</div>
</template>

<script>
import {isvalidUsername} from '@/utils/validate';
import {setSupport,getSupport,SupportUrl} from '@/utils/support';
import login_center_bg from '@/assets/images/login_center_bg.png'
export default {
Expand All @@ -71,15 +82,16 @@
return {
loginForm: {
username: 'admin',
password: '123456'
password: '123456',
},
loginRules: {
username: [{required: true, trigger: 'blur', validator: validateUsername}],
password: [{required: true, trigger: 'blur', validator: validatePass}]
},
loading: false,
pwdType: 'password',
login_center_bg
login_center_bg,
dialogVisible:false
}
},
methods: {
Expand All @@ -93,6 +105,11 @@
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
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;
Expand All @@ -105,6 +122,15 @@
return false
}
})
},
dialogConfirm(){
this.dialogVisible =false;
setSupport(true);
window.location.href=SupportUrl;
},
dialogCancel(){
this.dialogVisible = false;
setSupport(false);
}
}
}
Expand Down

0 comments on commit 6b86a9a

Please sign in to comment.