|
@@ -1,23 +1,84 @@
|
|
|
<template>
|
|
|
- <view class="u-line-1">
|
|
|
- <u-icon name="photo-fill" color="#2979ff" size="28"></u-icon>
|
|
|
- <u-input v-model="value" type="number" placeholder="请输入手机号" :border="true" clearable />
|
|
|
+ <view class="u-page">
|
|
|
+ <u--form ref="loginForm" :model="form" :rules="rules" errorType="toast">
|
|
|
+ <u-row justify="center">
|
|
|
+ <u-col span="9">
|
|
|
+ <u-form-item prop="username">
|
|
|
+ <u-input v-model="form.username" type="number" placeholder="请输入手机号" prefixIcon="account"
|
|
|
+ :clearable="true" />
|
|
|
+ </u-form-item>
|
|
|
+ </u-col>
|
|
|
+ </u-row>
|
|
|
+
|
|
|
+ <u-row justify="center">
|
|
|
+ <u-col span="9">
|
|
|
+ <u-form-item prop="password">
|
|
|
+ <u-input v-model="form.password" type="password" placeholder="请输入密码" prefixIcon="lock" :clearable="true" />
|
|
|
+ </u-form-item>
|
|
|
+ </u-col>
|
|
|
+ </u-row>
|
|
|
+
|
|
|
+ <u-row justify="center">
|
|
|
+ <u-col span="9">
|
|
|
+ <u-form-item>
|
|
|
+ <u-button type="primary" text="登录并绑定微信" @click="submitForm"></u-button>
|
|
|
+ <u-text type="info" align="center" text="微信一键登录" @click="quickLogin"></u-text>
|
|
|
+ </u-form-item>
|
|
|
+ </u-col>
|
|
|
+ </u-row>
|
|
|
+ </u--form>
|
|
|
+
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import { setToken } from '@/common/auth.js'
|
|
|
+ import { toast } from '@/common/common.js'
|
|
|
+ import { login } from '@/api/login.js'
|
|
|
+
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- value: '',
|
|
|
+ form: {
|
|
|
+ username: '15143018065',
|
|
|
+ password: 'sckj@2022',
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ username: [
|
|
|
+ { required: true, message: '手机号不能为空', trigger: ['blur', 'change'] },
|
|
|
+ { len: 11, message: '手机号应为11位数字', trigger: ['blur', 'change'] },
|
|
|
+ ],
|
|
|
+ password: [
|
|
|
+ { required: true, message: '密码不能为空', trigger: ['blur', 'change'] },
|
|
|
+ { min: 6, message: '密码长度应大于6位', trigger: ['blur', 'change'] },
|
|
|
+ ]
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
- methods: {
|
|
|
+ onReady() {
|
|
|
+ this.$refs.loginForm.setRules(this.rules)
|
|
|
+ },
|
|
|
|
|
|
+ methods: {
|
|
|
+ submitForm() {
|
|
|
+ this.$refs.loginForm.validate().then(() => {
|
|
|
+ login(this.form).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const { data } = res
|
|
|
+ setToken(data.access_token)
|
|
|
+ uni.reLaunch({ url: '/pages/index/index' })
|
|
|
+ } else {
|
|
|
+ toast(res.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+ quickLogin() {
|
|
|
+ console.log('quick login');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
- @import "uview-ui/index.scss";
|
|
|
</style>
|