login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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
  23. full
  24. round
  25. @click="handleLogin"
  26. :customStyle="{ background: 'linear-gradient(to right, #00c6fc, #9adcf1)' }"
  27. >
  28. 登录
  29. </fs-button>
  30. <fs-gutter height="60rpx" bgColor="#fff"></fs-gutter>
  31. <fs-button full round type="success" @click="getUserProfile">微信登录</fs-button>
  32. </fs-form>
  33. </view>
  34. </template>
  35. <script setup>
  36. import { ref, reactive } from 'vue'
  37. import useForm from '@/hooks/useForm'
  38. import { useUserStore } from '@/stores/user'
  39. const user = useUserStore()
  40. const loginRules = {
  41. name: {
  42. required: true,
  43. message: '请输入账号'
  44. },
  45. password: {
  46. required: true,
  47. message: '请输入密码'
  48. }
  49. }
  50. const loginModel = reactive({
  51. name: '',
  52. password: ''
  53. })
  54. const loginRef = ref(null)
  55. const loginForm = useForm(loginRules, 'loginRef')
  56. const handleLogin = () => {
  57. loginForm.validate().then(() => {
  58. user
  59. .login({
  60. ...loginModel
  61. })
  62. .then(res => {
  63. uni.navigateBack()
  64. })
  65. })
  66. }
  67. const getUserProfile = () => {
  68. wx.getUserProfile({
  69. desc: '用于完善会员资料',
  70. success: res => {
  71. // store.dispatch('wxLogin').then(res => {
  72. // })
  73. }
  74. })
  75. }
  76. </script>
  77. <style>
  78. page {
  79. background-color: #fff;
  80. }
  81. </style>
  82. <style lang="scss" scoped>
  83. .login {
  84. &-bg {
  85. position: fixed;
  86. top: -250rpx;
  87. right: -250rpx;
  88. width: 600rpx;
  89. height: 600rpx;
  90. border-radius: 100%;
  91. background-color: #00baef;
  92. z-index: 2;
  93. }
  94. &-bg2 {
  95. position: fixed;
  96. top: -150rpx;
  97. right: -300rpx;
  98. width: 600rpx;
  99. height: 600rpx;
  100. border-radius: 100%;
  101. background-color: #ade8f9;
  102. z-index: 1;
  103. }
  104. }
  105. .login-box {
  106. padding: 30rpx;
  107. }
  108. .login-top {
  109. color: #222222;
  110. font-size: 30px;
  111. font-weight: bold;
  112. margin: 150rpx 0;
  113. &-sub {
  114. font-size: 16px;
  115. color: #b0b0b1;
  116. }
  117. }
  118. </style>