|
11 | 11 | fieldDecoratorId="username"
|
12 | 12 | :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入帐户名或邮箱地址' }, { validator: this.handleUsernameOrEmail }], validateTrigger: 'blur'}"
|
13 | 13 | >
|
14 |
| - <a-input size="large" type="text" v-model="formLogin.username" placeholder="帐户名或邮箱地址 / admin"> |
| 14 | + <a-input size="large" type="text" placeholder="帐户名或邮箱地址 / admin"> |
15 | 15 | <a-icon slot="prefix" type='user' :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
16 | 16 | </a-input>
|
17 | 17 | </a-form-item>
|
18 | 18 |
|
19 | 19 | <a-form-item
|
20 | 20 | fieldDecoratorId="password"
|
21 | 21 | :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入密码' }], validateTrigger: 'blur'}">
|
22 |
| - <a-input size="large" type="password" v-model="formLogin.password" placeholder="密码 / admin"> |
| 22 | + <a-input size="large" type="password" placeholder="密码 / admin"> |
23 | 23 | <a-icon slot="prefix" type='lock' :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
24 | 24 | </a-input>
|
25 | 25 | </a-form-item>
|
|
28 | 28 | <a-form-item
|
29 | 29 | fieldDecoratorId="mobile"
|
30 | 30 | :fieldDecoratorOptions="{rules: [{ required: true, pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号' }], validateTrigger: 'blur'}">
|
31 |
| - <a-input size="large" type="text" v-model="formLogin.mobile" placeholder="手机号"> |
| 31 | + <a-input size="large" type="text" placeholder="手机号"> |
32 | 32 | <a-icon slot="prefix" type='mobile' :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
33 | 33 | </a-input>
|
34 | 34 | </a-form-item>
|
|
38 | 38 | <a-form-item
|
39 | 39 | fieldDecoratorId="captcha"
|
40 | 40 | :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入验证码' }], validateTrigger: 'blur'}">
|
41 |
| - <a-input size="large" type="text" v-model="formLogin.captcha" placeholder="验证码"> |
| 41 | + <a-input size="large" type="text" placeholder="验证码"> |
42 | 42 | <a-icon slot="prefix" type='mail' :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
43 | 43 | </a-input>
|
44 | 44 | </a-form-item>
|
|
48 | 48 | class="getCaptcha"
|
49 | 49 | :disabled="state.smsSendBtn"
|
50 | 50 | @click.stop.prevent="getCaptcha"
|
51 |
| - v-text="!state.smsSendBtn&&'获取验证码'||(state.time+' s')"></a-button> |
| 51 | + v-text="!state.smsSendBtn && '获取验证码' || (state.time+' s')"></a-button> |
52 | 52 | </a-col>
|
53 | 53 | </a-row>
|
54 | 54 | </a-tab-pane>
|
|
153 | 153 | let that = this
|
154 | 154 | let flag = false
|
155 | 155 |
|
| 156 | + let loginParams = { |
| 157 | + remember_me: that.formLogin.rememberMe |
| 158 | + }; |
| 159 | +
|
| 160 | + // 使用账户密码登陆 |
156 | 161 | if (that.customActiveKey === 'tab1') {
|
157 |
| - that.form.validateFields([ 'username', 'password' ], { force: true }, (err) => { |
| 162 | + that.form.validateFields([ 'username', 'password' ], { force: true }, (err, values) => { |
158 | 163 | if (!err) {
|
159 | 164 | flag = true
|
| 165 | + loginParams[!that.loginType ? 'email' : 'username'] = values.username |
| 166 | + loginParams.password = md5(values.password) |
160 | 167 | }
|
161 | 168 | })
|
| 169 | + // 使用手机号登陆 |
162 | 170 | } else {
|
163 |
| - that.form.validateFields([ 'mobile', 'captcha' ], { force: true }, (err) => { |
| 171 | + that.form.validateFields([ 'mobile', 'captcha' ], { force: true }, (err, values) => { |
164 | 172 | if (!err) {
|
165 | 173 | flag = true
|
166 |
| - that.loginType = 2 // 登录类型修改为手机登录 |
| 174 | + loginParams = Object.assign(loginParams, values) |
167 | 175 | }
|
168 | 176 | })
|
169 | 177 | }
|
|
172 | 180 |
|
173 | 181 | that.loginBtn = true
|
174 | 182 |
|
175 |
| - let loginParams = { |
176 |
| - password: md5(that.formLogin.password), |
177 |
| - remember_me: that.formLogin.rememberMe |
178 |
| - }; |
179 |
| -
|
180 |
| - switch (that.loginType) { |
181 |
| - case 0: |
182 |
| - loginParams.email = that.formLogin.username |
183 |
| - break; |
184 |
| - case 1: |
185 |
| - loginParams.username = that.formLogin.username |
186 |
| - break; |
187 |
| - case 2: |
188 |
| - default: |
189 |
| - loginParams.mobile = that.formLogin.mobile |
190 |
| - loginParams.captcha = that.formLogin.captcha |
191 |
| - break; |
192 |
| - } |
193 |
| -
|
194 | 183 | that.Login(loginParams).then(() => {
|
195 | 184 | if (that.requiredTwoStepCaptcha) {
|
196 | 185 | that.stepCaptchaVisible = true
|
|
0 commit comments