"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; (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config; const $apifile = (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$apifile; common_vendor.computed(() => { return common_vendor.index.getStorageSync("openid"); }); const user = common_vendor.ref({}); const form = common_vendor.ref({}); const typeList = common_vendor.ref([]); common_vendor.onShow(() => { searchUser(); searchOther(); common_vendor.index.$on("setCity", function(city) { form.value.city = city; }); }); const searchUser = async () => { user.value = common_vendor.index.getStorageSync("user"); }; const searchOther = async () => { let res; res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_type" }); if (res.code === 200 && res.total > 0) typeList.value = res.rows; }; const typeChange = (e) => { const data = typeList.value[e.detail.value]; if (data) form.value.type = data.dictLabel; }; const dateChange = (e) => { form.value.date = e.detail.value; }; const toCity = () => { if (form.value.city) { common_vendor.index.navigateTo({ url: `/pagesHome/city/index?city=${form.value.city}` }); } else { common_vendor.index.navigateTo({ url: `/pagesHome/city/index` }); } }; const Preview = () => { common_vendor.index.chooseImage({ count: 1, sizeType: ["original", "compressed"], sourceType: ["album", "camera"], success: async function(res) { let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths)); const arr = await $apifile( `/common/upload`, "file", tempFile[0], "file" ); if (arr.code == 200) { form.value.logo = arr.url; } else { common_vendor.index.showToast({ title: arr.msg, icon: "none" }); } } }); }; const formSubmit = async (e) => { if (user.value.id) { let data = e.detail.value; data.logo = form.value.logo; data.city = form.value.city; data = delEmptyQueryNodes(data); data.userId = user.value.id; const arr = await $api(`team`, "POST", data); if (arr.code === 200) { common_vendor.index.navigateBack({ delta: 1 }); } else { common_vendor.index.showToast({ title: arr.msg, icon: "error" }); } } else { common_vendor.index.showToast({ title: `无用户信息 无法创建球队`, icon: "none" }); } }; const delEmptyQueryNodes = (obj = {}) => { Object.keys(obj).forEach((key) => { let value = obj[key]; value && typeof value === "object" && delEmptyQueryNodes(value); (value === "" || value === null || value === void 0 || value.length === 0 || Object.keys(value).length === 0) && delete obj[key]; }); return obj; }; return (_ctx, _cache) => { return common_vendor.e({ a: form.value.logo || "/static/qiudui.png", b: common_vendor.o(Preview), c: form.value.name, d: common_vendor.t(form.value.type || "请选择类型"), e: common_vendor.o(typeChange), f: _ctx.index, g: typeList.value, h: form.value.city }, form.value.city ? { i: common_vendor.t(form.value.city) } : {}, { j: common_vendor.o(toCity), k: common_vendor.t(form.value.date || "请选择成立时间"), l: common_vendor.o(dateChange), m: _ctx.index, n: form.value.color, o: form.value.brief, p: common_vendor.o(formSubmit) }); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-01c8185c"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/team/index.vue"]]); wx.createPage(MiniProgramPage);