1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
- __name: "index",
- setup(__props) {
- var _a, _b, _c;
- const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
- const $app = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$app;
- const $config = (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$config;
- const openid = common_vendor.computed(() => {
- return common_vendor.index.getStorageSync("openid");
- });
- const logoUrl = common_vendor.ref("");
- const initUser = async () => {
- common_vendor.index.login({
- success: async function(result) {
- if (!result.code) {
- common_vendor.index.showToast({
- title: "登录失败请重进!",
- icon: "fail"
- });
- return false;
- }
- if (!openid.value) {
- const res = await login(result.code);
- if (res)
- common_vendor.index.setStorageSync("openid", res);
- }
- common_vendor.index.redirectTo({
- url: "/pages/home/index"
- });
- }
- });
- };
- const login = async (js_code) => {
- const res = await $app("/wechat/api/login/app", "GET", {
- js_code,
- config: $config.wx_projectkey
- });
- if (res.errcode === 0)
- return res.data.openid;
- else {
- common_vendor.index.showToast({
- title: "登录失败请重进!",
- icon: "fail"
- });
- return false;
- }
- };
- const searchConfig = async () => {
- const res = await $api("/system/matchconfig/findOne", "GET", {});
- if (res.code === 200) {
- if (res.data) {
- logoUrl.value = res.data.logoUrl;
- common_vendor.index.setStorageSync("config", res.data);
- }
- } else {
- common_vendor.index.showToast({
- title: res.msg || "",
- icon: "error"
- });
- }
- };
- initUser();
- searchConfig();
- return (_ctx, _cache) => {
- return {
- a: logoUrl.value || "/static/logo.png"
- };
- };
- }
- });
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/project/足球比赛/match_applet/pages/index/index.vue"]]);
- wx.createPage(MiniProgramPage);
|