2024-09-19 07:20:14 +08:00
|
|
|
"use strict";
|
|
|
|
var __async = (__this, __arguments, generator) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
var fulfilled = (value) => {
|
|
|
|
try {
|
|
|
|
step(generator.next(value));
|
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var rejected = (value) => {
|
|
|
|
try {
|
|
|
|
step(generator.throw(value));
|
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
|
|
});
|
|
|
|
};
|
2024-10-01 09:15:35 +08:00
|
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
|
|
const utils_http = require("../../../utils/http.js");
|
|
|
|
require("../../../store/index.js");
|
|
|
|
const utils_commUtils = require("../../../utils/commUtils.js");
|
|
|
|
const store_user = require("../../../store/user.js");
|
2024-09-19 07:20:14 +08:00
|
|
|
if (!Array) {
|
|
|
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
|
|
|
_component_layout_default_uni();
|
|
|
|
}
|
|
|
|
if (!Math) {
|
|
|
|
TopBar();
|
|
|
|
}
|
2024-10-01 09:15:35 +08:00
|
|
|
const TopBar = () => "../../../components/TopBar.js";
|
2024-09-19 07:20:14 +08:00
|
|
|
const _sfc_main = {
|
|
|
|
__name: "real-name-auth",
|
|
|
|
setup(__props) {
|
2024-10-01 09:15:35 +08:00
|
|
|
const frontImage = common_vendor.ref(utils_commUtils.imgUrl("@/static/permission/idcard.png"));
|
|
|
|
const backImage = common_vendor.ref(utils_commUtils.imgUrl("@/static/permission/idcard_back.png"));
|
2024-09-19 07:20:14 +08:00
|
|
|
const frontImagePath = common_vendor.ref(null);
|
|
|
|
const backImagePath = common_vendor.ref(null);
|
|
|
|
const user = store_user.useUserStore();
|
|
|
|
const chooseFrontImage = () => {
|
|
|
|
common_vendor.index.chooseImage({
|
|
|
|
count: 1,
|
|
|
|
success: (res) => {
|
|
|
|
frontImagePath.value = res.tempFilePaths[0];
|
|
|
|
frontImage.value = frontImagePath.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const chooseBackImage = () => {
|
|
|
|
common_vendor.index.chooseImage({
|
|
|
|
count: 1,
|
|
|
|
success: (res) => {
|
|
|
|
backImagePath.value = res.tempFilePaths[0];
|
|
|
|
backImage.value = backImagePath.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const submitAuth = () => __async(this, null, function* () {
|
|
|
|
if (!frontImagePath.value) {
|
|
|
|
common_vendor.index.showToast({ title: "请选择身份证人像面图片", icon: "none" });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!backImagePath.value) {
|
|
|
|
common_vendor.index.showToast({ title: "请选择身份证国徽面图片", icon: "none" });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
common_vendor.index.showToast({ title: "提交认证中", icon: "loading" });
|
|
|
|
if (frontImagePath.value) {
|
|
|
|
const uploadRes = yield utils_http.httpUploadFile("/auth", frontImagePath.value, "file", {
|
|
|
|
type: "front"
|
|
|
|
});
|
|
|
|
console.log(uploadRes);
|
2024-10-01 09:15:35 +08:00
|
|
|
if (uploadRes.code === 200) {
|
|
|
|
user.setUserInfo({ isRealName: true });
|
|
|
|
utils_commUtils.toast("实名认证成功!");
|
|
|
|
} else {
|
|
|
|
utils_commUtils.toast(uploadRes.msg || "认证失败,请重新认证!");
|
|
|
|
}
|
2024-09-19 07:20:14 +08:00
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
2024-10-01 09:15:35 +08:00
|
|
|
if (error.statusCode === 413) {
|
2024-09-19 07:20:14 +08:00
|
|
|
common_vendor.index.showToast({ title: "图片大小不能超过 1MB", icon: "none" });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
common_vendor.index.showToast({ title: "提交认证失败", icon: "none" });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return (_ctx, _cache) => {
|
|
|
|
return common_vendor.e({
|
|
|
|
a: !common_vendor.unref(user).userInfo.isRealName
|
|
|
|
}, !common_vendor.unref(user).userInfo.isRealName ? {
|
|
|
|
b: frontImage.value,
|
|
|
|
c: common_vendor.o(chooseFrontImage),
|
|
|
|
d: backImage.value,
|
|
|
|
e: common_vendor.o(chooseBackImage),
|
|
|
|
f: common_vendor.o(submitAuth),
|
|
|
|
g: common_vendor.o(($event) => common_vendor.unref(utils_commUtils.toPath)("/"))
|
|
|
|
} : {});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
wx.createPage(_sfc_main);
|