2025-06-09 17:33:50 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
|
|
const request_index = require("../../request/index.js");
|
|
|
|
|
if (!Array) {
|
|
|
|
|
const _easycom_u_modal2 = common_vendor.resolveComponent("u-modal");
|
2025-06-23 17:31:43 +08:00
|
|
|
|
const _easycom_u_action_sheet2 = common_vendor.resolveComponent("u-action-sheet");
|
|
|
|
|
(_easycom_u_modal2 + _easycom_u_action_sheet2)();
|
2025-06-09 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
const _easycom_u_modal = () => "../../uni_modules/vk-uview-ui/components/u-modal/u-modal.js";
|
2025-06-23 17:31:43 +08:00
|
|
|
|
const _easycom_u_action_sheet = () => "../../uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.js";
|
2025-06-09 17:33:50 +08:00
|
|
|
|
if (!Math) {
|
2025-06-23 17:31:43 +08:00
|
|
|
|
(_easycom_u_modal + _easycom_u_action_sheet)();
|
2025-06-09 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
const _sfc_main = {
|
|
|
|
|
__name: "name",
|
|
|
|
|
setup(__props) {
|
|
|
|
|
const show = common_vendor.ref(false);
|
|
|
|
|
const content = common_vendor.ref("");
|
2025-06-23 17:31:43 +08:00
|
|
|
|
const bottomshow = common_vendor.ref(false);
|
|
|
|
|
const bottomlist = [{
|
|
|
|
|
text: "拍摄图片",
|
|
|
|
|
fontSize: 40
|
|
|
|
|
}, {
|
|
|
|
|
text: "图片预览",
|
|
|
|
|
fontSize: 40
|
|
|
|
|
}];
|
2025-06-09 17:33:50 +08:00
|
|
|
|
const nameArray = ["姓名", "性别", "身份证号码", "民族", "出生日期", "住址", "签发机关", "有效期限"];
|
|
|
|
|
const textArray = common_vendor.reactive(["", "", "", "", "", "", "", ""]);
|
2025-06-11 17:33:34 +08:00
|
|
|
|
const fontphoto = common_vendor.ref("");
|
|
|
|
|
const endphoto = common_vendor.ref("");
|
|
|
|
|
common_vendor.ref(0);
|
2025-06-23 17:31:43 +08:00
|
|
|
|
const photoclick = (element) => {
|
|
|
|
|
if (element) {
|
|
|
|
|
common_vendor.index.previewImage({
|
|
|
|
|
urls: [headImge.value, backImge.value],
|
|
|
|
|
// 必填,所有要预览的图片地址数组
|
|
|
|
|
current: targetphoto.value ? backImge.value : headImge.value,
|
|
|
|
|
// 可选,当前显示图片的地址,默认是 urls[0]
|
|
|
|
|
indicator: "default",
|
|
|
|
|
// 可选,指示器样式,H5/App 有效,值为 'default'(圆点)或 'number'(数字)
|
|
|
|
|
longPressActions: {
|
|
|
|
|
// 可选,仅 App 支持,长按图片时弹出的操作项
|
|
|
|
|
itemList: ["保存图片到相册"]
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
getMessage();
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-06-09 17:33:50 +08:00
|
|
|
|
const tempImagePath = common_vendor.ref("");
|
2025-06-23 17:31:43 +08:00
|
|
|
|
const targetphoto = common_vendor.ref(0);
|
|
|
|
|
const selectphoto = (number) => {
|
2025-06-27 08:55:44 +08:00
|
|
|
|
if (!uping.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-06-23 17:31:43 +08:00
|
|
|
|
if (backImge.value && headImge.value) {
|
|
|
|
|
targetphoto.value = number;
|
|
|
|
|
bottomshow.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
getMessage();
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-06-09 17:33:50 +08:00
|
|
|
|
function getMessage() {
|
|
|
|
|
common_vendor.index.chooseImage({
|
|
|
|
|
count: 1,
|
2025-06-23 17:31:43 +08:00
|
|
|
|
sourceType: ["album", "camera"],
|
2025-06-09 17:33:50 +08:00
|
|
|
|
success: (chooseRes) => {
|
|
|
|
|
tempImagePath.value = chooseRes.tempFilePaths[0];
|
2025-06-23 17:31:43 +08:00
|
|
|
|
common_vendor.index.navigateTo({
|
|
|
|
|
url: `/compontent/public/camera?url=${chooseRes.tempFilePaths[0]}&type=0`
|
|
|
|
|
});
|
2025-06-09 17:33:50 +08:00
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
2025-06-27 08:55:44 +08:00
|
|
|
|
common_vendor.index.__f__("error", "at pages/addjigou/name.vue:174", "拍照失败:", err);
|
2025-06-09 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
const headImge = common_vendor.ref("");
|
|
|
|
|
const backImge = common_vendor.ref("");
|
|
|
|
|
function uploadImage(filePath) {
|
2025-06-13 13:42:14 +08:00
|
|
|
|
uping.value = false;
|
2025-06-09 17:33:50 +08:00
|
|
|
|
common_vendor.index.showLoading();
|
|
|
|
|
common_vendor.index.uploadFile({
|
|
|
|
|
url: `${request_index.base_url}/api/ocr/idCard`,
|
|
|
|
|
// 替换为你的POST接口地址
|
|
|
|
|
filePath,
|
|
|
|
|
name: "file",
|
|
|
|
|
// 后端接收时的字段名
|
|
|
|
|
header: {
|
|
|
|
|
"X-Access-Token": common_vendor.index.getStorageSync("token") || ""
|
|
|
|
|
},
|
|
|
|
|
formData: {},
|
|
|
|
|
success: (uploadRes) => {
|
2025-06-27 08:55:44 +08:00
|
|
|
|
common_vendor.index.__f__("log", "at pages/addjigou/name.vue:212", "token", common_vendor.index.getStorageSync("token"));
|
2025-06-09 17:33:50 +08:00
|
|
|
|
if (!JSON.parse(uploadRes.data).success) {
|
2025-06-27 08:55:44 +08:00
|
|
|
|
common_vendor.index.hideLoading();
|
2025-06-09 17:33:50 +08:00
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
|
title: "识别失败",
|
2025-06-23 17:31:43 +08:00
|
|
|
|
icon: "error",
|
|
|
|
|
duration: 2e3
|
2025-06-09 17:33:50 +08:00
|
|
|
|
});
|
2025-06-23 17:31:43 +08:00
|
|
|
|
uping.value = true;
|
2025-06-09 17:33:50 +08:00
|
|
|
|
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;
|
2025-06-11 17:33:34 +08:00
|
|
|
|
savephoto(filePath, 0);
|
2025-06-09 17:33:50 +08:00
|
|
|
|
common_vendor.index.hideLoading();
|
2025-06-23 17:31:43 +08:00
|
|
|
|
} else if (JSON.parse(JSON.parse(uploadRes.data).result.data).data.back) {
|
2025-06-09 17:33:50 +08:00
|
|
|
|
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;
|
2025-06-11 17:33:34 +08:00
|
|
|
|
savephoto(filePath, 1);
|
2025-06-09 17:33:50 +08:00
|
|
|
|
common_vendor.index.hideLoading();
|
2025-06-23 17:31:43 +08:00
|
|
|
|
} else {
|
2025-06-27 08:55:44 +08:00
|
|
|
|
common_vendor.index.hideLoading();
|
2025-06-23 17:31:43 +08:00
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
|
title: "识别失败",
|
|
|
|
|
icon: "error",
|
|
|
|
|
duration: 2e3
|
|
|
|
|
});
|
2025-06-27 08:55:44 +08:00
|
|
|
|
uping.value = true;
|
2025-06-09 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
|
title: "上传出错",
|
|
|
|
|
icon: "error"
|
|
|
|
|
});
|
|
|
|
|
common_vendor.index.hideLoading();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-06-13 13:42:14 +08:00
|
|
|
|
const uping = common_vendor.ref(true);
|
2025-06-11 17:33:34 +08:00
|
|
|
|
const savephoto = (filePath, type) => {
|
2025-06-09 17:33:50 +08:00
|
|
|
|
common_vendor.index.uploadFile({
|
|
|
|
|
url: `${request_index.base_url}/sys/common/upload`,
|
|
|
|
|
// 替换为你的POST接口地址
|
|
|
|
|
filePath,
|
|
|
|
|
name: "file",
|
|
|
|
|
// 后端接收时的字段名
|
|
|
|
|
header: {
|
|
|
|
|
"X-Access-Token": common_vendor.index.getStorageSync("token") || ""
|
|
|
|
|
},
|
|
|
|
|
formData: {
|
|
|
|
|
biz: `temp`
|
|
|
|
|
},
|
|
|
|
|
success: (uploadRes) => {
|
2025-06-11 17:33:34 +08:00
|
|
|
|
if (!type) {
|
|
|
|
|
fontphoto.value = JSON.parse(uploadRes.data).message;
|
|
|
|
|
} else {
|
|
|
|
|
endphoto.value = JSON.parse(uploadRes.data).message;
|
|
|
|
|
}
|
2025-06-13 13:42:14 +08:00
|
|
|
|
uping.value = true;
|
2025-06-09 17:33:50 +08:00
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
|
title: "上传出错",
|
|
|
|
|
icon: "error"
|
|
|
|
|
});
|
|
|
|
|
common_vendor.index.hideLoading();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const openLook = (res) => {
|
|
|
|
|
if (res) {
|
|
|
|
|
content.value = res;
|
|
|
|
|
show.value = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const next = () => {
|
2025-06-27 08:55:44 +08:00
|
|
|
|
if (!fontphoto.value) {
|
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
|
title: "请上传身份证正面",
|
|
|
|
|
icon: "error"
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
} else if (!endphoto.value) {
|
|
|
|
|
common_vendor.index.showToast({
|
|
|
|
|
title: "请上传身份证背面",
|
|
|
|
|
icon: "error"
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-06-11 17:33:34 +08:00
|
|
|
|
const allNonEmpty = textArray.every((item) => {
|
|
|
|
|
return item !== "";
|
2025-06-09 17:33:50 +08:00
|
|
|
|
});
|
2025-06-13 13:42:14 +08:00
|
|
|
|
if (!uping.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-06-11 17:33:34 +08:00
|
|
|
|
if (allNonEmpty) {
|
|
|
|
|
const range = textArray[7];
|
|
|
|
|
const [start, end] = range.split("-");
|
2025-06-27 08:55:44 +08:00
|
|
|
|
let data = common_vendor.index.getStorageSync("backhuancun");
|
|
|
|
|
data.tel = common_vendor.index.getStorageSync("tel");
|
|
|
|
|
data.name = textArray[0];
|
|
|
|
|
data.sex = textArray[1];
|
|
|
|
|
data.idCard = textArray[2];
|
|
|
|
|
data.national = textArray[3];
|
|
|
|
|
data.birthDate = textArray[4];
|
|
|
|
|
data.idCardAddress = textArray[5];
|
|
|
|
|
data.issuingAuthority = textArray[6];
|
|
|
|
|
data.startTime = start;
|
|
|
|
|
data.endTime = end;
|
|
|
|
|
data.cardZmPath = fontphoto.value;
|
|
|
|
|
data.cardFmPath = endphoto.value;
|
|
|
|
|
common_vendor.index.setStorageSync("backhuancun", data);
|
|
|
|
|
common_vendor.index.navigateTo({
|
|
|
|
|
url: "/pages/addjigou/card"
|
2025-06-11 17:33:34 +08:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
common_vendor.index.showToast({
|
2025-06-27 08:55:44 +08:00
|
|
|
|
title: "身份证信息不完整",
|
2025-06-11 17:33:34 +08:00
|
|
|
|
icon: "error"
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-06-09 17:33:50 +08:00
|
|
|
|
};
|
|
|
|
|
const goBack = () => {
|
|
|
|
|
common_vendor.index.navigateBack();
|
|
|
|
|
};
|
|
|
|
|
common_vendor.onLoad(() => {
|
2025-06-13 13:42:14 +08:00
|
|
|
|
if (common_vendor.index.getStorageSync("baddata")) {
|
|
|
|
|
let data = common_vendor.index.getStorageSync("baddata");
|
|
|
|
|
textArray[0] = data.name;
|
|
|
|
|
textArray[1] = data.sex;
|
|
|
|
|
textArray[2] = data.idCard;
|
|
|
|
|
textArray[3] = data.national;
|
|
|
|
|
textArray[4] = data.birthDate;
|
|
|
|
|
textArray[5] = data.idCardAddress;
|
|
|
|
|
textArray[6] = data.issuingAuthority;
|
|
|
|
|
textArray[7] = `${data.startTime}-${data.endTime}`;
|
|
|
|
|
headImge.value = `${request_index.base_url}/sys/common/static/${data.cardZmPath}`;
|
|
|
|
|
backImge.value = `${request_index.base_url}/sys/common/static/${data.cardFmPath}`;
|
|
|
|
|
fontphoto.value = data.cardZmPath;
|
|
|
|
|
endphoto.value = data.cardFmPath;
|
|
|
|
|
}
|
2025-06-09 17:33:50 +08:00
|
|
|
|
});
|
2025-06-20 17:32:20 +08:00
|
|
|
|
common_vendor.onShow(() => {
|
|
|
|
|
const img = common_vendor.index.getStorageSync("imgkey0");
|
|
|
|
|
if (img) {
|
|
|
|
|
uploadImage(img);
|
|
|
|
|
common_vendor.index.removeStorageSync("imgkey0");
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-06-09 17:33:50 +08:00
|
|
|
|
return (_ctx, _cache) => {
|
2025-06-19 17:03:31 +08:00
|
|
|
|
return common_vendor.e({
|
2025-06-09 17:33:50 +08:00
|
|
|
|
a: common_vendor.o(($event) => show.value = $event),
|
|
|
|
|
b: common_vendor.p({
|
|
|
|
|
content: content.value,
|
|
|
|
|
modelValue: show.value
|
|
|
|
|
}),
|
2025-06-19 17:03:31 +08:00
|
|
|
|
c: common_vendor.o(goBack),
|
2025-06-27 08:55:44 +08:00
|
|
|
|
d: fontphoto.value ? `${common_vendor.unref(request_index.base_url)}/sys/common/static/${fontphoto.value}` : `https://www.focusnu.com/media/directive/index/IDcard.png`,
|
|
|
|
|
e: !fontphoto.value
|
|
|
|
|
}, !fontphoto.value ? {} : {}, {
|
2025-06-23 17:31:43 +08:00
|
|
|
|
f: common_vendor.o(($event) => selectphoto(0)),
|
2025-06-27 08:55:44 +08:00
|
|
|
|
g: endphoto.value ? `${common_vendor.unref(request_index.base_url)}/sys/common/static/${endphoto.value}` : `https://www.focusnu.com/media/directive/index/backIDcard.png`,
|
|
|
|
|
h: !endphoto.value
|
|
|
|
|
}, !endphoto.value ? {} : {}, {
|
2025-06-23 17:31:43 +08:00
|
|
|
|
i: common_vendor.o(($event) => selectphoto(1)),
|
2025-06-19 17:03:31 +08:00
|
|
|
|
j: common_vendor.f(nameArray, (item, index, i0) => {
|
2025-06-09 17:33:50 +08:00
|
|
|
|
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)
|
|
|
|
|
};
|
|
|
|
|
}),
|
2025-06-23 17:31:43 +08:00
|
|
|
|
k: common_vendor.o(next),
|
|
|
|
|
l: common_vendor.o(photoclick),
|
|
|
|
|
m: common_vendor.o(($event) => bottomshow.value = $event),
|
|
|
|
|
n: common_vendor.p({
|
|
|
|
|
list: bottomlist,
|
|
|
|
|
modelValue: bottomshow.value
|
|
|
|
|
})
|
2025-06-19 17:03:31 +08:00
|
|
|
|
});
|
2025-06-09 17:33:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4363d488"]]);
|
|
|
|
|
wx.createPage(MiniProgramPage);
|
|
|
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/addjigou/name.js.map
|