"use strict";
|
const common_vendor = require("../../common/vendor.js");
|
const common_assets = require("../../common/assets.js");
|
const api_index = require("../../api/index.js");
|
const config_config = require("../../config/config.js");
|
const _sfc_main = {
|
__name: "index",
|
setup(__props) {
|
common_vendor.ref(config_config.BASE_URL);
|
function wxLogin() {
|
if (!common_vendor.index.getStorageSync("openId") || !common_vendor.index.getStorageSync("token")) {
|
common_vendor.wx$1.login({
|
success: async (res1) => {
|
common_vendor.index.setStorageSync("code", res1.code);
|
await api_index.wxLoginApi({
|
code: res1.code
|
}).then((res2) => {
|
if (res2.code == 200) {
|
common_vendor.index.redirectTo({
|
url: "/pages/layout/index"
|
});
|
common_vendor.index.setStorageSync("openId", res2.data.userId);
|
common_vendor.index.setStorageSync("token", res2.data.token);
|
} else {
|
common_vendor.index.showToast({
|
title: "登录失败",
|
icon: "none"
|
});
|
}
|
});
|
},
|
fail: (e) => {
|
common_vendor.index.showToast({
|
title: "微信登录失败,请退出重试!",
|
duration: 2e3,
|
icon: "fail"
|
});
|
}
|
});
|
} else {
|
common_vendor.index.redirectTo({
|
url: "/pages/layout/index"
|
});
|
}
|
}
|
return (_ctx, _cache) => {
|
return {
|
a: common_assets._imports_0,
|
b: common_assets._imports_1,
|
c: common_vendor.o(wxLogin)
|
};
|
};
|
}
|
};
|
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
|