login4.vue 2.4 KB

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