118 lines
4.0 KiB
JavaScript
118 lines
4.0 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: "card",
|
||
|
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/addjigou/card.vue:96", "拍照失败:", err);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
const headImge = common_vendor.ref("");
|
||
|
common_vendor.ref("");
|
||
|
function uploadImage(filePath) {
|
||
|
common_vendor.index.showLoading();
|
||
|
common_vendor.index.uploadFile({
|
||
|
url: `${request_index.base_url}/api/ocr/businessLicense`,
|
||
|
// 替换为你的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;
|
||
|
}
|
||
|
common_vendor.index.__f__("log", "at pages/addjigou/card.vue:124", "营业执照", JSON.parse(JSON.parse(uploadRes.data).result.data).data);
|
||
|
let father = JSON.parse(JSON.parse(uploadRes.data).result.data).data;
|
||
|
textArray[0] = father.companyName;
|
||
|
textArray[1] = father.businessAddress;
|
||
|
textArray[2] = father.creditCode;
|
||
|
textArray[3] = father.legalPerson;
|
||
|
headImge.value = filePath;
|
||
|
common_vendor.index.hideLoading();
|
||
|
},
|
||
|
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/where"
|
||
|
});
|
||
|
};
|
||
|
const goBack = () => {
|
||
|
common_vendor.index.navigateBack();
|
||
|
};
|
||
|
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$3,
|
||
|
d: headImge.value ? headImge.value : `/static/index/zhizhao.png`,
|
||
|
e: !headImge.value,
|
||
|
f: common_assets._imports_1$5,
|
||
|
g: common_vendor.o(getMessage),
|
||
|
h: 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)
|
||
|
};
|
||
|
}),
|
||
|
i: common_vendor.o(goBack),
|
||
|
j: common_vendor.o(next)
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-402780bb"]]);
|
||
|
wx.createPage(MiniProgramPage);
|
||
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/addjigou/card.js.map
|