login5.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">
  7. <view>欢迎回来!</view>
  8. </view>
  9. <fs-form ref="loginRef" :model="loginModel">
  10. <fs-field class="radius" placeholder="请输入账号" v-model="loginModel.name">
  11. <template #before>
  12. <fs-icon type="icon-user" color="#666666"></fs-icon>
  13. </template>
  14. </fs-field>
  15. <fs-gutter height="40rpx" bgColor="#F6F7FB"></fs-gutter>
  16. <fs-field class="radius" placeholder="请输入密码" v-model="loginModel.password">
  17. <template #before>
  18. <fs-icon type="icon-password" color="#666666"></fs-icon>
  19. </template>
  20. </fs-field>
  21. <fs-gutter height="100rpx" bgColor="#F6F7FB"></fs-gutter>
  22. <fs-button full radius @click="handleLogin">登录</fs-button>
  23. </fs-form>
  24. </view>
  25. </template>
  26. <script setup>
  27. import { ref, reactive } from 'vue'
  28. import useForm from '@/hooks/useForm'
  29. import { useStore } from 'vuex'
  30. const store = useStore()
  31. const loginRules = {
  32. name: {
  33. required: true,
  34. message: '请输入账号'
  35. },
  36. password: {
  37. required: true,
  38. message: '请输入密码'
  39. }
  40. }
  41. const loginModel = reactive({
  42. name: '',
  43. password: ''
  44. })
  45. const loginRef = ref(null)
  46. const loginForm = useForm(loginRules, 'loginRef')
  47. const handleLogin = () => {
  48. loginForm.validate().then(() => {
  49. store.dispatch('login', {
  50. ...loginModel
  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>