login4.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="login-box">
  3. <view class="text-center">
  4. <image src="/modules/common/static/images/login/logo.png" mode="widthFix" style="width: 500rpx"></image>
  5. </view>
  6. <view class="login-top"><view>欢迎回来!</view></view>
  7. <fs-form ref="loginRef" :model="loginModel">
  8. <fs-field class="radius" placeholder="请输入账号" v-model="loginModel.name">
  9. <template #before>
  10. <fs-icon type="icon-user" color="#666666"></fs-icon>
  11. </template>
  12. </fs-field>
  13. <fs-gutter height="40rpx" bgColor="#F6F7FB"></fs-gutter>
  14. <fs-field class="radius" placeholder="请输入密码" v-model="loginModel.password">
  15. <template #before>
  16. <fs-icon type="icon-password" color="#666666"></fs-icon>
  17. </template>
  18. </fs-field>
  19. <fs-gutter height="100rpx" bgColor="#F6F7FB"></fs-gutter>
  20. <fs-button full radius @click="handleLogin">登录</fs-button>
  21. </fs-form>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, reactive } from 'vue'
  26. import useForm from '@/hooks/useForm'
  27. import { useUserStore } from '@/stores/user'
  28. const user = useUserStore()
  29. const loginRules = {
  30. name: {
  31. required: true,
  32. message: '请输入账号'
  33. },
  34. password: {
  35. required: true,
  36. message: '请输入密码'
  37. }
  38. }
  39. const loginModel = reactive({
  40. name: '',
  41. password: ''
  42. })
  43. const loginRef = ref(null)
  44. const loginForm = useForm(loginRules, 'loginRef')
  45. const handleLogin = () => {
  46. loginForm.validate().then(() => {
  47. user
  48. .login('login', {
  49. ...loginModel
  50. })
  51. .then(res => {
  52. uni.navigateBack()
  53. })
  54. })
  55. }
  56. </script>
  57. <style>
  58. page {
  59. background-color: #f6f7fb;
  60. }
  61. </style>
  62. <style lang="scss" scoped>
  63. .login-box {
  64. padding: 30rpx;
  65. }
  66. .login-top {
  67. color: #041b3d;
  68. font-size: 24px;
  69. font-family: Source Han Sans SC;
  70. margin: 50rpx 0;
  71. &-sub {
  72. font-size: 18px;
  73. color: #b0b0b1;
  74. }
  75. }
  76. </style>