hldy_xcx/unpackage/dist/dev/mp-weixin/pages/addjigou/card.js

274 lines
9.5 KiB
JavaScript
Raw Normal View History

2025-06-27 08:56:14 +08:00
"use strict";
const common_vendor = require("../../common/vendor.js");
const request_index = require("../../request/index.js");
if (!Array) {
const _easycom_u_action_sheet2 = common_vendor.resolveComponent("u-action-sheet");
2025-07-01 17:29:13 +08:00
_easycom_u_action_sheet2();
2025-06-27 08:56:14 +08:00
}
const _easycom_u_action_sheet = () => "../../uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.js";
if (!Math) {
2025-07-01 17:29:13 +08:00
(model + _easycom_u_action_sheet)();
2025-06-27 08:56:14 +08:00
}
2025-07-01 17:29:13 +08:00
const model = () => "../../compontent/public/model.js";
2025-06-27 08:56:14 +08:00
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 bottomlist = [{
2025-06-30 17:33:35 +08:00
text: "拍摄图片",
fontSize: 40
2025-06-27 08:56:14 +08:00
}, {
2025-06-30 17:33:35 +08:00
text: "图片预览",
fontSize: 40
2025-06-27 08:56:14 +08:00
}];
const bottomshow = common_vendor.ref(false);
const tempImagePath = common_vendor.ref("");
const selectphoto = (number) => {
if (!uping.value) {
return;
}
if (headImge.value) {
bottomshow.value = true;
} else {
getMessage();
}
};
const photoclick = (element) => {
if (element) {
common_vendor.index.previewImage({
urls: [headImge.value],
// 必填,所有要预览的图片地址数组
current: headImge.value,
// 可选,当前显示图片的地址,默认是 urls[0]
indicator: "default",
// 可选指示器样式H5/App 有效,值为 'default'(圆点)或 'number'(数字)
longPressActions: {
// 可选,仅 App 支持,长按图片时弹出的操作项
itemList: ["保存图片到相册"]
}
});
} else {
getMessage();
}
};
function getMessage() {
common_vendor.index.chooseImage({
count: 1,
sourceType: ["album", "camera"],
success: (chooseRes) => {
tempImagePath.value = chooseRes.tempFilePaths[0];
common_vendor.index.navigateTo({
url: `/compontent/public/camera?url=${chooseRes.tempFilePaths[0]}&type=0&size=1`
});
},
fail: (err) => {
2025-07-01 17:29:13 +08:00
common_vendor.index.__f__("error", "at pages/addjigou/card.vue:144", "拍照失败:", err);
2025-06-27 08:56:14 +08:00
}
});
}
const headImge = common_vendor.ref("");
common_vendor.ref("");
const uping = common_vendor.ref(true);
function uploadImage(filePath) {
uping.value = false;
common_vendor.index.showLoading();
common_vendor.index.uploadFile({
url: `${request_index.base_url}/api/ocr/businessLicense`,
2025-06-30 17:33:35 +08:00
// 替换为您的POST接口地址
2025-06-27 08:56:14 +08:00
filePath,
name: "file",
// 后端接收时的字段名
header: {
"X-Access-Token": common_vendor.index.getStorageSync("token") || ""
},
formData: {},
success: (uploadRes) => {
if (!JSON.parse(uploadRes.data).success) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "识别失败",
icon: "error",
duration: 2e3
});
uping.value = true;
return;
}
2025-07-01 17:29:13 +08:00
common_vendor.index.__f__("log", "at pages/addjigou/card.vue:177", "营业执照", JSON.parse(JSON.parse(uploadRes.data).result.data).data);
2025-06-27 08:56:14 +08:00
if (JSON.parse(JSON.parse(uploadRes.data).result.data).data.companyName) {
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;
savephoto(filePath);
} else {
common_vendor.index.showToast({
title: "识别失败",
icon: "error",
duration: 2e3
});
uping.value = true;
common_vendor.index.hideLoading();
}
common_vendor.index.hideLoading();
},
fail: (err) => {
common_vendor.index.showToast({
title: "上传出错",
icon: "error"
});
common_vendor.index.hideLoading();
}
});
}
const fontphoto = common_vendor.ref("");
const savephoto = (filePath) => {
common_vendor.index.uploadFile({
url: `${request_index.base_url}/sys/common/upload`,
2025-06-30 17:33:35 +08:00
// 替换为您的POST接口地址
2025-06-27 08:56:14 +08:00
filePath,
name: "file",
// 后端接收时的字段名
header: {
"X-Access-Token": common_vendor.index.getStorageSync("token") || ""
},
formData: {
biz: `temp`
},
success: (uploadRes) => {
fontphoto.value = JSON.parse(uploadRes.data).message;
uping.value = true;
},
fail: (err) => {
common_vendor.index.showToast({
title: "上传出错",
icon: "error"
});
common_vendor.index.hideLoading();
}
});
};
2025-07-01 17:29:13 +08:00
function isAtLeastEightChars(str) {
return typeof str === "string" && str.length >= 8;
}
2025-06-27 08:56:14 +08:00
const openLook = (res) => {
2025-07-01 17:29:13 +08:00
if (isAtLeastEightChars(res)) {
2025-06-27 08:56:14 +08:00
content.value = res;
show.value = true;
}
};
const next = () => {
if (!uping.value) {
return;
}
const allNonEmpty = textArray[0];
if (allNonEmpty) {
let data = common_vendor.index.getStorageSync("backhuancun");
data.comName = textArray[0];
data.comRegisterAddress = textArray[1];
data.comCreditCode = textArray[2];
data.comLegalPerson = textArray[3];
data.comBusinessLicense = fontphoto.value;
common_vendor.index.setStorageSync("backhuancun", data);
common_vendor.index.navigateTo({
url: "/pages/addjigou/where"
});
} else {
common_vendor.index.showToast({
title: "请上传营业执照",
icon: "error"
});
}
};
common_vendor.onLoad(() => {
if (common_vendor.index.getStorageSync("backhuancun").comName) {
let data = common_vendor.index.getStorageSync("backhuancun");
if (data.comName) {
textArray[0] = data.comName;
textArray[1] = data.comRegisterAddress;
textArray[2] = data.comCreditCode;
textArray[3] = data.comLegalPerson;
if (data.comBusinessLicense) {
headImge.value = `${request_index.base_url}/sys/common/static/${data.comBusinessLicense}`;
fontphoto.value = data.comBusinessLicense;
}
}
} else if (common_vendor.index.getStorageSync("baddata")) {
let data = common_vendor.index.getStorageSync("baddata");
if (data.comName) {
textArray[0] = data.comName;
textArray[1] = data.comRegisterAddress;
textArray[2] = data.comCreditCode;
textArray[3] = data.comLegalPerson;
2025-06-30 17:33:35 +08:00
let data0 = common_vendor.index.getStorageSync("backhuancun");
data0.comName = data.id;
common_vendor.index.setStorageSync("backhuancun", data);
2025-06-27 08:56:14 +08:00
if (data.comBusinessLicense) {
headImge.value = `${request_index.base_url}/sys/common/static/${data.comBusinessLicense}`;
fontphoto.value = data.comBusinessLicense;
}
}
}
});
const goBack = () => {
if (!uping.value) {
return;
}
if (textArray[0]) {
let data = common_vendor.index.getStorageSync("backhuancun");
data.comName = textArray[0];
data.comRegisterAddress = textArray[1];
data.comCreditCode = textArray[2];
data.comLegalPerson = textArray[3];
data.comBusinessLicense = fontphoto.value;
common_vendor.index.setStorageSync("backhuancun", data);
}
common_vendor.index.navigateBack();
};
common_vendor.onShow(() => {
const img = common_vendor.index.getStorageSync("imgkey0");
if (img) {
uploadImage(img);
common_vendor.index.removeStorageSync("imgkey0");
}
});
return (_ctx, _cache) => {
return common_vendor.e({
2025-07-01 17:29:13 +08:00
a: common_vendor.o(($event) => show.value = false),
2025-06-27 08:56:14 +08:00
b: common_vendor.p({
2025-07-01 17:29:13 +08:00
show: show.value,
content: content.value
2025-06-27 08:56:14 +08:00
}),
c: common_vendor.o(goBack),
d: headImge.value ? headImge.value : `https://www.focusnu.com/media/directive/index/zhizhao.png`,
e: !headImge.value
}, !headImge.value ? {} : {}, {
f: common_vendor.o(selectphoto),
g: 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)
};
}),
h: common_vendor.o(goBack),
i: common_vendor.o(next),
j: common_vendor.o(photoclick),
k: common_vendor.o(($event) => bottomshow.value = $event),
l: common_vendor.p({
list: bottomlist,
modelValue: bottomshow.value
})
});
};
}
};
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