searchState.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="page-bg">
  3. <view class="container">
  4. <uni-forms ref="formRef" :model="form" :rules="rules" validateTrigger="blur" label-position="top" label-width="100px">
  5. <uni-forms-item label="身份证号码" name="lrZjhm" required>
  6. <uni-easyinput type="text" v-model="form.lrZjhm" placeholder="请输入身份证号码" />
  7. </uni-forms-item>
  8. </uni-forms>
  9. <button class="green-btn" @click="submitForm">查询</button>
  10. <uni-card title="查询结果" extra="" :class="{'search-result':true,'isShow':msg}">
  11. <text class="uni-body">{{msg}}</text>
  12. </uni-card>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { getState } from '@/api/kh.js'
  18. import { showConfirm, toast } from '@/common/common.js'
  19. const idNumReg = (/^[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]$/)
  20. export default {
  21. data() {
  22. return {
  23. btnLoad: false,
  24. form: {
  25. lrZjhm: '', //222327196011300057
  26. },
  27. oldIdNum: '',
  28. msg: '',
  29. rules: {
  30. lrZjhm: {
  31. rules: [
  32. { required: true, errorMessage: '身份证号码不能为空' },
  33. {
  34. validateFunction: function(rule, value, data, callback) {
  35. if (!idNumReg.test(value)) {
  36. callback('身份证号格式不正确')
  37. }
  38. }
  39. }
  40. ]
  41. },
  42. }
  43. }
  44. },
  45. watch: {
  46. 'form.lrZjhm': {
  47. handler(newVal) {
  48. if (!newVal) {
  49. this.msg = ''
  50. }
  51. }
  52. }
  53. },
  54. methods: {
  55. submitForm() {
  56. this.$refs.formRef.validate().then(form => {
  57. uni.showLoading({
  58. title: '查询中...',
  59. mask: true,
  60. })
  61. // 重复查询不请求
  62. if (form.lrZjhm !== this.oldIdNum) {
  63. this.msg = ''
  64. getState(this.form).then(res => {
  65. if (res.code !== 200) return
  66. const { data } = res
  67. // lzzt 0 审核通过须人脸激活 8待审核,9 被拒绝
  68. if (!data) {
  69. showConfirm('您查询的身份证号码不存在,请确认证件号码是否正确!')
  70. return
  71. }
  72. uni.hideLoading()
  73. switch (data.lzzt) {
  74. case '0':
  75. this.msg = '您查询的人员信息审核已通过,请尽快进行刷脸激活操作!'
  76. break;
  77. case '8':
  78. this.msg = '您查询的人员信息正在审核中,请再耐心等待一下~'
  79. break;
  80. case '9':
  81. this.msg = '您查询的人员信息审核被拒绝了,拒绝原因是:' + data.lrSpyj
  82. break;
  83. default:
  84. this.msg = '您查询的人员信息审核已经通过啦~'
  85. break;
  86. }
  87. }).finally(() => {
  88. uni.hideLoading()
  89. this.oldIdNum = form.lrZjhm
  90. })
  91. } else {
  92. uni.hideLoading()
  93. toast('请勿重复查询!')
  94. }
  95. })
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .page-bg {
  102. height: 100vh;
  103. overflow: hidden;
  104. background-image: linear-gradient(to top, #68b7e7 0%, #ffffff 100%);
  105. animation: fadeIn 1s linear;
  106. }
  107. .container {
  108. padding: 10px;
  109. }
  110. ::v-deep .uni-forms {
  111. width: 80%;
  112. margin: 20% auto 0;
  113. }
  114. .green-btn {
  115. width: 30%;
  116. line-height: 2;
  117. background: #28d87d;
  118. // background: #00c4f3;
  119. border-radius: 5px;
  120. color: white;
  121. margin: 20px auto 50px;
  122. position: relative;
  123. }
  124. ::v-deep .search-result {
  125. position: relative;
  126. top: 20vh;
  127. opacity: 0;
  128. visibility: hidden;
  129. transition: all .8s;
  130. &.isShow {
  131. top: 0;
  132. opacity: 1;
  133. visibility: inherit;
  134. }
  135. }
  136. </style>