108 lines
3.7 KiB
JavaScript
108 lines
3.7 KiB
JavaScript
"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(utils_commUtils.imgUrl("@/static/permission/idcard.png"));
|
|
const backImage = common_vendor.ref(utils_commUtils.imgUrl("@/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);
|
|
if (uploadRes.code === 200) {
|
|
user.setUserInfo({ isRealName: true });
|
|
utils_commUtils.toast("实名认证成功!");
|
|
} else {
|
|
utils_commUtils.toast(uploadRes.msg || "认证失败,请重新认证!");
|
|
}
|
|
}
|
|
} 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);
|