index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="content">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <view class="wx">
  7. <view class="wx_1">
  8. <image class="image" src="/static/login.png">
  9. </image>
  10. </view>
  11. <view class="wx_2">
  12. <view class="textOne">当前业务需要人脸识别验证</view>
  13. <view class="textTwo">信息将用于公证业务办理,并与当前微信绑定</view>
  14. </view>
  15. <view class="wx_3">
  16. <u--form class="form" :model="form" ref="uForm" :rules="rules" labelWidth="70"
  17. label-position="top">
  18. <u-form-item label="证件号码" prop="card">
  19. <input class="input" v-model="form.card" placeholder="填写证件号码" />
  20. </u-form-item>
  21. <u-form-item label="姓名" prop="name">
  22. <input class="input" v-model="form.name" placeholder="填写姓名" />
  23. </u-form-item>
  24. <u-form-item label="手机号" prop="phone">
  25. <input class="input" v-model="form.phone" placeholder="填写常用手机号" />
  26. </u-form-item>
  27. </u--form>
  28. </view>
  29. <view class="wx_4">
  30. <checkbox-group @change="changeAgree">
  31. <label>
  32. <checkbox color="#2979ff" :checked="agree" />
  33. <text @tap.stop="toAgree()">我同意使用我所提交的信息用于身份验证及公证业务办理,阅读<text
  34. style="color: #2979ff;">《用户服务协议》</text>和 <text
  35. style="color: #2979ff;">《隐私策略》</text></text>
  36. </label>
  37. </checkbox-group>
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. <view class="foot">
  44. <button class="btn" @tap="formSubmit">开始验证</button>
  45. </view>
  46. </view>
  47. </template>
  48. <script setup lang="ts">
  49. import moment from 'moment';
  50. import { getCurrentInstance, computed, ref } from 'vue';
  51. // 请求接口
  52. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  53. // openid
  54. const openid = computed(() => {
  55. return uni.getStorageSync('openid');
  56. })
  57. // 用户协议
  58. const agree = ref(false);
  59. const form = ref({ name: '', card: '', phone: '' });
  60. const rules = {
  61. 'card': [{
  62. required: true,
  63. message: '请填写身份证号',
  64. },
  65. {
  66. validator: function (rule, value, data, callback) {
  67. if (value.indexOf('**') > -1) {
  68. callback()
  69. return
  70. }
  71. let idCard = (
  72. /^[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]$/
  73. ); //
  74. return idCard.test(value)
  75. },
  76. message: '身份证格式不正确,请重新填写'
  77. }
  78. ],
  79. 'name': {
  80. type: 'string',
  81. required: true,
  82. message: '请输入姓名',
  83. trigger: ['blur', 'change'],
  84. },
  85. 'phone': [
  86. {
  87. required: true,
  88. message: '请输入手机号',
  89. trigger: ['change', 'blur'],
  90. },
  91. {
  92. // 自定义验证函数,见上说明
  93. validator: (rule, value, callback) => {
  94. return uni.$u.test.mobile(value);
  95. },
  96. message: '手机号码不正确',
  97. trigger: ['change', 'blur'],
  98. }
  99. ]
  100. }
  101. const uForm = ref(null);
  102. // 开始验证
  103. const formSubmit = () => {
  104. if (agree.value) {
  105. // if (openid.value) {
  106. uForm.value.validate().then(async res => {
  107. console.log(form.value);
  108. }).catch(err => {
  109. console.log(err, '校验失败');
  110. })
  111. // uni.getUserProfile({
  112. // desc: '用于展示',
  113. // success: async function (res) {
  114. // let parmas = {
  115. // openid: openid.value,
  116. // nickname: res.userInfo.nickName + moment().valueOf()
  117. // }
  118. // const arr = await $api(`user`, 'POST', parmas);
  119. // if (arr.errcode == '0') {
  120. // uni.setStorageSync('user', arr.data);
  121. // uni.navigateBack({
  122. // delta: 1
  123. // })
  124. // } else {
  125. // uni.showToast({
  126. // title: arr.errmsg,
  127. // icon: 'error'
  128. // });
  129. // }
  130. // },
  131. // fail: function (err) {
  132. // console.log(err);
  133. // }
  134. // })
  135. // } else {
  136. // uni.showToast({
  137. // title: '系统更新中,请稍后再试!',
  138. // icon: 'none'
  139. // })
  140. // }
  141. } else {
  142. uni.showToast({
  143. title: '请阅读并同意用户协议和隐私政策',
  144. icon: 'none'
  145. })
  146. }
  147. };
  148. // 查看隐私协议
  149. const toAgree = () => {
  150. uni.navigateTo({
  151. url: `/pagesHome/agree/index`
  152. })
  153. };
  154. // 同意隐私协议
  155. const changeAgree = () => {
  156. agree.value = !agree.value;
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .content {
  161. display: flex;
  162. flex-direction: column;
  163. width: 100vw;
  164. height: 100vh;
  165. .info {
  166. position: relative;
  167. flex-grow: 1;
  168. .wx {
  169. .wx_1 {
  170. text-align: center;
  171. padding: 10vw;
  172. .image {
  173. width: 35vw;
  174. height: 27vw;
  175. }
  176. }
  177. .wx_2 {
  178. text-align: center;
  179. .textOne {
  180. font-size: var(--font16Size);
  181. }
  182. .textTwo {
  183. font-size: var(--font14Size);
  184. margin: 2vw 0 0 0;
  185. color: var(--f85Color);
  186. }
  187. }
  188. .wx_3 {
  189. margin: 5vw;
  190. }
  191. .wx_4 {
  192. padding: 2vw;
  193. text-align: center;
  194. font-size: var(--font12Size);
  195. }
  196. }
  197. }
  198. .foot {
  199. padding: 2vw;
  200. .btn {
  201. font-size: var(--font14Size);
  202. color: var(--mainColor);
  203. background-color: var(--fFFColor);
  204. }
  205. }
  206. }
  207. .scroll-view {
  208. position: absolute;
  209. top: 0;
  210. left: 0;
  211. right: 0;
  212. bottom: 0;
  213. .list-scroll-view {
  214. display: flex;
  215. flex-direction: column;
  216. }
  217. }
  218. </style>