login4.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="login-box">
  3. <view class="login-bg"></view>
  4. <view class="login-bg2"></view>
  5. <view class="login-top">
  6. <view>登录</view>
  7. <view class="login-top-sub">欢迎再次回来~</view>
  8. </view>
  9. <fs-form ref="loginRef" :model="loginModel">
  10. <fs-field bgColor="#f8f8f8" round 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="#fff"></fs-gutter>
  16. <fs-field bgColor="#f8f8f8" round 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="#fff"></fs-gutter>
  22. <fs-button full round @click="handleLogin" :customStyle="{background: 'linear-gradient(to right, #00c6fc, #9adcf1)'}">登录</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: #fff;
  60. }
  61. </style>
  62. <style lang="scss" scoped>
  63. .login{
  64. &-bg {
  65. position: fixed;
  66. top: -250rpx;
  67. right: -250rpx;
  68. width: 600rpx;
  69. height: 600rpx;
  70. border-radius: 100%;
  71. background-color: #00baef;
  72. z-index: 2
  73. }
  74. &-bg2 {
  75. position: fixed;
  76. top: -150rpx;
  77. right: -300rpx;
  78. width: 600rpx;
  79. height: 600rpx;
  80. border-radius: 100%;
  81. background-color: #ade8f9;
  82. z-index: 1;
  83. }
  84. }
  85. .login-box{
  86. padding: 30rpx;
  87. }
  88. .login-top{
  89. color: #222222;
  90. font-size: 30px;
  91. font-weight: bold;
  92. margin: 150rpx 0;
  93. &-sub{
  94. font-size: 16px;
  95. color: #b0b0b1;
  96. }
  97. }
  98. </style>