"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; const openid = common_vendor.computed(() => { return common_vendor.index.getStorageSync("openid"); }); const config = common_vendor.ref({ logoUrl: "" }); const form = common_vendor.ref({ icon: "" }); const sexList = common_vendor.ref([]); const typeList = common_vendor.ref([]); const placeList = common_vendor.ref([]); const ballYearsList = common_vendor.ref([]); common_vendor.onLoad(async () => { await searchOther(); await searchConfig(); await search(); common_vendor.index.$on("setCity", function(city) { form.value.city = city; }); }); const searchOther = async () => { let res; res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_sex" }); if (res.code === 200 && res.total > 0) sexList.value = res.rows; res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_type" }); if (res.code === 200 && res.total > 0) typeList.value = res.rows; res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_place" }); if (res.code === 200 && res.total > 0) placeList.value = res.rows; res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_year" }); if (res.code === 200 && res.total > 0) ballYearsList.value = res.rows; }; const searchConfig = async () => { config.value = common_vendor.index.getStorageSync("config"); }; const search = async () => { const res = await $api(`matchUser/find`, "GET", { openid: openid.value }); if (res.code === 200) { if (res.data) { form.value = res.data; form.value.sex = toData(form.value.sex, sexList.value); form.value.type = toData(form.value.type, typeList.value); form.value.place = toData(form.value.place, placeList.value); form.value.ballYears = toData(form.value.ballYears, ballYearsList.value); } else { common_vendor.index.navigateTo({ url: `/pages/login/index` }); } } else { common_vendor.index.showToast({ title: res.msg || "", icon: "error" }); } }; const toData = (value, list) => { if (value) return value = list[value].dictLabel; }; 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 sexChange = (e) => { const data = sexList.value[e.detail.value]; if (data) form.value.sex = data.dictLabel; }; const typeChange = (e) => { const data = typeList.value[e.detail.value]; if (data) form.value.type = data.dictLabel; }; const placeChange = (e) => { const data = placeList.value[e.detail.value]; if (data) form.value.place = data.dictLabel; }; const ballYearsChange = (e) => { const data = ballYearsList.value[e.detail.value]; if (data) form.value.ballYears = data.dictLabel; }; 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.icon = arr.url; } else { common_vendor.index.showToast({ title: arr.msg, icon: "none" }); } } }); }; const formSubmit = async (e) => { let data = e.detail.value; data.icon = form.value.icon; data = delEmptyQueryNodes(data); const arr = await $api(`matchUser`, "PUT", data); if (arr.code === 200) { search(); } else { common_vendor.index.showToast({ title: arr.msg, icon: "error" }); } }; 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.id, b: form.value.icon || config.value.logoUrl, c: common_vendor.o(Preview), d: form.value.name, e: form.value.nickname, f: common_vendor.t(form.value.sex || "请选择性别"), g: common_vendor.o(sexChange), h: _ctx.index, i: sexList.value, j: form.value.phone, k: form.value.city }, form.value.city ? { l: common_vendor.t(form.value.city) } : {}, { m: common_vendor.o(toCity), n: form.value.city, o: form.value.height, p: form.value.weight, q: common_vendor.t(form.value.type || "请选择主要项目"), r: common_vendor.o(typeChange), s: _ctx.index, t: typeList.value, v: common_vendor.t(form.value.ballYears || "请选择球龄"), w: common_vendor.o(ballYearsChange), x: _ctx.index, y: ballYearsList.value, z: common_vendor.t(form.value.place || "请选择队内位置"), A: common_vendor.o(placeChange), B: _ctx.index, C: placeList.value, D: common_vendor.o(formSubmit) }); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bf1a7b85"], ["__file", "D:/project/足球比赛/match_applet/pagesMy/basic/index.vue"]]); wx.createPage(MiniProgramPage);