index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!--
  2. * @Author: wjc
  3. * @Date: 2024-06-06 14:51:25
  4. * @LastEditors: wjc
  5. * @LastEditTime: 2024-07-03 11:27:20
  6. * @Description:
  7. -->
  8. <template>
  9. <view class="login-container">
  10. <view class="header">
  11. <image :src="logo" class="logo"></image>
  12. <view class="title">欢迎登录绘管家</view>
  13. <view class="desc">可使用企业号、账号密码登录</view>
  14. </view>
  15. <view class="form">
  16. <up-form ref="formRef" :model="formState" :rules="rules" error-type="toast">
  17. <up-form-item prop="entCode">
  18. <up-input v-model="formState.entCode" border="none" placeholder="请输入企业号"></up-input>
  19. </up-form-item>
  20. <up-form-item prop="account">
  21. <up-input v-model="formState.account" border="none" placeholder="请输入账号"></up-input>
  22. </up-form-item>
  23. <up-form-item prop="password">
  24. <up-input
  25. v-model="formState.password"
  26. border="none"
  27. type="password"
  28. placeholder="请输入密码"
  29. ></up-input>
  30. </up-form-item>
  31. </up-form>
  32. <view class="flex items-center color-gray text-14px mt-24px mb-24px">
  33. <up-checkbox-group v-model="isChecks">
  34. <up-checkbox
  35. shape="circle"
  36. name="isCheck"
  37. label="我已阅读同意"
  38. :label-size="14"
  39. ></up-checkbox>
  40. </up-checkbox-group>
  41. <text class="font-500 color-black" @click="goPrivacy">《绘管家个人信息保护政策》</text>
  42. </view>
  43. <up-button type="primary" class="btn-primary" @click="onSubmit">登录</up-button>
  44. <up-button type="text" class="mt-24px" @click="onTest">查看 Auth 页面</up-button>
  45. </view>
  46. <MFooter></MFooter>
  47. <PrivacyModal @privacy="handlePrivacy"></PrivacyModal>
  48. </view>
  49. </template>
  50. <script setup lang="ts">
  51. import { useUserStore } from '@/stores/modules/userStore'
  52. import logo from '@/static/images/logo.png'
  53. import PrivacyModal from './components/privacy.vue'
  54. defineOptions({ name: 'Login' })
  55. const userStore = useUserStore()
  56. const formRef = ref(null)
  57. const formState = ref({
  58. entCode: '460101',
  59. account: '18889757900',
  60. password: '',
  61. })
  62. const isChecks = ref([])
  63. const rules = ref({
  64. entCode: {
  65. type: 'number',
  66. required: true,
  67. message: '请输入企业号',
  68. trigger: ['blur', 'change'],
  69. },
  70. account: {
  71. type: 'number',
  72. required: true,
  73. message: '请输入账号',
  74. trigger: ['blur', 'change'],
  75. },
  76. password: {
  77. type: 'string',
  78. required: true,
  79. message: '请输入密码',
  80. trigger: ['blur', 'change'],
  81. },
  82. })
  83. const goPrivacy = () => {
  84. uni.navigateTo({ url: '/pages/privacy/index' })
  85. }
  86. const onTest = () => {
  87. uni.navigateTo({ url: '/pages/test/index' })
  88. }
  89. const onSubmit = () => {
  90. formRef.value
  91. .validate()
  92. .then((valid) => {
  93. if (valid) {
  94. if (isChecks.value.length === 0) {
  95. uni.showToast({
  96. icon: 'none',
  97. title: '请先阅读并勾选绘管家个人信息保护政策',
  98. })
  99. } else {
  100. userStore.loginAction(formState.value).then((res) => {
  101. if (res) {
  102. userStore.getUserInfoAction().then((res) => {
  103. if (res) {
  104. uni.reLaunch({
  105. url: '/pages/index/index',
  106. })
  107. }
  108. })
  109. }
  110. })
  111. }
  112. }
  113. })
  114. .catch(() => {
  115. // 处理验证错误
  116. })
  117. }
  118. const handlePrivacy = (data: boolean) => {
  119. if (data) {
  120. isChecks.value = ['isCheck']
  121. }
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. .login-container {
  126. @apply wh-full p-24px box-border;
  127. background: url('@/static/images/login/bg.png') no-repeat;
  128. background-size: contain;
  129. .header {
  130. @apply mt-140px;
  131. .logo {
  132. @apply wh-60px;
  133. }
  134. .title {
  135. @apply text-30px mt-20px mb-10px;
  136. }
  137. .desc {
  138. @apply text-16px color-gray;
  139. }
  140. }
  141. .form {
  142. @apply my-24px;
  143. .u-form {
  144. @apply flex flex-col gap-18px;
  145. .u-form-item {
  146. @apply bg-bg-page rounded-20px px-16px;
  147. }
  148. }
  149. }
  150. }
  151. </style>