const getHeight = require("../../../../utils/getRheRemainingHeight"); const _Http = getApp().globalData.http; Component({ /** * 组件的属性列表 */ properties: { }, options: { addGlobalClass: true }, lifetimes: { ready() { this.getList(); getHeight.getHeight('.tabs', this).then(res => { this.setData({ listHeight: res }) }); } }, /** * 组件的初始数据 */ data: { listHeight: 0, //列表高度 tabActiveTitle: "列表", //列表类型 show: false, //显示底部弹出 fileSelected: {}, //选中文件详情 content: { //请求搜索条件 "pageNumber": 1, "pageSize": 20, "parentid": 1, "pageTotal": 1, "where": { "condition": "", //搜索内容 "sorttype": 2 //1:热门,2:最新,不传默认最新 } }, list: [], //文件列表 inTotal: 0, //总计 }, /** * 组件的方法列表 */ methods: { /* 是否收藏 */ isCollect() { const isCollect = this.data.fileSelected.isCollect; _Http.basic({ "classname": "system.attachment.MediaCenter", "method": isCollect == 0 ? "collectAttachment" : "uncollectAttachment", "content": { "collecttype": "营销物料", "attachmentid": this.data.fileSelected.attachmentid } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) wx.showToast({ title: isCollect == 0 ? '收藏成功' : "取消收藏", }) let list = this.data.list, index = this.data.fileSelected.queryrow - 1; this.data.tabActiveTitle == '列表' ? list[index].isCollect = isCollect == 0 ? 1 : 0 : list.splice(index, 1); this.setData({ list }) this.closeShow(); }) }, /* 获得列表 */ getList(init = false) { if (init.detail != undefined) init = init.detail; if (init) this.setData({ ['content.pageNumber']: 1 }) if (this.data.content.pageNumber > this.data.content.pageTotal) return; _Http.basic({ "classname": "saletool.salematerial.salematerial", "method": (this.data.tabActiveTitle == '列表') ? "selectList" : "selectMyList", "content": this.data.content }).then(res => { this.selectComponent('#ListBox').RefreshToComplete(); if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) this.setData({ list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data), ['content.pageNumber']: res.pageNumber + 1, ['content.pageTotal']: res.pageTotal, inTotal: res.total }) // console.log((this.data.tabActiveTitle == '列表') ? "列表" : '营销物料', this.data.list) }) }, /* 搜索框输入 */ searchInput({ detail }) { this.setData({ ['content.where.condition']: detail.trim() }) this.getList(true) }, /* 清除搜索输入 */ searchClear() { this.setData({ ['content.where.condition']: "" }) }, /* tab切换 */ tabsChange({ detail }) { this.setData({ tabActiveTitle: detail.title }) this.getList(true); }, /* 开关切换 */ changeSwitch({ detail }) { this.setData({ ["content.where.sorttype"]: detail == '最新' ? 2 : 1 }) this.getList(true); }, /* 修改ID */ changeParentid(id) { this.setData({ ['content.parentid']: id }) }, /* 修改选中ID */ changeId({ detail }) { console.log(detail) this.setData({ fileSelected: detail, show: true }) }, /* 关闭修改 */ closeShow() { this.setData({ show: false }) setTimeout(() => { this.setData({ fileSelected: {} }) }, 150) }, } })