168 lines
5.0 KiB
JavaScript
168 lines
5.0 KiB
JavaScript
"use strict";
|
|||
|
|
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 = {
|
||
|
|
name: "common_card",
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
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"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
fileListZ: {},
|
||
|
|
// 身份正面照
|
||
|
|
fileListF: {}
|
||
|
|
// 身份反面照片
|
||
|
|
};
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
deletePic(event) {
|
||
|
|
this.fileListZ.splice(event.index, 1);
|
||
|
|
},
|
||
|
|
phoneFun(type) {
|
||
|
|
let that = this;
|
||
|
|
common_vendor.index.chooseMedia({
|
||
|
|
count: 1,
|
||
|
|
// 默认为1,摄像头拍照为1,录像为10,录音为1
|
||
|
|
mediaType: ["image"],
|
||
|
|
// 可以指定是摄像头还是录像,这里两者都支持
|
||
|
|
sourceType: ["camera"],
|
||
|
|
// 可以指定来源是相册还是相机,这里只选相机
|
||
|
|
camera: "back",
|
||
|
|
// 可以指定使用前置还是后置摄像头,默认后置
|
||
|
|
success: (imgRes) => {
|
||
|
|
const filePath = imgRes.tempFiles[0].tempFilePath;
|
||
|
|
that.uploadFile(filePath, type);
|
||
|
|
},
|
||
|
|
fail: (err) => {
|
||
|
|
common_vendor.index.__f__("error", "at components/common_card.vue:87", err);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
uploadFile(url, type) {
|
||
|
|
common_vendor.index.showLoading({
|
||
|
|
title: "图片上传中..."
|
||
|
|
});
|
||
|
|
const that = this;
|
||
|
|
const token = utils_auth.getStorageFun(utils_auth.TOKEN_NAME);
|
||
|
|
common_vendor.index.uploadFile({
|
||
|
|
url: utils_config.BASE_URL + api_common.uploadImg,
|
||
|
|
// 替换为你的上传接口URL
|
||
|
|
filePath: url,
|
||
|
|
name: "file",
|
||
|
|
formData: {
|
||
|
|
"type": utils_enumUtils.IMG_TYPE.COMMON
|
||
|
|
},
|
||
|
|
header: {
|
||
|
|
"Authorization": utils_config.Authorization,
|
||
|
|
"HSM-AUTH": token ? token : ""
|
||
|
|
},
|
||
|
|
success: (uploadFileRes) => {
|
||
|
|
const data = JSON.parse(uploadFileRes.data);
|
||
|
|
if (data.bizcode === 100) {
|
||
|
|
if (type === "Z") {
|
||
|
|
that.fileListZ = data.data;
|
||
|
|
this.$emit("valueFunc", "Z", data.data.dbUrl);
|
||
|
|
} else if (type === "F") {
|
||
|
|
that.fileListF = data.data;
|
||
|
|
this.$emit("valueFunc", "F", data.data.dbUrl);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
common_vendor.index.showToast({
|
||
|
|
title: "图片上传失败",
|
||
|
|
icon: "none",
|
||
|
|
mask: true,
|
||
|
|
duration: 3e3
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
fail: (uploadFileErr) => {
|
||
|
|
common_vendor.index.showToast({
|
||
|
|
title: "图片上传失败",
|
||
|
|
icon: "none",
|
||
|
|
mask: true,
|
||
|
|
duration: 3e3
|
||
|
|
});
|
||
|
|
},
|
||
|
|
complete: (res) => {
|
||
|
|
common_vendor.index.hideLoading();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
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: "7acb6ad4-2-" + i0,
|
||
|
|
b: common_vendor.p({
|
||
|
|
src: item.url,
|
||
|
|
width: "100%",
|
||
|
|
height: "50",
|
||
|
|
bgColor: "#f1f6ff00"
|
||
|
|
}),
|
||
|
|
c: "7acb6ad4-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);
|
||
|
|
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/common_card.js.map
|