提交 3a85031a authored 作者: 王鹏飞's avatar 王鹏飞

update login

上级 3eb4e76c
......@@ -8,7 +8,7 @@ const routes = [
{
name: 'login',
path: '/login',
component: () => import('@/views/Login.vue')
component: () => import('@/views/login/Login.vue')
},
// 首页
{
......
<template>
<div class="login-form account-login">
<div class="login-form__item">
<input
type="text"
class="login-input"
placeholder="手机/邮箱/用户名"
v-model="ruleForm.account"
/>
</div>
<div class="login-form__item">
<input
type="password"
class="login-input"
placeholder="密码"
v-model="ruleForm.password"
@keyup.enter="onSubmit"
/>
</div>
</div>
</template>
<script>
export default {
name: 'AccountLogin',
data() {
return {
ruleForm: {
account: '',
password: ''
}
}
},
methods: {
submit() {
if (!this.ruleForm.account) {
this.$notify('请输入手机/邮箱/用户名')
return false
} else if (!this.ruleForm.password) {
this.$notify('请输入密码')
return false
}
return true
}
}
}
</script>
<template>
<div class="login-form code-login">
<div class="login-form__item">
<input
type="text"
class="login-input"
placeholder="手机号"
v-model="ruleForm.account"
/>
</div>
<div class="login-form__item">
<input
type="password"
class="login-input"
placeholder="验证码"
v-model="ruleForm.password"
@keyup.enter="onSubmit"
/>
<countdown-button
@click.native="onSendCode"
ref="countdown"
></countdown-button>
</div>
</div>
</template>
<script>
import * as api from '@/api/account'
import CountdownButton from '@/components/CountdownButton'
export default {
name: 'CodeLogin',
components: { CountdownButton },
data() {
return {
ruleForm: {
account: '',
password: ''
}
}
},
methods: {
submit() {
if (!this.ruleForm.account) {
this.$notify('请输入手机/邮箱/用户名')
return false
} else if (!this.ruleForm.password) {
this.$notify('请输入密码')
return false
}
return true
},
// 发送验证码
onSendCode() {
this.$refs.form.validate('account').then(response => {
if (!response) {
// 开始倒计时
this.$refs['countdown'].start()
this.sendCodeRequest()
}
})
},
// 验证码
sendCodeRequest() {
api
.sendResetPasswordCode({ account: this.ruleForm.account })
.then(response => {
if (response.code === 0) {
this.$notify({ type: 'success', message: '验证码发送成功' })
} else {
// 停止计时
this.$refs['countdown'].stop()
this.$notify(response.msg)
}
})
.catch(error => {
// 停止计时
this.$refs['countdown'].stop()
error.response && this.$notify(error.response.data.message)
})
}
}
}
</script>
......@@ -49,6 +49,8 @@
import Cookies from 'js-cookie'
import * as api from '@/api/account'
// import AccountLogin from './AccountLogin.vue'
// import CodeLogin from './CodeLogin.vue'
import Password from './Password.vue'
export default {
......@@ -57,6 +59,7 @@ export default {
const UA = navigator.userAgent.toLowerCase()
return {
ruleForm: {
type: 1,
account: '',
password: '',
RememberMe: false
......@@ -87,7 +90,6 @@ export default {
// 登录
loginRequest() {
let data = Object.assign({}, this.ruleForm, {
type: 1,
service: 'https://h5.ezijing.com'
})
api
......@@ -101,10 +103,7 @@ export default {
},
// 绑定微信并登录
bindWechat() {
let data = Object.assign({}, this.ruleForm, {
unionid: this.unionid,
type: 1
})
let data = Object.assign({}, this.ruleForm, { unionid: this.unionid })
api
.bindWechat(data)
.then(response => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论