index.vue 3.0 KB

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