123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <view class="login-box">
- <view class="text-center">
- <image src="/modules/common/static/images/login/logo.png" mode="widthFix" style="width: 500rpx"></image>
- </view>
- <view class="login-top"><view>欢迎回来!</view></view>
- <fs-form ref="loginRef" :model="loginModel">
- <fs-field class="radius" placeholder="请输入账号" v-model="loginModel.name">
- <template #before>
- <fs-icon type="icon-user" color="#666666"></fs-icon>
- </template>
- </fs-field>
- <fs-gutter height="40rpx" bgColor="#F6F7FB"></fs-gutter>
- <fs-field class="radius" placeholder="请输入密码" v-model="loginModel.password">
- <template #before>
- <fs-icon type="icon-password" color="#666666"></fs-icon>
- </template>
- </fs-field>
- <fs-gutter height="100rpx" bgColor="#F6F7FB"></fs-gutter>
- <fs-button full radius @click="handleLogin">登录</fs-button>
- </fs-form>
- </view>
- </template>
- <script setup>
- import { ref, reactive } from 'vue'
- import useForm from '@/hooks/useForm'
- import { useUserStore } from '@/stores/user'
- const user = useUserStore()
- const loginRules = {
- name: {
- required: true,
- message: '请输入账号'
- },
- password: {
- required: true,
- message: '请输入密码'
- }
- }
- const loginModel = reactive({
- name: '',
- password: ''
- })
- const loginRef = ref(null)
- const loginForm = useForm(loginRules, 'loginRef')
- const handleLogin = () => {
- loginForm.validate().then(() => {
- user
- .login('login', {
- ...loginModel
- })
- .then(res => {
- uni.navigateBack()
- })
- })
- }
- </script>
- <style>
- page {
- background-color: #f6f7fb;
- }
- </style>
- <style lang="scss" scoped>
- .login-box {
- padding: 30rpx;
- }
- .login-top {
- color: #041b3d;
- font-size: 24px;
- font-family: Source Han Sans SC;
- margin: 50rpx 0;
- &-sub {
- font-size: 18px;
- color: #b0b0b1;
- }
- }
- </style>
|