179 lines
6.2 KiB
JavaScript
179 lines
6.2 KiB
JavaScript
|
"use strict";
|
||
|
const common_vendor = require("../../common/vendor.js");
|
||
|
const common_assets = require("../../common/assets.js");
|
||
|
const request_index = require("../../request/index.js");
|
||
|
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();
|
||
|
}
|
||
|
const _sfc_main = {
|
||
|
__name: "name",
|
||
|
setup(__props) {
|
||
|
const show = common_vendor.ref(false);
|
||
|
const content = common_vendor.ref("");
|
||
|
const nameArray = ["姓名", "性别", "身份证号码", "民族", "出生日期", "住址", "签发机关", "有效期限"];
|
||
|
const textArray = common_vendor.reactive(["", "", "", "", "", "", "", ""]);
|
||
|
const states = ["审核中", "审核未通过", "审核通过"];
|
||
|
const statesTarget = common_vendor.ref(0);
|
||
|
const shenhe = () => {
|
||
|
if (statesTarget.value == 2) {
|
||
|
statesTarget.value = 0;
|
||
|
} else {
|
||
|
statesTarget.value++;
|
||
|
}
|
||
|
};
|
||
|
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/addjigou/name.vue:128", "拍照失败:", err);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
const headImge = common_vendor.ref("");
|
||
|
const backImge = common_vendor.ref("");
|
||
|
function uploadImage(filePath) {
|
||
|
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) => {
|
||
|
common_vendor.index.__f__("log", "at pages/addjigou/name.vue:148", "token", common_vendor.index.getStorageSync("token"));
|
||
|
if (!JSON.parse(uploadRes.data).success) {
|
||
|
common_vendor.index.showToast({
|
||
|
title: "识别失败",
|
||
|
icon: "error"
|
||
|
});
|
||
|
common_vendor.index.hideLoading();
|
||
|
return;
|
||
|
}
|
||
|
savephoto(filePath);
|
||
|
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();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
const savephoto = (filePath) => {
|
||
|
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) => {
|
||
|
common_vendor.index.__f__("log", "at pages/addjigou/name.vue:203", "?????", uploadRes);
|
||
|
},
|
||
|
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 = () => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/addjigou/card"
|
||
|
});
|
||
|
};
|
||
|
const goBack = () => {
|
||
|
common_vendor.index.navigateBack();
|
||
|
};
|
||
|
common_vendor.onLoad(() => {
|
||
|
});
|
||
|
return (_ctx, _cache) => {
|
||
|
return {
|
||
|
a: common_vendor.o(($event) => show.value = $event),
|
||
|
b: common_vendor.p({
|
||
|
content: content.value,
|
||
|
modelValue: show.value
|
||
|
}),
|
||
|
c: common_assets._imports_0$6,
|
||
|
d: common_vendor.o(goBack),
|
||
|
e: common_vendor.t(states[statesTarget.value]),
|
||
|
f: common_vendor.n(!statesTarget.value ? `rightStautes` : statesTarget.value == 1 ? `rightStautesred` : `rightStautesblue`),
|
||
|
g: common_vendor.o(shenhe),
|
||
|
h: common_assets._imports_0$3,
|
||
|
i: headImge.value ? headImge.value : `/static/index/IDcard.png`,
|
||
|
j: !headImge.value,
|
||
|
k: common_assets._imports_1$5,
|
||
|
l: common_vendor.o(getMessage),
|
||
|
m: backImge.value ? backImge.value : `/static/index/backIDcard.png`,
|
||
|
n: !backImge.value,
|
||
|
o: common_assets._imports_1$5,
|
||
|
p: common_vendor.o(getMessage),
|
||
|
q: 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)
|
||
|
};
|
||
|
}),
|
||
|
r: common_vendor.o(next)
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
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
|