Files
xiaokuaisong-paotui/distribution/unpackage/dist/dev/mp-alipay/pages/authentication/authentication.js
2025-08-18 09:57:10 +08:00

161 lines
4.6 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const API_api = require("../../API/api.js");
const _sfc_main = {
data() {
return {
photoSrcFront: "",
// 徽面照片路径
photoSrcBack: "",
// 人像面照片路径
bankCard: "",
// 银行卡号
submitRecord: {},
// 修改为对象
currentUser: common_vendor.index.getStorageSync("currentUser")
};
},
onLoad() {
this.getAuditRecords();
},
methods: {
takePhoto(side) {
const that = this;
common_vendor.index.chooseImage({
count: 1,
sourceType: ["camera"],
success(res) {
if (side === "front") {
that.photoSrcFront = res.tempFilePaths[0];
that.uploadPhoto(res.tempFilePaths[0], "front");
} else if (side === "back") {
that.photoSrcBack = res.tempFilePaths[0];
that.uploadPhoto(res.tempFilePaths[0], "back");
}
}
});
},
uploadPhoto(filePath, side) {
common_vendor.index.uploadFile({
url: API_api.apiImageUrl + "/api/file/upload/server",
filePath,
name: "file",
formData: {
biz: "card"
},
success: (res) => {
console.log("上传成功:", res);
},
fail: (err) => {
console.error("上传失败:", err);
}
});
},
submit() {
const data = {
backIdCard: this.photoSrcBack,
bankCard: this.bankCard,
errandId: this.currentUser.id,
frontIdCard: this.photoSrcFront
};
common_vendor.index.request({
url: API_api.apiImageUrl + "/api/errandAuth/add",
method: "POST",
data,
header: {
"Content-Type": "application/json",
// 确保设置正确的 Content-Type
"cookie": common_vendor.index.getStorageSync("cookie") || ""
},
success: (res) => {
console.log("提交成功:", res);
if (res.data.code === 4e4) {
common_vendor.index.showToast({
title: res.data.description,
icon: "fail",
duration: 2e3
});
} else if (res.data.code === 0) {
common_vendor.index.showToast({
title: "提交成功",
icon: "success",
duration: 2e3
});
}
},
fail: (err) => {
console.error("提交失败:", err);
}
});
},
getAuditRecords() {
common_vendor.index.request({
url: API_api.apiImageUrl + "/api/errandAuth/get/my",
method: "POST",
header: {
"Content-Type": "application/json",
// 确保设置正确的 Content-Type
"cookie": common_vendor.index.getStorageSync("cookie") || ""
},
success: (res) => {
console.log(res);
if (res.data.code === 0 && res.data.data) {
this.submitRecord = res.data.data;
}
},
fail: (err) => {
console.error("获取审核记录失败:", err);
}
});
}
}
};
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
_easycom_uni_icons2();
}
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
if (!Math) {
_easycom_uni_icons();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.bankCard,
b: common_vendor.o(($event) => $data.bankCard = $event.detail.value),
c: !$data.photoSrcFront
}, !$data.photoSrcFront ? {
d: common_vendor.p({
type: "plusempty",
size: "30",
color: "#6a7cbf"
})
} : {}, {
e: $data.photoSrcFront
}, $data.photoSrcFront ? {
f: $data.photoSrcFront
} : {}, {
g: common_vendor.o(($event) => $options.takePhoto("front")),
h: !$data.photoSrcBack
}, !$data.photoSrcBack ? {
i: common_vendor.p({
type: "plusempty",
size: "30",
color: "#6a7cbf"
})
} : {}, {
j: $data.photoSrcBack
}, $data.photoSrcBack ? {
k: $data.photoSrcBack
} : {}, {
l: common_vendor.o(($event) => $options.takePhoto("back")),
m: common_vendor.o((...args) => $options.submit && $options.submit(...args)),
n: $data.submitRecord
}, $data.submitRecord ? {
o: common_vendor.t($data.submitRecord.bankCard),
p: $data.submitRecord.frontIdCard,
q: $data.submitRecord.backIdCard
} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ae7e1909"]]);
my.createPage(MiniProgramPage);