identity-verify.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. formData: {
  7. name: "",
  8. idCard: ""
  9. },
  10. isAgreed: false
  11. };
  12. },
  13. computed: {
  14. canSubmit() {
  15. return this.formData.name.trim() && this.formData.idCard.trim() && this.isAgreed;
  16. }
  17. },
  18. methods: {
  19. toggleAgreement() {
  20. this.isAgreed = !this.isAgreed;
  21. },
  22. submitForm() {
  23. if (!this.canSubmit) {
  24. let message = "";
  25. if (!this.formData.name.trim()) {
  26. message = "请输入姓名";
  27. } else if (!this.formData.idCard.trim()) {
  28. message = "请输入身份证号";
  29. } else if (!this.isAgreed) {
  30. message = "请阅读并同意相关协议";
  31. }
  32. common_vendor.index.showToast({
  33. title: message,
  34. icon: "none"
  35. });
  36. return;
  37. }
  38. const idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  39. if (!idCardReg.test(this.formData.idCard)) {
  40. common_vendor.index.showToast({
  41. title: "请输入正确的身份证号",
  42. icon: "none"
  43. });
  44. return;
  45. }
  46. common_vendor.index.showLoading({
  47. title: "验证中..."
  48. });
  49. setTimeout(() => {
  50. common_vendor.index.hideLoading();
  51. common_vendor.index.navigateTo({
  52. url: "/pages/face-photo/face-photo",
  53. fail: (err) => {
  54. console.error("页面跳转失败:", err);
  55. common_vendor.index.showToast({
  56. title: "页面跳转失败",
  57. icon: "none"
  58. });
  59. }
  60. });
  61. }, 1500);
  62. }
  63. }
  64. };
  65. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  66. return {
  67. a: $data.formData.name,
  68. b: common_vendor.o(($event) => $data.formData.name = $event.detail.value),
  69. c: $data.formData.idCard,
  70. d: common_vendor.o(($event) => $data.formData.idCard = $event.detail.value),
  71. e: $data.isAgreed,
  72. f: common_vendor.o((...args) => $options.toggleAgreement && $options.toggleAgreement(...args)),
  73. g: !$options.canSubmit,
  74. h: common_vendor.o((...args) => $options.submitForm && $options.submitForm(...args))
  75. };
  76. }
  77. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  78. wx.createPage(MiniProgramPage);