index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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" @tap="validate">
  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 validate = () => {
  104. console.log('人脸验证');
  105. };
  106. // 开始验证
  107. const formSubmit = () => {
  108. if (agree.value) {
  109. // if (openid.value) {
  110. uForm.value.validate().then(async res => {
  111. console.log(form.value);
  112. }).catch(err => {
  113. console.log(err, '校验失败');
  114. })
  115. // uni.getUserProfile({
  116. // desc: '用于展示',
  117. // success: async function (res) {
  118. // let parmas = {
  119. // openid: openid.value,
  120. // nickname: res.userInfo.nickName + moment().valueOf()
  121. // }
  122. // const arr = await $api(`user`, 'POST', parmas);
  123. // if (arr.errcode == '0') {
  124. // uni.setStorageSync('user', arr.data);
  125. // uni.navigateBack({
  126. // delta: 1
  127. // })
  128. // } else {
  129. // uni.showToast({
  130. // title: arr.errmsg,
  131. // icon: 'error'
  132. // });
  133. // }
  134. // },
  135. // fail: function (err) {
  136. // console.log(err);
  137. // }
  138. // })
  139. // } else {
  140. // uni.showToast({
  141. // title: '系统更新中,请稍后再试!',
  142. // icon: 'none'
  143. // })
  144. // }
  145. } else {
  146. uni.showToast({
  147. title: '请阅读并同意用户协议和隐私政策',
  148. icon: 'none'
  149. })
  150. }
  151. };
  152. // 查看隐私协议
  153. const toAgree = () => {
  154. uni.navigateTo({
  155. url: `/pagesHome/agree/index`
  156. })
  157. };
  158. // 同意隐私协议
  159. const changeAgree = () => {
  160. agree.value = !agree.value;
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .content {
  165. display: flex;
  166. flex-direction: column;
  167. width: 100vw;
  168. height: 100vh;
  169. .info {
  170. position: relative;
  171. flex-grow: 1;
  172. .wx {
  173. .wx_1 {
  174. text-align: center;
  175. padding: 10vw;
  176. .image {
  177. width: 35vw;
  178. height: 27vw;
  179. }
  180. }
  181. .wx_2 {
  182. text-align: center;
  183. .textOne {
  184. font-size: var(--font16Size);
  185. }
  186. .textTwo {
  187. font-size: var(--font14Size);
  188. margin: 2vw 0 0 0;
  189. color: var(--f85Color);
  190. }
  191. }
  192. .wx_3 {
  193. margin: 5vw;
  194. }
  195. .wx_4 {
  196. padding: 2vw;
  197. text-align: center;
  198. font-size: var(--font12Size);
  199. }
  200. }
  201. }
  202. .foot {
  203. padding: 2vw;
  204. .btn {
  205. font-size: var(--font14Size);
  206. color: var(--mainColor);
  207. background-color: var(--fFFColor);
  208. }
  209. }
  210. }
  211. .scroll-view {
  212. position: absolute;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. bottom: 0;
  217. .list-scroll-view {
  218. display: flex;
  219. flex-direction: column;
  220. }
  221. }
  222. </style>