login3.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view>
  3. <image src="/modules/common/static/images/login/login-car.png" mode="widthFix" style="width: 100vw;"></image>
  4. <view class="login-box">
  5. <view class="login-box-top">手机号登录</view>
  6. <fs-form ref="loginRef" :model="loginModel">
  7. <fs-form-item>
  8. <fs-field placeholder="请输入手机号" v-model="loginModel.phone"></fs-field>
  9. </fs-form-item>
  10. <fs-form-item>
  11. <fs-field placeholder="请输入验证码" v-model="loginModel.code">
  12. <template #after>
  13. <fs-captcha :mobile="loginModel.phone" @start="sendCaptcha" @end="endCaptcha"></fs-captcha>
  14. </template>
  15. </fs-field>
  16. </fs-form-item>
  17. <fs-gutter height="160rpx" bgColor="#fff"></fs-gutter>
  18. <fs-button full round @click="handleLogin">登录</fs-button>
  19. <fs-gutter height="60rpx" bgColor="#fff"></fs-gutter>
  20. </fs-form>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, reactive } from 'vue'
  26. import useForm from '@/hooks/useForm'
  27. import useValidator from '@/hooks/useValidator'
  28. import { useStore } from 'vuex'
  29. const store = useStore()
  30. const validator = useValidator()
  31. const loginRules = {
  32. phone: { validator: validator.mobile},
  33. code: {
  34. required: true,
  35. message: '请输入密码'
  36. }
  37. }
  38. const loginModel = reactive({
  39. phone: '',
  40. code: ''
  41. })
  42. const loginRef = ref(null)
  43. const loginForm = useForm(loginRules, 'loginRef')
  44. const handleLogin = () => {
  45. loginForm.validate().then(() => {
  46. store.dispatch('login', {
  47. ...loginModel
  48. }).then(res => {
  49. uni.navigateBack()
  50. })
  51. })
  52. }
  53. const sendCaptcha = () => {
  54. console.log('sendCaptcha');
  55. }
  56. const endCaptcha = () => {
  57. console.log('endCaptcha');
  58. }
  59. </script>
  60. <style>
  61. page{
  62. background-color: #fff;
  63. height: 100%;
  64. overflow: hidden;
  65. }
  66. </style>
  67. <style lang="scss" scoped>
  68. .login-box{
  69. position: fixed;
  70. left: 40rpx;
  71. right: 40rpx;
  72. top: 260rpx;
  73. background-color: #fff;
  74. border-radius: 20rpx;
  75. padding: 60rpx;
  76. overflow: hidden;
  77. &-top{
  78. font-size: 20px;
  79. color: #222;
  80. font-weight: 500;
  81. margin: 40rpx 0;
  82. }
  83. }
  84. .login-top{
  85. color: #222222;
  86. font-size: 30px;
  87. font-weight: bold;
  88. margin: 100rpx 0;
  89. }
  90. </style>