acdr-ui/dist/dev/mp-weixin/pages/permission/real-name-auth.js

105 lines
3.5 KiB
JavaScript
Raw Normal View History

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());
});
};
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");
if (!Array) {
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
_component_layout_default_uni();
}
if (!Math) {
TopBar();
}
const TopBar = () => "../../components/TopBar.js";
const _sfc_main = {
__name: "real-name-auth",
setup(__props) {
const frontImage = common_vendor.ref("/static/permission/idcard.png");
const backImage = common_vendor.ref("/static/permission/idcard_back.png");
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);
user.setUserInfo({ isRealName: true });
}
common_vendor.index.showToast({ title: "提交认证成功", icon: "none" });
} catch (error) {
console.error(error);
if (error.statusCode == 413) {
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);
//# sourceMappingURL=real-name-auth.js.map