index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  53. // 请求接口
  54. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  55. // openid
  56. const openid = computed(() => {
  57. return uni.getStorageSync('openid');
  58. })
  59. // 用户协议
  60. const agree = ref(false);
  61. const form = ref({ name: '', card: '', phone: '' });
  62. const rules = {
  63. 'card': [{
  64. required: true,
  65. message: '请填写身份证号',
  66. },
  67. {
  68. validator: function (rule, value, data, callback) {
  69. if (value.indexOf('**') > -1) {
  70. callback()
  71. return
  72. }
  73. let idCard = (
  74. /^[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]$/
  75. ); //
  76. return idCard.test(value)
  77. },
  78. message: '身份证格式不正确,请重新填写'
  79. }
  80. ],
  81. 'name': {
  82. type: 'string',
  83. required: true,
  84. message: '请输入姓名',
  85. trigger: ['blur', 'change'],
  86. },
  87. 'phone': [
  88. {
  89. required: true,
  90. message: '请输入手机号',
  91. trigger: ['change', 'blur'],
  92. },
  93. {
  94. // 自定义验证函数,见上说明
  95. validator: (rule, value, callback) => {
  96. return uni.$u.test.mobile(value);
  97. },
  98. message: '手机号码不正确',
  99. trigger: ['change', 'blur'],
  100. }
  101. ]
  102. }
  103. const uForm = ref(null);
  104. onShow(() => {
  105. if (openid.value) search();
  106. })
  107. // 查询
  108. const search = async () => {
  109. const res = await $api(`login/wxapp/${openid.value}`, 'POST', {});
  110. if (res.errcode == '0') {
  111. form.value = res.data
  112. } else {
  113. uni.showToast({
  114. title: res.errmsg,
  115. icon: 'none'
  116. })
  117. }
  118. };
  119. // 开始验证
  120. const formSubmit = () => {
  121. if (agree.value) {
  122. if (openid.value) {
  123. uForm.value.validate().then(async res => {
  124. console.log(form.value);
  125. // uni.getUserProfile({
  126. // desc: '用于展示',
  127. // success: async function (res) {
  128. // let parmas = {
  129. // openid: openid.value,
  130. // nickname: res.userInfo.nickName + moment().valueOf()
  131. // }
  132. // const arr = await $api(`user`, 'POST', parmas);
  133. // if (arr.errcode == '0') {
  134. // uni.setStorageSync('user', arr.data);
  135. // uni.navigateBack({
  136. // delta: 1
  137. // })
  138. // } else {
  139. // uni.showToast({
  140. // title: arr.errmsg,
  141. // icon: 'error'
  142. // });
  143. // }
  144. // },
  145. // fail: function (err) {
  146. // console.log(err);
  147. // }
  148. // })
  149. }).catch(err => {
  150. console.log(err, '校验失败');
  151. })
  152. } else {
  153. uni.showToast({
  154. title: '系统更新中,请稍后再试!',
  155. icon: 'none'
  156. })
  157. }
  158. } else {
  159. uni.showToast({
  160. title: '请阅读并同意用户协议和隐私政策',
  161. icon: 'none'
  162. })
  163. }
  164. };
  165. // 查看隐私协议
  166. const toAgree = () => {
  167. uni.navigateTo({
  168. url: `/pagesHome/agree/index`
  169. })
  170. };
  171. // 同意隐私协议
  172. const changeAgree = () => {
  173. agree.value = !agree.value;
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. .content {
  178. display: flex;
  179. flex-direction: column;
  180. width: 100vw;
  181. height: 100vh;
  182. .info {
  183. position: relative;
  184. flex-grow: 1;
  185. .wx {
  186. .wx_1 {
  187. text-align: center;
  188. padding: 10vw;
  189. .image {
  190. width: 35vw;
  191. height: 27vw;
  192. }
  193. }
  194. .wx_2 {
  195. text-align: center;
  196. .textOne {
  197. font-size: var(--font16Size);
  198. }
  199. .textTwo {
  200. font-size: var(--font14Size);
  201. margin: 2vw 0 0 0;
  202. color: var(--f85Color);
  203. }
  204. }
  205. .wx_3 {
  206. margin: 5vw;
  207. }
  208. .wx_4 {
  209. padding: 2vw;
  210. text-align: center;
  211. font-size: var(--font12Size);
  212. }
  213. }
  214. }
  215. .foot {
  216. padding: 2vw;
  217. .btn {
  218. font-size: var(--font14Size);
  219. color: var(--mainColor);
  220. background-color: var(--fFFColor);
  221. }
  222. }
  223. }
  224. .scroll-view {
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. right: 0;
  229. bottom: 0;
  230. .list-scroll-view {
  231. display: flex;
  232. flex-direction: column;
  233. }
  234. }
  235. </style>