const content = { pageNumber: 1, pageTotal: 1 }, _Http = getApp().globalData.http; let sa_brandid = null, downCount = null; Component({ options: { addGlobalClass: true }, data: { CustomBar: getApp().globalData.CustomBar, typeList: [], list: [], filtratelist: [], popupShow: false }, methods: { init() { content.where = { condition: "", itemclassid: "", tradefield: "" } this.getBrand(); this.getTradefie(); return true; }, /* 获取品牌 */ getBrand() { _Http.basic({ "id": 20220924163702, content: { nocache: true, pageSize: 999, } }).then(res => { console.log("查询品牌", res) if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }); if (res.data.length != 0) { sa_brandid = res.data[0].sa_brandid; this.getTypeList(); } else { wx.showToast({ title: '未查询到授权品牌', icon: "none" }) } }) }, /* 获取分类 */ getTypeList() { _Http.basic({ "id": "20220922110403", pageSize: 1000, content: { nocache: true, sa_brandid: sa_brandid, where: { istool: 0, ishide: 0 } } }).then(res => { console.log("营销类别", res) if (res.data.length) { res.data[0].ttemclass.unshift({ itemclassid: "", itemclassfullname: "全部", itemclassname: "全部", subdep: [] }) this.setData({ itemClasss: [res.data[0].ttemclass] }); try { this.selectAllComponents('#class0').filter(v => { v.setData({ active: 0 }) }) } catch {} } this.getList(true); }) }, itemClasssChange(e) { let detail = e.detail; content.where.itemclassid = detail.item.itemclassid; let itemClasss = this.data.itemClasss, subdep = detail.item.subdep; itemClasss = itemClasss.slice(0, detail.rowIndex + 1); /* if (subdep.length) { subdep.unshift({ itemclassid: detail.item.itemclassid, itemclassfullname: "全部", itemclassname: "全部", subdep: [] }) itemClasss.push(subdep) this.selectAllComponents('#class' + (detail.rowIndex - 0 + 1)).filter(v => v.setData({ active: 0 })) } */ this.setData({ itemClasss }) itemClasss.push(subdep) this.setData({ itemClasss }) this.getList(true); }, /* 获取产品 */ getList(init = false) { if (init.detail != undefined) init = init.detail; if (init) content.pageNumber = 1; if (content.pageNumber > content.pageTotal) return; content.brandids = [sa_brandid]; _Http.basic({ "id": 20220926142203, content }).then(res => { console.log("商品列表", res) if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }) this.selectComponent('#ListBox').RefreshToComplete(); content.pageNumber = res.pageNumber + 1; content.pageTotal = res.pageTotal; this.setData({ list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data) }) this.setListHeight() }) }, /* 开始搜索 */ onSearch({ detail }) { content.where.condition = detail; this.getList(true) }, /* 获取领域 */ getTradefie() { _Http.basic({ "id": 20221223141802, content: { nocache: true, pageNumber: 1, pageSize: 9999, where: { condition: "" } } }, false).then(res => { console.log("获取领域", res) if (res.msg == '成功' && res.data.length > 1) { res.data.unshift({ rowindex: 0, subvalues: [], sys_enterprise_tradefieldid: 0, tradefield: "全部" }) this.setData({ tradefieList: res.data }); } }) }, /* 设置页面高度 */ setListHeight() { this.selectComponent("#ListBox").setHeight(".division", this); }, tradefieChange({ detail }) { content.where.tradefield = detail.item.tradefield == '全部' ? '' : detail.item.tradefield this.getList(true); this.selectAllComponents('#tradefieList').filter(v => { v.setData({ active: detail.index }) }) }, openPopup() { this.setData({ popupShow: true }) }, onClose() { this.setData({ popupShow: false }) } } })