index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="login">
  3. <view class="login-content">
  4. <view class="login-title">账号登录</view>
  5. <uni-forms ref="formRef" :modelValue="formData" :rules="formRules" style="margin-top: 10px;">
  6. <uni-forms-item name="hzxm">
  7. <uni-easyinput class="pub-input" trim="all" v-model="formData.hzxm" placeholder="请输入姓名"></uni-easyinput>
  8. </uni-forms-item>
  9. <uni-forms-item name="hzsfzh">
  10. <uni-easyinput class="pub-input" trim="all" v-model="formData.hzsfzh" placeholder="请输入身份证号"></uni-easyinput>
  11. </uni-forms-item>
  12. </uni-forms>
  13. <view class=" pub-button is-bg large" @click="submit">登录</view>
  14. </view>
  15. </view>
  16. </template>
  17. <script lang="ts" setup>
  18. import { ref, reactive } from 'vue'
  19. import dlg from '@/lib/dlg'
  20. import { aesEncrypt, aesDecrypt } from "@/lib/encryption"
  21. import * as link from '@/lib/link'
  22. import { useUserStore } from '@/lib/store';
  23. import { storeToRefs } from 'pinia';
  24. const store = useUserStore();
  25. const { globalParameter } = storeToRefs(store);
  26. const formData = ref({
  27. hzxm: '',
  28. hzsfzh: '',
  29. })
  30. const formRef = ref()
  31. const formRules = reactive({
  32. hzxm: {
  33. rules: [{
  34. required: true,
  35. errorMessage: '姓名不能为空'
  36. }]
  37. },
  38. hzsfzh: {
  39. rules: [{
  40. required: true,
  41. errorMessage: '身份证号不能为空',
  42. }, {
  43. validateFunction: function (rule, value, data, callback) {
  44. let CardNoReg = (
  45. /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/
  46. ); //身份证
  47. if (!CardNoReg.test(value)) {
  48. callback('身份证格式不正确,请重新填写')
  49. }
  50. }
  51. }]
  52. },
  53. })
  54. const submit = async () => {
  55. // 校验表单
  56. formRef.value.validate().then(async res => {
  57. // 提交请求
  58. try {
  59. globalParameter.value.authCode = formData.value.hzsfzh
  60. localStorage.setItem('authCode', formData.value.hzsfzh);
  61. link.goBJList(aesEncrypt(formData.value.hzsfzh),aesEncrypt(formData.value.hzxm))
  62. } catch (e) {
  63. dlg.error(e)
  64. }
  65. }).catch(err => {
  66. console.log('表单错误信息:', err);
  67. })
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .login {
  72. height: 100%;
  73. width: 100%;
  74. background-image: url("~@/static/image/logo_bg.png");
  75. background-repeat: no-repeat;
  76. background-position: center;
  77. width: 100%;
  78. background-size: cover;
  79. position: relative;
  80. text-align: center;
  81. .login-content {
  82. top: 360rpx;
  83. left: 96rpx;
  84. position: absolute;
  85. background: #FFFFFF;
  86. border-radius: $uni-border-radius-r1;
  87. width: calc(100% - 194rpx);
  88. padding: 40rpx $page-row-spacing 16rpx;
  89. box-sizing: border-box;
  90. .login-title {
  91. font-size: $uni-font-size-xl;
  92. line-height: $uni-line-height-xl;
  93. }
  94. .pub-input {
  95. :deep(.uni-easyinput__content) {
  96. border-color: $uni-border-color !important;
  97. border-radius: 4rpx;
  98. .uni-easyinput__content-input {
  99. height: 88rpx;
  100. font-size: $uni-font-size-lg;
  101. line-height: $uni-line-height-lg;
  102. color: $uni-text-color;
  103. .uni-input-placeholder {
  104. color: $uni-text-color-light;
  105. font-size: $uni-font-size-lg;
  106. line-height: $uni-line-height-lg;
  107. }
  108. }
  109. }
  110. }
  111. .pub-button {
  112. margin-top: 40rpx;
  113. }
  114. }
  115. }
  116. </style>