const _Http = getApp().globalData.http; Component({ properties: { groupname: { type: String, value: "" }, sys_phonebookgroupid: { type: [String, Number], value: 0 } }, data: { list: [], "content": { nocache: true, "type": 1, "pageNumber": 1, "pageTotal": 1, "pageSize": 20, "where": { "condition": "" } }, navList: [{ label: "我负责的", icon: "icon-webxialaxuanxiangjiantou", color: "", width: "", id: "1" }, { label: "筛选", icon: "icon-shaixuan", color: "", width: "", id: "2" }], classShow: false, classActions: [], filtratelist: [{ label: "标签", index: null, type: "checkbox", showName: "tag", //显示字段 valueKey: "tag", //返回Key selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象 value: "", //选中值 list: [{ tag: "关键决策人" }, { tag: "反对者" }, { tag: "支持者" }] }], total: 0 }, methods: { getList(init = false) { if (init.detail != undefined) init = init.detail; let content = this.data.content; if (init) { content.pageNumber = 1; content.pageTotal = 1; } if (content.pageNumber > content.pageTotal) return; content.groupname = this.data.groupname; content.sys_phonebookgroupid = this.data.sys_phonebookgroupid; if (this.data.classActions.length == 0) { this.setData({ classActions: wx.getStorageSync('templetList').map(v => { return { name: v.templetname, index: v.templetid } }), 'navList[0].label': wx.getStorageSync('templetList')[0].templetname }); content.type = wx.getStorageSync('templetList')[0].templetid; this.selectComponent("#ListBox").setHeight(".head", this); } return new Promise((resolve) => { _Http.basic({ "id": 20231220085804, content }).then(res => { console.log("联系人列表", res) this.selectComponent('#ListBox').RefreshToComplete(); resolve() if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }) content.pageTotal = res.pageTotal; content.pageNumber = res.pageNumber + 1; this.setData({ content, list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data), total: res.total }) }) }) }, insertRows() { wx.navigateTo({ url: `/packageA/contacts/insert?id=${this.data.sys_phonebookgroupid||0}&name=${this.data.groupname||'默认群组'}`, }); this.updateList() }, toDetail(e) { let { sys_phonebookid, sa_project_contactsid, contactsid, } = e.currentTarget.dataset.item; wx.navigateTo({ url: `/packageA/contacts/detail?id=${sys_phonebookid||0}&sa_project_contactsid=${sa_project_contactsid||0}&contactsid=${contactsid||0}`, }); this.updateList() }, updateList() { _Http.updateList = () => { let content = JSON.parse(JSON.stringify(this.data.content)); content.pageSize = (content.pageNumber - 1) * (content.pageSize || 20); console.log(content.pageSize) content.pageNumber = 1; _Http.basic({ "id": 20231220085804, content }).then(res => { console.log("更新联系人列表", res) this.setData({ list: res.data }) }) } }, classSelect({ detail }) { if (this.data.content.type == detail.index) return this.classClose(); this.setData({ "content.type": detail.index, 'navList[0].label': detail.name }) this.classClose(); this.getList(true) }, classClose() { this.setData({ classShow: false }) }, /* 顶部条件导航回调 */ navClick({ detail }) { switch (detail.id) { case '1': this.setData({ classShow: true }) break; case '2': this.setData({ 'filterShow': true }) break; } }, onSearch({ detail }) { this.data.content.where.condition = detail; this.getList(true) }, handleFilter({ detail }) { console.log("筛选项", detail) detail.condition = this.data.content.where.condition; if (getCurrentPages()[getCurrentPages().length - 1].__route__ == 'packageA/contacts/index') { if (detail.group) { this.data.groupname = detail.group.groupname; this.data.sys_phonebookgroupid = detail.group.sys_phonebookgroupid; } else { this.data.groupname = ""; this.data.sys_phonebookgroupid = 0; } delete(detail.group) } this.data.content.where = detail; this.getList(true); } } })