account-login.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!-- 账号密码登录 accountLogin -->
  2. <template>
  3. <view>
  4. <!-- 标题栏 -->
  5. <!-- <view class="head-box ss-flex-col">
  6. <view class="ss-flex ss-m-b-20">
  7. <view class="head-title ss-m-r-40 head-title-animation">账号登录</view>
  8. <view class="head-title-active head-title-line" @tap="showAuthModal('smsLogin')">
  9. 短信登录
  10. </view>
  11. </view>
  12. <view class="head-subtitle">如果未设置过密码,请点击忘记密码</view>
  13. </view> -->
  14. <!-- 表单项 -->
  15. <uni-forms ref="accountLoginRef" v-model="state.model" :rules="state.rules" validateTrigger="bind"
  16. labelWidth="140" labelAlign="center" class="loginUniForm">
  17. <uni-forms-item name="mobile" label="账号" class="loginUniFormItem">
  18. <uni-easyinput placeholder="请输入账号" v-model="state.model.mobile" :inputBorder="false">
  19. <!-- <template v-slot:right>
  20. <button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')">
  21. 忘记密码
  22. </button>
  23. </template> -->
  24. </uni-easyinput>
  25. </uni-forms-item>
  26. <uni-forms-item name="password" label="密码" class="loginUniFormItem">
  27. <uni-easyinput type="password" placeholder="请输入密码" v-model="state.model.password" :inputBorder="false">
  28. <!-- <template v-slot:right>
  29. <button class="ss-reset-button login-btn-start" @tap="accountLoginSubmit">登录</button>
  30. </template> -->
  31. </uni-easyinput>
  32. </uni-forms-item>
  33. </uni-forms>
  34. <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
  35. <button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')">
  36. 忘记密码
  37. </button>
  38. <button class="ss-reset-button login-btn-start" @tap="accountLoginSubmit">登录</button>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup>
  43. import {
  44. ref,
  45. reactive,
  46. unref,
  47. computed
  48. } from 'vue';
  49. import sheep from '@/sheep';
  50. import {
  51. mobile,
  52. password
  53. } from '@/sheep/validate/form';
  54. import {
  55. showAuthModal,
  56. closeAuthModal
  57. } from '@/sheep/hooks/useModal';
  58. import AuthUtil from '@/sheep/api/member/auth';
  59. const accountLoginRef = ref(null);
  60. const emits = defineEmits(['onConfirm']);
  61. const props = defineProps({
  62. agreeStatus: {
  63. type: Boolean,
  64. default: false,
  65. },
  66. });
  67. // 数据
  68. const state = reactive({
  69. model: {
  70. mobile: '', // 账号
  71. password: '', // 密码
  72. },
  73. rules: {
  74. mobile,
  75. password,
  76. },
  77. });
  78. // 账号登录
  79. async function accountLoginSubmit() {
  80. // 表单验证
  81. const validate = await unref(accountLoginRef)
  82. .validate()
  83. .catch((error) => {
  84. console.log('error: ', error);
  85. });
  86. if (!validate) return;
  87. // 同意协议
  88. if (!protocol.value) {
  89. // emits('onConfirm', true)
  90. onConfirm(true)
  91. // console.log("没勾选",protocol)
  92. sheep.$helper.toast('请勾选同意');
  93. return;
  94. }
  95. // 提交数据
  96. const {
  97. code,
  98. data
  99. } = await AuthUtil.login(state.model);
  100. if (code === 0) {
  101. closeAuthModal();
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. @import '../index.scss';
  107. .login-btn-start {
  108. background: #55b774;
  109. width: 60%;
  110. height: 80rpx;
  111. font-size: 32rpx;
  112. }
  113. .loginUniForm {
  114. border: 1rpx solid #d6d6d6;
  115. padding: 10rpx 15rpx;
  116. border-radius: 10rpx;
  117. }
  118. .loginUniFormItem:first-child {
  119. border-bottom: 1rpx solid #d6d6d6;
  120. padding-bottom: 10rpx;
  121. }
  122. .loginUniFormItem:last-child {
  123. // border-bottom: 1rpx solid #d6d6d6;
  124. padding-top: 10rpx;
  125. }
  126. ::v-deep .loginUniFormItem .uni-forms-item__inner {
  127. padding-bottom: 0;
  128. }
  129. ::v-deep .loginUniFormItem .uni-error-message {
  130. bottom: -20rpx;
  131. }
  132. </style>