"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"); _easycom_u_action_sheet2(); } const _easycom_u_action_sheet = () => "../../uni_modules/vk-uview-ui/components/u-action-sheet/u-action-sheet.js"; if (!Math) { (model + _easycom_u_action_sheet)(); } const model = () => "../../compontent/public/model.js"; const _sfc_main = { __name: "bankcard", setup(__props) { const show = common_vendor.ref(false); const content = common_vendor.ref(""); const bottomshow = common_vendor.ref(false); const bottomlist = [{ text: "拍摄图片", fontSize: 40 }, { text: "图片预览", fontSize: 40 }]; const nameArray = ["开户行", "开户行卡号"]; const textArray = common_vendor.reactive(["", ""]); const fontphoto = common_vendor.ref(""); const endphoto = common_vendor.ref(""); common_vendor.ref(0); 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(); } }; const tempImagePath = common_vendor.ref(""); const targetphoto = common_vendor.ref(0); const selectphoto = (number) => { if (!uping.value) { return; } targetphoto.value = number; common_vendor.index.__f__("log", "at pages/addstaff/bankcard.vue:150", "????", backImge.value, headImge.value); if (backImge.value && headImge.value) { bottomshow.value = true; } 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` }); }, fail: (err) => { common_vendor.index.__f__("error", "at pages/addstaff/bankcard.vue:173", "拍照失败:", err); } }); } const headImge = common_vendor.ref(""); const backImge = common_vendor.ref(""); function uploadImage(filePath) { uping.value = false; common_vendor.index.showLoading(); common_vendor.index.uploadFile({ url: `${request_index.base_url}/api/ocr/bankCard`, // 替换为您的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.hideLoading(); savephoto(filePath, targetphoto.value); return; } if (JSON.parse(JSON.parse(uploadRes.data).result.data).data.bankName) { let father = JSON.parse(JSON.parse(uploadRes.data).result.data).data; textArray[0] = father.bankName; textArray[1] = father.cardNumber; savephoto(filePath, targetphoto.value); } else { common_vendor.index.hideLoading(); uping.value = true; } }, fail: (err) => { common_vendor.index.showToast({ title: "上传出错", icon: "error" }); common_vendor.index.hideLoading(); } }); } const uping = common_vendor.ref(true); const savephoto = (filePath, type) => { 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) => { if (!type) { fontphoto.value = JSON.parse(uploadRes.data).message; headImge.value = filePath; } else { endphoto.value = JSON.parse(uploadRes.data).message; backImge.value = filePath; } common_vendor.index.hideLoading(); if (JSON.parse(uploadRes.data).code == 401) { 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: (uploadRes2) => { if (!type) { fontphoto.value = JSON.parse(uploadRes2.data).message; } else { endphoto.value = JSON.parse(uploadRes2.data).message; } uping.value = true; }, fail: (err) => { common_vendor.index.showToast({ title: "上传出错", icon: "error" }); common_vendor.index.hideLoading(); } }); } uping.value = true; }, fail: (err) => { common_vendor.index.showToast({ title: "上传出错", icon: "error" }); common_vendor.index.hideLoading(); } }); }; function isAtLeastEightChars(str) { return typeof str === "string" && str.length >= 12; } const openLook = (res) => { if (isAtLeastEightChars(res)) { content.value = res; show.value = true; } }; const next = () => { if (!uping.value) { return; } let data = common_vendor.index.getStorageSync("backhuancun"); data.openingBank = textArray[0]; data.bankCard = textArray[1]; data.bankZmPath = fontphoto.value; data.bankFmPath = endphoto.value; common_vendor.index.setStorageSync("backhuancun", data); common_vendor.index.navigateTo({ url: "/pages/addstaff/healthcertificate" }); }; const goBack = () => { if (!uping.value) { return; } if (textArray[0]) { let data = common_vendor.index.getStorageSync("backhuancun"); data.openingBank = textArray[0]; data.bankCard = textArray[1]; data.bankZmPath = fontphoto.value; data.bankFmPath = endphoto.value; common_vendor.index.setStorageSync("backhuancun", data); } common_vendor.index.navigateBack(); }; common_vendor.onLoad(() => { if (common_vendor.index.getStorageSync("backhuancun").openingBank) { let data = common_vendor.index.getStorageSync("backhuancun"); textArray[0] = data.openingBank; textArray[1] = data.bankCard; fontphoto.value = data.bankZmPath; endphoto.value = data.bankFmPath; } else if (common_vendor.index.getStorageSync("baddata")) { let data = common_vendor.index.getStorageSync("baddata"); textArray[0] = data.openingBank; textArray[1] = data.bankCard; fontphoto.value = data.bankZmPath; endphoto.value = data.bankFmPath; } }); 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({ a: common_vendor.o(($event) => show.value = false), b: common_vendor.p({ show: show.value, content: content.value }), c: common_vendor.o(goBack), d: fontphoto.value ? `${common_vendor.unref(request_index.base_url)}/sys/common/static/${fontphoto.value}` : `https://www.focusnu.com/media/directive/index/bankfront.png`, e: endphoto.value ? `` : `https://www.focusnu.com/media/directive/index/bian.png`, f: !fontphoto.value }, !fontphoto.value ? {} : {}, { g: common_vendor.o(($event) => selectphoto(0)), h: endphoto.value ? `${common_vendor.unref(request_index.base_url)}/sys/common/static/${endphoto.value}` : `https://www.focusnu.com/media/directive/index/bankend.png`, i: endphoto.value ? `` : `https://www.focusnu.com/media/directive/index/bian.png`, j: !endphoto.value }, !endphoto.value ? {} : {}, { k: common_vendor.o(($event) => selectphoto(1)), l: 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) }; }), m: common_vendor.o(goBack), n: common_vendor.o(next), o: common_vendor.o(photoclick), p: common_vendor.o(($event) => bottomshow.value = $event), q: common_vendor.p({ list: bottomlist, modelValue: bottomshow.value }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b0243273"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/addstaff/bankcard.js.map