86 lines
2.9 KiB
JavaScript
86 lines
2.9 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const utils_api = require("../../utils/api.js");
|
|
if (!Array) {
|
|
const _easycom_t_input2 = common_vendor.resolveComponent("t-input");
|
|
const _easycom_t_button2 = common_vendor.resolveComponent("t-button");
|
|
(_easycom_t_input2 + _easycom_t_button2)();
|
|
}
|
|
const _easycom_t_input = () => "../../uni_modules/tdesign-uniapp/components/input/input.js";
|
|
const _easycom_t_button = () => "../../uni_modules/tdesign-uniapp/components/button/button.js";
|
|
if (!Math) {
|
|
(_easycom_t_input + _easycom_t_button)();
|
|
}
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "register",
|
|
setup(__props) {
|
|
const phone = common_vendor.ref("");
|
|
const nickname = common_vendor.ref("");
|
|
const loading = common_vendor.ref(false);
|
|
const register = async () => {
|
|
if (!phone.value || String(phone.value).length !== 11) {
|
|
common_vendor.index.showToast({
|
|
title: "请输入正确的手机号",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
if (!nickname.value || nickname.value.trim().length === 0) {
|
|
common_vendor.index.showToast({
|
|
title: "请输入昵称",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
loading.value = true;
|
|
try {
|
|
const res = await utils_api.api.auth.register("+86" + phone.value, nickname.value.trim());
|
|
common_vendor.index.setStorageSync("token", res.token);
|
|
common_vendor.index.setStorageSync("user", res.user);
|
|
common_vendor.index.showToast({
|
|
title: "注册成功",
|
|
icon: "success"
|
|
});
|
|
common_vendor.index.reLaunch({ url: "/pages/index/index" });
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/register/register.vue:95", "注册失败", error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
const goToLogin = () => {
|
|
common_vendor.index.navigateBack();
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.o(($event) => phone.value = $event),
|
|
b: common_vendor.p({
|
|
placeholder: "请输入手机号",
|
|
type: "number",
|
|
maxlength: 11,
|
|
clearable: true,
|
|
value: phone.value
|
|
}),
|
|
c: common_vendor.o(($event) => nickname.value = $event),
|
|
d: common_vendor.p({
|
|
placeholder: "请输入昵称",
|
|
maxlength: 20,
|
|
clearable: true,
|
|
value: nickname.value
|
|
}),
|
|
e: common_vendor.o(register),
|
|
f: common_vendor.p({
|
|
theme: "primary",
|
|
size: "large",
|
|
block: true,
|
|
loading: loading.value
|
|
}),
|
|
g: common_vendor.o(goToLogin)
|
|
};
|
|
};
|
|
}
|
|
});
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bac4a35d"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/register/register.js.map
|