2021-11-15 10:29:05 +08:00
|
|
|
<template>
|
|
|
|
|
<section class="login">
|
|
|
|
|
<u-form :model="form" ref="loginForm" label-width="140">
|
2021-11-15 15:53:44 +08:00
|
|
|
<u-form-item label="账号" prop="username">
|
|
|
|
|
<u-input v-model="form.username" placeholder="请输入手机号"/>
|
2021-11-15 10:29:05 +08:00
|
|
|
</u-form-item>
|
2021-11-15 15:53:44 +08:00
|
|
|
<u-form-item label="密码" prop="password">
|
|
|
|
|
<u-input type="password" v-model="form.password" placeholder="请输入密码"/>
|
2021-11-15 10:29:05 +08:00
|
|
|
</u-form-item>
|
|
|
|
|
</u-form>
|
|
|
|
|
<div bottom>
|
2021-11-15 15:53:44 +08:00
|
|
|
<u-button type="primary" @tap="handleLogin">登录</u-button>
|
2021-11-15 10:29:05 +08:00
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-11-15 15:53:44 +08:00
|
|
|
import {mapActions, mapMutations} from "vuex";
|
2021-11-15 10:29:05 +08:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "login",
|
|
|
|
|
inject: ['root'],
|
|
|
|
|
computed: {
|
|
|
|
|
rules() {
|
|
|
|
|
return {
|
2021-11-15 15:53:44 +08:00
|
|
|
username: [{required: true, message: "请输入 手机号"}],
|
|
|
|
|
password: [{required: true, message: "请输入 密码"}],
|
2021-11-15 10:29:05 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-11-15 15:53:44 +08:00
|
|
|
form: {}
|
2021-11-15 10:29:05 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-11-15 15:53:44 +08:00
|
|
|
...mapActions(['getToken']),
|
|
|
|
|
...mapMutations(['login']),
|
2021-11-15 10:29:05 +08:00
|
|
|
handleLogin() {
|
|
|
|
|
this.$refs.loginForm.validate(v => {
|
|
|
|
|
if (v) {
|
2021-11-15 15:53:44 +08:00
|
|
|
this.getToken(this.form).then(() => {
|
|
|
|
|
uni.navigateBack({})
|
|
|
|
|
})
|
2021-11-15 10:29:05 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.$nextTick(() => this.$refs.loginForm?.setRules(this.rules))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.login {
|
|
|
|
|
border-top: 1px solid #D4D4D4;
|
|
|
|
|
padding: 0 0 208px;
|
|
|
|
|
background: #F5F5F5;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
.vcode {
|
|
|
|
|
color: $uni-color-primary;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|