48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const utils_request = require("../../utils/request.js");
|
|
const store_user = require("../../store/user.js");
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "index",
|
|
setup(__props) {
|
|
const loading = common_vendor.ref(false);
|
|
const userStore = store_user.useUserStore();
|
|
async function handleLogin() {
|
|
if (loading.value)
|
|
return;
|
|
loading.value = true;
|
|
try {
|
|
await utils_request.autoLogin();
|
|
await userStore.fetchProfile();
|
|
common_vendor.index.showToast({ title: "登录成功", icon: "success" });
|
|
setTimeout(() => {
|
|
common_vendor.index.navigateBack({ delta: 1, fail: () => {
|
|
common_vendor.index.switchTab({ url: "/pages/index/index" });
|
|
} });
|
|
}, 500);
|
|
} catch {
|
|
common_vendor.index.showToast({ title: "登录失败,请重试", icon: "none" });
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
function goBack() {
|
|
common_vendor.index.navigateBack({ delta: 1, fail: () => {
|
|
common_vendor.index.switchTab({ url: "/pages/index/index" });
|
|
} });
|
|
}
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_assets._imports_0$1,
|
|
b: loading.value,
|
|
c: common_vendor.o(handleLogin),
|
|
d: common_vendor.o(goBack)
|
|
};
|
|
};
|
|
}
|
|
});
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d08ef7d4"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/index.js.map
|