|
1 | 1 | <template>
|
2 | 2 | <div class="login-container">
|
3 |
| - <el-form autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left" label-width="0px" |
4 |
| - class="card-box login-form"> |
| 3 | + <el-form class="card-box login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm" label-position="left"> |
5 | 4 | <h3 class="title">系统登录</h3>
|
6 |
| - <el-form-item prop="email"> |
7 |
| - <span class="svg-container"><icon-svg icon-class="jiedianyoujian"></icon-svg></span> |
8 |
| - <el-input name="email" type="text" v-model="loginForm.email" autoComplete="on" placeholder="邮箱"></el-input> |
| 5 | + |
| 6 | + <el-form-item prop="username"> |
| 7 | + <span class="svg-container svg-container_login"> |
| 8 | + <icon-svg icon-class="yonghuming" /> |
| 9 | + </span> |
| 10 | + <el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="邮箱" /> |
9 | 11 | </el-form-item>
|
| 12 | + |
10 | 13 | <el-form-item prop="password">
|
11 |
| - <span class="svg-container"><icon-svg icon-class="mima"></icon-svg></span> |
12 |
| - <el-input name="password" type="password" @keyup.enter.native="handleLogin" v-model="loginForm.password" autoComplete="on" |
13 |
| - placeholder="密码"></el-input> |
| 14 | + <span class="svg-container"> |
| 15 | + <icon-svg icon-class="mima" /> |
| 16 | + </span> |
| 17 | + <el-input name="password" :type="pwdType" @keyup.enter.native="handleLogin" v-model="loginForm.password" autoComplete="on" |
| 18 | + placeholder="密码" /> |
| 19 | + <span class='show-pwd' @click='showPwd'><icon-svg icon-class="yanjing" /></span> |
14 | 20 | </el-form-item>
|
15 |
| - <el-form-item> |
16 |
| - <el-button type="primary" style="width:100%;" :loading="loading" @click.native.prevent="handleLogin"> |
17 |
| - 登录 |
18 |
| - </el-button> |
19 |
| - </el-form-item> |
20 |
| - < div class= 'tips'>admin账号为: [email protected] 密码随便填</ div> |
21 |
| - < div class= 'tips'>editor账号: [email protected] 密码随便填</ div> |
| 21 | + |
| 22 | + <el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">登录</el-button> |
| 23 | + |
| 24 | + <div class='tips'>账号:admin 密码随便填</div> |
| 25 | + <div class='tips'>账号:editor 密码随便填</div> |
22 | 26 | </el-form>
|
23 | 27 |
|
24 | 28 | <el-dialog title="第三方验证" :visible.sync="showDialog">
|
25 | 29 | 邮箱登录成功,请选择第三方验证
|
26 |
| - <social-sign></social-sign> |
| 30 | + <social-sign /> |
27 | 31 | </el-dialog>
|
28 | 32 |
|
29 | 33 | </div>
|
30 | 34 | </template>
|
31 | 35 |
|
32 | 36 | <script>
|
33 |
| - import { isWscnEmail } from 'utils/validate'; |
34 |
| - import socialSign from './socialsignin'; |
| 37 | + import { isvalidUsername } from 'utils/validate' |
| 38 | + import socialSign from './socialsignin' |
35 | 39 |
|
36 | 40 | export default {
|
37 | 41 | components: { socialSign },
|
38 | 42 | name: 'login',
|
39 | 43 | data() {
|
40 |
| - const validateEmail = (rule, value, callback) => { |
41 |
| - if (!isWscnEmail(value)) { |
42 |
| - callback(new Error('请输入正确的合法邮箱')); |
| 44 | + const validateUsername = (rule, value, callback) => { |
| 45 | + if (!isvalidUsername(value)) { |
| 46 | + callback(new Error('请输入正确的用户名')) |
43 | 47 | } else {
|
44 |
| - callback(); |
| 48 | + callback() |
45 | 49 | }
|
46 |
| - }; |
47 |
| - const validatePass = (rule, value, callback) => { |
| 50 | + } |
| 51 | + const validatePassword = (rule, value, callback) => { |
48 | 52 | if (value.length < 6) {
|
49 |
| - callback(new Error('密码不能小于6位')); |
| 53 | + callback(new Error('密码不能小于6位')) |
50 | 54 | } else {
|
51 |
| - callback(); |
| 55 | + callback() |
52 | 56 | }
|
53 |
| - }; |
| 57 | + } |
54 | 58 | return {
|
55 | 59 | loginForm: {
|
56 |
| - email: 'admin@wallstreetcn.com', |
57 |
| - password: '' |
| 60 | + username: 'admin', |
| 61 | + password: '1111111' |
58 | 62 | },
|
59 | 63 | loginRules: {
|
60 |
| - email: [ |
61 |
| - { required: true, trigger: 'blur', validator: validateEmail } |
62 |
| - ], |
63 |
| - password: [ |
64 |
| - { required: true, trigger: 'blur', validator: validatePass } |
65 |
| - ] |
| 64 | + username: [{ required: true, trigger: 'blur', validator: validateUsername }], |
| 65 | + password: [{ required: true, trigger: 'blur', validator: validatePassword }] |
66 | 66 | },
|
| 67 | + pwdType: 'password', |
67 | 68 | loading: false,
|
68 | 69 | showDialog: false
|
69 | 70 | }
|
70 | 71 | },
|
71 | 72 | methods: {
|
| 73 | + showPwd() { |
| 74 | + if (this.pwdType === 'password') { |
| 75 | + this.pwdType = '' |
| 76 | + } else { |
| 77 | + this.pwdType = 'password' |
| 78 | + } |
| 79 | + }, |
72 | 80 | handleLogin() {
|
73 | 81 | this.$refs.loginForm.validate(valid => {
|
74 | 82 | if (valid) {
|
75 |
| - this.loading = true; |
76 |
| - this.$store.dispatch('LoginByEmail', this.loginForm).then(() => { |
77 |
| - this.loading = false; |
78 |
| - this.$router.push({ path: '/' }); |
79 |
| - // this.showDialog = true; |
| 83 | + this.loading = true |
| 84 | + this.$store.dispatch('LoginByUsername', this.loginForm).then(() => { |
| 85 | + this.loading = false |
| 86 | + this.$router.push({ path: '/' }) |
| 87 | + // this.showDialog = true |
80 | 88 | }).catch(() => {
|
81 |
| - this.loading = false; |
82 |
| - }); |
| 89 | + this.loading = false |
| 90 | + }) |
83 | 91 | } else {
|
84 |
| - console.log('error submit!!'); |
85 |
| - return false; |
| 92 | + console.log('error submit!!') |
| 93 | + return false |
86 | 94 | }
|
87 |
| - }); |
| 95 | + }) |
88 | 96 | },
|
89 | 97 | afterQRScan() {
|
90 |
| - // const hash = window.location.hash.slice(1); |
91 |
| - // const hashObj = getQueryObject(hash); |
92 |
| - // const originUrl = window.location.origin; |
93 |
| - // history.replaceState({}, '', originUrl); |
| 98 | + // const hash = window.location.hash.slice(1) |
| 99 | + // const hashObj = getQueryObject(hash) |
| 100 | + // const originUrl = window.location.origin |
| 101 | + // history.replaceState({}, '', originUrl) |
94 | 102 | // const codeMap = {
|
95 | 103 | // wechat: 'code',
|
96 | 104 | // tencent: 'code'
|
97 |
| - // }; |
98 |
| - // const codeName = hashObj[codeMap[this.auth_type]]; |
| 105 | + // } |
| 106 | + // const codeName = hashObj[codeMap[this.auth_type]] |
99 | 107 | // if (!codeName) {
|
100 |
| - // alert('第三方登录失败'); |
| 108 | + // alert('第三方登录失败') |
101 | 109 | // } else {
|
102 | 110 | // this.$store.dispatch('LoginByThirdparty', codeName).then(() => {
|
103 |
| - // this.$router.push({ path: '/' }); |
104 |
| - // }); |
| 111 | + // this.$router.push({ path: '/' }) |
| 112 | + // }) |
105 | 113 | // }
|
106 | 114 | }
|
107 | 115 | },
|
108 | 116 | created() {
|
109 |
| - // window.addEventListener('hashchange', this.afterQRScan); |
| 117 | + // window.addEventListener('hashchange', this.afterQRScan) |
110 | 118 | },
|
111 | 119 | destroyed() {
|
112 |
| - // window.removeEventListener('hashchange', this.afterQRScan); |
| 120 | + // window.removeEventListener('hashchange', this.afterQRScan) |
113 | 121 | }
|
114 | 122 | }
|
115 | 123 | </script>
|
|
119 | 127 | .tips {
|
120 | 128 | font-size: 14px;
|
121 | 129 | color: #fff;
|
122 |
| - margin-bottom: 5px; |
| 130 | + margin-bottom: 10px; |
123 | 131 | }
|
124 | 132 |
|
125 | 133 | .login-container {
|
|
147 | 155 | .svg-container {
|
148 | 156 | padding: 6px 5px 6px 15px;
|
149 | 157 | color: #889aa4;
|
| 158 | + vertical-align: middle; |
| 159 | + width: 30px; |
| 160 | + display: inline-block; |
| 161 | + &_login{ |
| 162 | + font-size:20px; |
| 163 | + } |
150 | 164 | }
|
151 | 165 | .title {
|
152 | 166 | font-size: 26px;
|
|
170 | 184 | border-radius: 5px;
|
171 | 185 | color: #454545;
|
172 | 186 | }
|
173 |
| - .forget-pwd { |
174 |
| - color: #fff; |
| 187 | + .show-pwd{ |
| 188 | + position: absolute; |
| 189 | + right: 10px; |
| 190 | + top: 7px; |
| 191 | + font-size: 16px; |
| 192 | + color: #889aa4; |
| 193 | + cursor: pointer; |
175 | 194 | }
|
176 | 195 | }
|
177 | 196 | </style>
|
0 commit comments