"use strict"; const common_vendor = require("../../common/vendor.js"); const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js"); const _sfc_main = { mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin], data() { return { searchText: "", users: [], // 改为空数组,由接口获取 statusBarHeight: 0, showSuggestList: false, suggestList: [], searchBarOffset: 0, searchBarTop: 0, contentOffset: 0, navBarRealHeight: 0, searchBarHeight: 70 // px }; }, computed: { filteredUsers() { if (!this.searchText) return this.users; return this.users.filter( (u) => u.name.includes(this.searchText) || u.phone.includes(this.searchText) || u.role && u.role.includes(this.searchText) ); }, navbarStyle() { return `padding-top: ${this.statusBarHeight}px;`; } }, onLoad() { common_vendor.index.getSystemInfo({ success: (res) => { this.statusBarHeight = res.statusBarHeight || 20; } }); this.$nextTick(() => { common_vendor.index.createSelectorQuery().select(".navbar").boundingClientRect((rect) => { if (rect) { this.navBarRealHeight = rect.height; } }).exec(); }); this.refreshData(); }, methods: { goBack() { common_vendor.index.navigateBack(); }, onInput(e) { const val = e.detail.value; this.searchText = val; if (val) { this.suggestList = this.users.map((u) => u.phone).filter((phone) => phone.includes(val)); this.showSuggestList = this.suggestList.length > 0; } else { this.showSuggestList = false; } }, clearInput() { this.searchText = ""; this.showSuggestList = false; }, cancelSearch() { this.clearInput(); }, highlightMatch(phone, keyword) { if (!keyword) return [{ name: "span", children: [phone] }]; const idx = phone.indexOf(keyword); if (idx === -1) return [{ name: "span", children: [phone] }]; const before = phone.slice(0, idx); const match = phone.slice(idx, idx + keyword.length); const after = phone.slice(idx + keyword.length); return [ { name: "span", children: [before] }, { name: "span", attrs: { style: "color:#ff8917" }, children: [match] }, { name: "span", children: [after] } ]; }, goUserDetail(user) { const avatar = user.avatar || user.avatarUrl || ""; common_vendor.index.navigateTo({ url: "/pages/manager/user-detail", success: (res) => { res.eventChannel.emit("userDetail", { ...user, avatar }); } }); }, async refreshData() { try { const res = await this.$api("getInfoTeamListPage", { pageSize: 1e3, current: 1 }); if (res && res.code === 200 && res.result && Array.isArray(res.result.records)) { this.users = res.result.records.map((user) => ({ id: user.id, name: user.name || user.nickName || "-", phone: user.phone || "-", role: user.isTuiRole === "Y" ? "推广官" : "", blocked: user.isBlack === "Y", avatar: user.headImage || user.avatar || user.avatarUrl || "" })); } } catch (error) { common_vendor.index.__f__("error", "at pages/manager/user.vue:171", "获取用户列表失败:", error); common_vendor.index.showToast({ title: "获取用户列表失败", icon: "none" }); } }, async onRefresh() { await this.refreshData && this.refreshData(); } }, onPullDownRefresh() { this.refreshData && this.refreshData(); common_vendor.index.stopPullDownRefresh(); } }; 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(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.p({ type: "back", size: "24", color: "#222" }), b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)), c: common_vendor.s($options.navbarStyle), d: common_vendor.p({ type: "search", size: "22", color: "#bfbfbf" }), e: common_vendor.o([($event) => $data.searchText = $event.detail.value, (...args) => $options.onInput && $options.onInput(...args)]), f: $data.searchText, g: $data.searchText.length }, $data.searchText.length ? { h: common_vendor.p({ type: "closeempty", size: "22", color: "#bfbfbf" }), i: common_vendor.o((...args) => $options.clearInput && $options.clearInput(...args)) } : {}, { j: $data.searchText.length }, $data.searchText.length ? { k: common_vendor.o((...args) => $options.cancelSearch && $options.cancelSearch(...args)) } : {}, { l: $data.navBarRealHeight + "px", m: $data.showSuggestList }, $data.showSuggestList ? { n: common_vendor.f($data.suggestList, (item, idx, i0) => { return { a: "1d5a9178-3-" + i0, b: $options.highlightMatch(item, $data.searchText), c: idx }; }), o: common_vendor.p({ type: "search", size: "22", color: "#bfbfbf" }), p: $data.navBarRealHeight + $data.searchBarHeight + "px" } : {}, { q: !$data.showSuggestList }, !$data.showSuggestList ? { r: common_vendor.f($options.filteredUsers, (user, idx, i0) => { return common_vendor.e({ a: common_vendor.t(user.name), b: common_vendor.t(user.phone), c: user.role }, user.role ? common_vendor.e({ d: user.role === "推广官" }, user.role === "推广官" ? {} : { e: common_vendor.t(user.role) }) : {}, { f: user.blocked }, user.blocked ? {} : {}, { g: idx, h: common_vendor.o(($event) => $options.goUserDetail(user), idx) }); }), s: $data.navBarRealHeight + $data.searchBarHeight + "px" } : {}); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1d5a9178"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/manager/user.js.map