2025-06-03 17:29:22 +08:00
|
|
|
"use strict";
|
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
|
const common_assets = require("../../common/assets.js");
|
2025-06-04 17:33:25 +08:00
|
|
|
if (!Array) {
|
|
|
|
const _easycom_u_modal2 = common_vendor.resolveComponent("u-modal");
|
|
|
|
_easycom_u_modal2();
|
|
|
|
}
|
|
|
|
const _easycom_u_modal = () => "../../uni_modules/vk-uview-ui/components/u-modal/u-modal.js";
|
|
|
|
if (!Math) {
|
|
|
|
_easycom_u_modal();
|
|
|
|
}
|
2025-06-03 17:29:22 +08:00
|
|
|
const _sfc_main = {
|
|
|
|
__name: "IDcard",
|
|
|
|
setup(__props) {
|
2025-06-04 17:33:25 +08:00
|
|
|
const show = common_vendor.ref(false);
|
|
|
|
const content = common_vendor.ref("");
|
2025-06-03 17:29:22 +08:00
|
|
|
const nameArray = ["姓名", "性别", "身份证号码", "民族", "出生日期", "住址", "签发机关", "有效期限"];
|
2025-06-04 17:33:25 +08:00
|
|
|
const textArray = common_vendor.reactive(["", "", "", "", "", "", "", ""]);
|
2025-06-03 17:29:22 +08:00
|
|
|
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) => {
|
2025-06-04 17:33:25 +08:00
|
|
|
common_vendor.index.__f__("error", "at pages/addoldman/IDcard.vue:87", "拍照失败:", err);
|
2025-06-03 17:29:22 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2025-06-04 17:33:25 +08:00
|
|
|
const headImge = common_vendor.ref("");
|
|
|
|
const backImge = common_vendor.ref("");
|
2025-06-03 17:29:22 +08:00
|
|
|
function uploadImage(filePath) {
|
2025-06-04 17:33:25 +08:00
|
|
|
common_vendor.index.showLoading();
|
2025-06-03 17:29:22 +08:00
|
|
|
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") || ""
|
|
|
|
},
|
2025-06-04 17:33:25 +08:00
|
|
|
formData: {},
|
2025-06-03 17:29:22 +08:00
|
|
|
success: (uploadRes) => {
|
2025-06-04 17:33:25 +08:00
|
|
|
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();
|
|
|
|
}
|
2025-06-03 17:29:22 +08:00
|
|
|
},
|
|
|
|
fail: (err) => {
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
title: "上传出错",
|
|
|
|
icon: "error"
|
|
|
|
});
|
2025-06-04 17:33:25 +08:00
|
|
|
common_vendor.index.hideLoading();
|
2025-06-03 17:29:22 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2025-06-04 17:33:25 +08:00
|
|
|
const openLook = (res) => {
|
|
|
|
if (res) {
|
|
|
|
content.value = res;
|
|
|
|
show.value = true;
|
|
|
|
}
|
|
|
|
};
|
2025-06-03 17:29:22 +08:00
|
|
|
const next = () => {
|
|
|
|
common_vendor.index.navigateTo({
|
|
|
|
url: "/pages/addoldman/yibao"
|
|
|
|
});
|
|
|
|
};
|
|
|
|
return (_ctx, _cache) => {
|
|
|
|
return {
|
2025-06-04 17:33:25 +08:00
|
|
|
a: common_vendor.o(($event) => show.value = $event),
|
|
|
|
b: common_vendor.p({
|
|
|
|
content: content.value,
|
|
|
|
modelValue: show.value
|
|
|
|
}),
|
2025-06-13 13:42:14 +08:00
|
|
|
c: common_assets._imports_0$4,
|
2025-06-04 17:33:25 +08:00
|
|
|
d: headImge.value ? headImge.value : `/static/index/IDcard.png`,
|
|
|
|
e: !headImge.value,
|
2025-06-09 17:33:50 +08:00
|
|
|
f: common_assets._imports_1$5,
|
2025-06-04 17:33:25 +08:00
|
|
|
g: common_vendor.o(getMessage),
|
|
|
|
h: backImge.value ? backImge.value : `/static/index/backIDcard.png`,
|
|
|
|
i: !backImge.value,
|
2025-06-09 17:33:50 +08:00
|
|
|
j: common_assets._imports_1$5,
|
2025-06-04 17:33:25 +08:00
|
|
|
k: common_vendor.o(getMessage),
|
|
|
|
l: common_vendor.f(nameArray, (item, index, i0) => {
|
2025-06-03 17:29:22 +08:00
|
|
|
return {
|
|
|
|
a: common_vendor.t(item),
|
2025-06-04 17:33:25 +08:00
|
|
|
b: common_vendor.t(textArray[index] ? textArray[index] : "自动获取"),
|
|
|
|
c: index,
|
|
|
|
d: common_vendor.o(($event) => openLook(textArray[index]), index)
|
2025-06-03 17:29:22 +08:00
|
|
|
};
|
|
|
|
}),
|
2025-06-04 17:33:25 +08:00
|
|
|
m: common_vendor.o(next)
|
2025-06-03 17:29:22 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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
|