Files
frontend-app/unpackage/dist/dev/mp-weixin/components/common_card.js
T

168 lines
5.0 KiB
JavaScript
Raw Normal View History

2025-05-07 10:09:55 +08:00
"use strict";
2025-08-06 20:25:41 +08:00
const common_vendor = require("../common/vendor.js");
const api_common = require("../api/common.js");
const utils_enumUtils = require("../utils/enumUtils.js");
const utils_config = require("../utils/config.js");
const utils_auth = require("../utils/auth.js");
const _sfc_main = {
2025-05-07 10:09:55 +08:00
name: "common_card",
2025-08-06 20:25:41 +08:00
data() {
2025-05-07 10:09:55 +08:00
return {
2025-08-06 20:25:41 +08:00
uploadTemplList: [
{
id: 1,
title: "标准",
isOk: true,
url: "/static/common/ID_ok.png"
},
{
id: 2,
title: "边框缺失",
isOk: false,
url: "/static/common/ID_error_1.png"
},
{
id: 3,
title: "照片模糊",
isOk: false,
url: "/static/common/ID_error_2.png"
},
{
id: 4,
title: "闪光强烈",
isOk: false,
url: "/static/common/ID_error_3.png"
}
],
2025-05-07 10:09:55 +08:00
fileListZ: {},
// 身份正面照
2025-08-06 20:25:41 +08:00
fileListF: {}
// 身份反面照片
2025-05-07 10:09:55 +08:00
};
},
methods: {
2025-08-06 20:25:41 +08:00
deletePic(event) {
2025-05-07 10:09:55 +08:00
this.fileListZ.splice(event.index, 1);
},
2025-08-06 20:25:41 +08:00
phoneFun(type) {
let that = this;
common_vendor.index.chooseMedia({
2025-05-07 10:09:55 +08:00
count: 1,
// 默认为1,摄像头拍照为1,录像为10,录音为1
2025-08-06 20:25:41 +08:00
mediaType: ["image"],
2025-05-07 10:09:55 +08:00
// 可以指定是摄像头还是录像,这里两者都支持
2025-08-06 20:25:41 +08:00
sourceType: ["camera"],
2025-05-07 10:09:55 +08:00
// 可以指定来源是相册还是相机,这里只选相机
2025-08-06 20:25:41 +08:00
camera: "back",
2025-05-07 10:09:55 +08:00
// 可以指定使用前置还是后置摄像头,默认后置
2025-08-06 20:25:41 +08:00
success: (imgRes) => {
const filePath = imgRes.tempFiles[0].tempFilePath;
2025-05-07 10:09:55 +08:00
that.uploadFile(filePath, type);
},
2025-08-06 20:25:41 +08:00
fail: (err) => {
common_vendor.index.__f__("error", "at components/common_card.vue:87", err);
2025-05-07 10:09:55 +08:00
}
});
},
2025-08-06 20:25:41 +08:00
uploadFile(url, type) {
common_vendor.index.showLoading({
title: "图片上传中..."
2025-05-07 10:09:55 +08:00
});
2025-08-06 20:25:41 +08:00
const that = this;
const token = utils_auth.getStorageFun(utils_auth.TOKEN_NAME);
common_vendor.index.uploadFile({
url: utils_config.BASE_URL + api_common.uploadImg,
2025-05-07 10:09:55 +08:00
// 替换为你的上传接口URL
filePath: url,
2025-08-06 20:25:41 +08:00
name: "file",
2025-05-07 10:09:55 +08:00
formData: {
2025-08-06 20:25:41 +08:00
"type": utils_enumUtils.IMG_TYPE.COMMON
2025-05-07 10:09:55 +08:00
},
header: {
2025-08-06 20:25:41 +08:00
"Authorization": utils_config.Authorization,
"HSM-AUTH": token ? token : ""
2025-05-07 10:09:55 +08:00
},
2025-08-06 20:25:41 +08:00
success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data);
2025-05-07 10:09:55 +08:00
if (data.bizcode === 100) {
if (type === "Z") {
that.fileListZ = data.data;
2025-08-06 20:25:41 +08:00
this.$emit("valueFunc", "Z", data.data.dbUrl);
2025-05-07 10:09:55 +08:00
} else if (type === "F") {
that.fileListF = data.data;
2025-08-06 20:25:41 +08:00
this.$emit("valueFunc", "F", data.data.dbUrl);
2025-05-07 10:09:55 +08:00
}
} else {
2025-08-06 20:25:41 +08:00
common_vendor.index.showToast({
title: "图片上传失败",
icon: "none",
2025-05-07 10:09:55 +08:00
mask: true,
2025-08-06 20:25:41 +08:00
duration: 3e3
2025-05-07 10:09:55 +08:00
});
}
},
2025-08-06 20:25:41 +08:00
fail: (uploadFileErr) => {
common_vendor.index.showToast({
title: "图片上传失败",
icon: "none",
2025-05-07 10:09:55 +08:00
mask: true,
2025-08-06 20:25:41 +08:00
duration: 3e3
2025-05-07 10:09:55 +08:00
});
},
2025-08-06 20:25:41 +08:00
complete: (res) => {
common_vendor.index.hideLoading();
2025-05-07 10:09:55 +08:00
}
});
}
}
};
2025-08-06 20:25:41 +08:00
if (!Array) {
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
_easycom_up_image2();
}
const _easycom_up_image = () => "../uni_modules/uview-plus/components/u-image/u-image.js";
if (!Math) {
_easycom_up_image();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.p({
src: $data.fileListZ && Object.keys($data.fileListZ).length !== 0 ? $data.fileListZ.accessUrl : "/static/common/ID_rx.png",
width: "100%",
height: "90",
bgColor: "#f1f6ff00"
}),
b: common_vendor.o(($event) => $options.phoneFun("Z")),
c: common_vendor.p({
src: $data.fileListF && Object.keys($data.fileListF).length !== 0 ? $data.fileListF.accessUrl : "/static/common/ID_gq.png",
width: "100%",
height: "90",
bgColor: "#f1f6ff00"
}),
d: common_vendor.o(($event) => $options.phoneFun("F")),
e: common_vendor.f($data.uploadTemplList, (item, k0, i0) => {
return {
a: "185011ef-2-" + i0,
b: common_vendor.p({
src: item.url,
width: "100%",
height: "50",
bgColor: "#f1f6ff00"
}),
c: "185011ef-3-" + i0,
d: common_vendor.p({
src: item.isOk ? "/static/common/ID_ok_1.png" : "/static/common/ID_error.png",
width: "10",
height: "10",
bgColor: "#f1f6ff00"
}),
e: common_vendor.t(item.title),
f: item.id
};
})
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);
2025-05-07 10:09:55 +08:00
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/common_card.js.map