"use strict"; const common_vendor = require("../../common/vendor.js"); if (!Math) { model(); } const model = () => "../../compontent/public/model.js"; const _sfc_main = { __name: "IDcard", setup(__props) { const show = common_vendor.ref(false); const content = common_vendor.ref(""); const nameArray = ["姓名", "性别", "身份证号码", "民族", "出生日期", "住址", "签发机关", "有效期限"]; const textArray = common_vendor.reactive(["", "", "", "", "", "", "", ""]); const tempImagePath = common_vendor.ref(""); function getMessage() { common_vendor.index.chooseImage({ count: 1, sourceType: ["camera"], success: (chooseRes) => { tempImagePath.value = chooseRes.tempFilePaths[0]; uploadImage(tempImagePath.value); }, fail: (err) => { common_vendor.index.__f__("error", "at pages/addoldman/IDcard.vue:97", "拍照失败:", err); } }); } const headImge = common_vendor.ref(""); const backImge = common_vendor.ref(""); function uploadImage(filePath) { common_vendor.index.showLoading(); common_vendor.index.uploadFile({ url: `${common_vendor.index.getStorageSync("serverUrl")}/api/ocr/idCard`, // 替换为您的POST接口地址 filePath, name: "file", // 后端接收时的字段名 header: { "X-Access-Token": common_vendor.index.getStorageSync("token") || "" }, formData: {}, success: (uploadRes) => { if (!JSON.parse(uploadRes.data).success) { common_vendor.index.showToast({ title: "识别失败", icon: "error" }); common_vendor.index.hideLoading(); return; } if (JSON.parse(JSON.parse(uploadRes.data).result.data).data.face) { let father = JSON.parse(JSON.parse(uploadRes.data).result.data).data.face.data; textArray[0] = father.name; textArray[1] = father.sex; textArray[2] = father.idNumber; textArray[3] = father.ethnicity; textArray[4] = father.birthDate; textArray[5] = father.address; common_vendor.index.showToast({ title: "识别成功" }); headImge.value = filePath; common_vendor.index.hideLoading(); } else { let father = JSON.parse(JSON.parse(uploadRes.data).result.data).data.back.data; textArray[6] = father.issueAuthority; textArray[7] = father.validPeriod; common_vendor.index.showToast({ title: "识别成功" }); backImge.value = filePath; common_vendor.index.hideLoading(); } }, fail: (err) => { common_vendor.index.showToast({ title: "上传出错", icon: "error" }); common_vendor.index.hideLoading(); } }); } function isAtLeastEightChars(str) { return typeof str === "string" && str.length >= 8; } const openLook = (res) => { if (isAtLeastEightChars(res)) { content.value = res; show.value = true; } }; const next = () => { common_vendor.index.navigateTo({ url: "/pages/addoldman/yibao" }); }; return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.o(($event) => show.value = false), b: common_vendor.p({ show: show.value, content: content.value }), c: headImge.value ? headImge.value : `https://www.focusnu.com/media/directive/index/IDcard.png`, d: !headImge.value }, !headImge.value ? {} : {}, { e: common_vendor.o(getMessage), f: backImge.value ? backImge.value : `https://www.focusnu.com/media/directive/index/backIDcard.png`, g: !backImge.value }, !backImge.value ? {} : {}, { h: common_vendor.o(getMessage), i: common_vendor.f(nameArray, (item, index, i0) => { return { a: common_vendor.t(item), b: common_vendor.t(textArray[index] ? textArray[index] : "自动获取"), c: index, d: common_vendor.o(($event) => openLook(textArray[index]), index) }; }), j: common_vendor.o(next) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5fcb8e22"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/addoldman/IDcard.js.map