"use strict"; const common_vendor = require("../../common/vendor.js"); const common_js_util = require("../../common/js/util.js"); const api_index = require("../../api/index.js"); if (!Array) { const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); _easycom_uni_icons2(); } const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; if (!Math) { _easycom_uni_icons(); } const _sfc_main = { __name: "userinfo", setup(__props) { const store = common_vendor.useStore(); const user = common_vendor.reactive({}); const gender = [ { id: 1, name: "男" }, { id: 2, name: "女" } ]; const genderIndex = common_vendor.ref(0); common_vendor.onLoad(() => { syncInfo(); }); function syncInfo() { const userinfo = store.state.userinfo; user.background = userinfo.background; user.userPortrait = userinfo.userPortrait; user.userAccount = userinfo.userAccount; user.userNickname = userinfo.userNickname; user.userAddress = userinfo.userAddress; user.userBrief = userinfo.userBrief; user.userId = userinfo.userId; user.birth = userinfo.birth; genderIndex.value = gender.findIndex((item) => item.id == userinfo.userGender); } function handleBirthday(ev) { const value = ev.detail.value; if (user.birth === value) return; user.birth = value; } function handleGender(ev) { const value = ev.detail.value; if (genderIndex.value === value) return; genderIndex.value = value; } function uploadImg(key) { common_js_util.util.upload_image({ value: user[key], type: 1, success: (rs) => { user[key] = rs.value; } }); } function handleSubmit() { if (gender[genderIndex.value]) user.userGender = gender[genderIndex.value].id; const data = { ...user }; if (data.userPortrait) data.userPortrait = common_js_util.util.replace_url(data.userPortrait); if (data.background) data.background = common_js_util.util.replace_url(data.background); api_index.api.mine.updateUserInfo({ data }).then((rs) => { if (rs.code === 200) { store.commit("setState", { key: "userinfo", value: Object.assign(store.state.userinfo, user) }); common_js_util.util.alert("修改成功"); return; } common_js_util.util.alert({ content: rs.msg, showCancel: false }); }); } return (_ctx, _cache) => { return common_vendor.e({ a: user.background, b: user.userPortrait, c: common_vendor.o$1(($event) => uploadImg("userPortrait")), d: common_vendor.o$1(($event) => uploadImg("background")), e: common_vendor.t(user.userAccount), f: user.userNickname, g: common_vendor.o$1(($event) => user.userNickname = $event.detail.value), h: common_vendor.p({ type: "right" }), i: user.birth }, user.birth ? { j: common_vendor.t(user.birth) } : {}, { k: common_vendor.o$1(handleBirthday), l: common_vendor.p({ type: "right" }), m: genderIndex.value == -1 }, genderIndex.value == -1 ? {} : { n: common_vendor.t(gender[genderIndex.value].name) }, { o: gender, p: common_vendor.o$1(handleGender), q: common_vendor.p({ type: "right" }), r: user.userAddress, s: common_vendor.o$1(($event) => user.userAddress = $event.detail.value), t: common_vendor.p({ type: "right" }), v: user.userBrief, w: common_vendor.o$1(($event) => user.userBrief = $event.detail.value), x: common_vendor.o$1(handleSubmit) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4ef92957"]]); wx.createPage(MiniProgramPage);