index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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, computed } 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. const store = useUserStore();
  24. const globalParameter = computed(() => store.getGlobalParameter);
  25. const formData = ref({
  26. hzxm: '',
  27. hzsfzh: '',
  28. })
  29. const formRef = ref()
  30. const formRules = reactive({
  31. hzxm: {
  32. rules: [{
  33. required: true,
  34. errorMessage: '姓名不能为空'
  35. }]
  36. },
  37. hzsfzh: {
  38. rules: [{
  39. required: true,
  40. errorMessage: '身份证号不能为空',
  41. }, {
  42. validateFunction: function (rule, value, data, callback) {
  43. let CardNoReg = (
  44. /(^[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]$)/
  45. ); //身份证
  46. if (!CardNoReg.test(value)) {
  47. callback('身份证格式不正确,请重新填写')
  48. }
  49. }
  50. }]
  51. },
  52. })
  53. const submit = async () => {
  54. // 校验表单
  55. formRef.value.validate().then(async res => {
  56. // 提交请求
  57. try {
  58. let obj = Object.assign({}, globalParameter.value)
  59. obj.authCode = formData.value.hzsfzh;
  60. obj.zjhm = formData.value.hzsfzh;
  61. obj.userName = formData.value.hzxm
  62. store.setGlobalParameter(obj)
  63. link.goBJList(true)
  64. } catch (e) {
  65. dlg.error(e)
  66. }
  67. }).catch(err => {
  68. console.log('表单错误信息:', err);
  69. })
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .login {
  74. height: 100%;
  75. width: 100%;
  76. background-image: url("~@/static/image/logo_bg.png");
  77. background-repeat: no-repeat;
  78. background-position: center;
  79. width: 100%;
  80. background-size: cover;
  81. position: relative;
  82. text-align: center;
  83. .login-content {
  84. top: 360rpx;
  85. left: 96rpx;
  86. position: absolute;
  87. background: #FFFFFF;
  88. border-radius: $uni-border-radius-r1;
  89. width: calc(100% - 194rpx);
  90. padding: 40rpx $page-row-spacing 16rpx;
  91. box-sizing: border-box;
  92. .login-title {
  93. font-size: $uni-font-size-xl;
  94. line-height: $uni-line-height-xl;
  95. }
  96. .pub-input {
  97. :deep(.uni-easyinput__content) {
  98. border-color: $uni-border-color !important;
  99. border-radius: 4rpx;
  100. .uni-easyinput__content-input {
  101. height: 88rpx;
  102. font-size: $uni-font-size-lg;
  103. line-height: $uni-line-height-lg;
  104. color: $uni-text-color;
  105. .uni-input-placeholder {
  106. color: $uni-text-color-light;
  107. font-size: $uni-font-size-lg;
  108. line-height: $uni-line-height-lg;
  109. }
  110. }
  111. }
  112. }
  113. .pub-button {
  114. margin-top: 40rpx;
  115. }
  116. }
  117. }
  118. </style>