| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | 
							- const getHeight = require("../../utils/getRheRemainingHeight");
 
- const _Http = getApp().globalData.http;
 
- const MFT = require("../../utils/matchingFeilType");
 
- let dowmCount = null;
 
- Page({
 
-     /**
 
-      * 页面的初始数据
 
-      */
 
-     data: {
 
-         isInsert: true, //是否具有新增权限
 
-         tabsActiveIndex: 0,
 
-         scrollHeight: 0, //滚动区域高度
 
-         searchContent: "", //搜索内容
 
-         mainActiveIndex: 0, //分类选择器打开分类的下标
 
-         activeId: null, //分类选择器选择id
 
-         activeName: null,
 
-         items: [], //分类列表
 
-         total: 0,
 
-         sort: [],
 
-         content: {
 
-             pageNumber: 1,
 
-             pageSize: 20,
 
-             pageTotal: 1,
 
-             where: {
 
-                 condition: "",
 
-                 sat_sharematerial_classid: ""
 
-             }
 
-         },
 
-         sheetShow: false,
 
-         actions: [{
 
-                 name: '上传图片',
 
-             },
 
-             {
 
-                 name: '上传视频',
 
-             },
 
-             {
 
-                 name: '上传图文',
 
-             },
 
-         ],
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面加载
 
-      */
 
-     onLoad(options) {
 
-         if (options.auth) {
 
-             let auth = JSON.parse(options.auth)[0].meta.auth;
 
-             this.setData({
 
-                 isInsert: auth.some(v => v.optionname == '新增')
 
-             })
 
-         }
 
-         this.selectMenu();
 
-         this.getList();
 
-     },
 
-     tabChange({
 
-         detail
 
-     }) {
 
-         this.setData({
 
-             tabsActiveIndex: detail.index
 
-         });
 
-         this.getList(true);
 
-     },
 
-     /* 查询列表 */
 
-     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;
 
-         let content = this.data.content;
 
-         (this.data.activeId != null) ? content.where.sat_sharematerial_classid = this.data.activeId: delete(content.where.sat_sharematerial_classid);
 
-         if (this.data.sort[0]) content.sort = this.data.sort;
 
-         _Http.basic({
 
-             "classname": "saletool.sharematerial.sharematerial",
 
-             "method": this.data.tabsActiveIndex == 0 ? "selectList" : "selectMyList",
 
-             content
 
-         }).then(res => {
 
-             console.log("列表", res)
 
-             let deleteList = [],
 
-                 initID = '9999' + wx.getStorageSync('userMsg').userid;
 
-             res.data.forEach(v => (initID == v.sat_sharematerial_classid && v.title == '') ? deleteList.push(v.sat_sharematerialid) : '');
 
-             if (deleteList.length != 0) return this.handleDelete(deleteList);
 
-             this.selectComponent('#ListBox').RefreshToComplete();
 
-             if (res.msg != '成功') return wx.showToast({
 
-                 title: res.data,
 
-                 icon: "none"
 
-             });
 
-             for (let i = 0; i < res.data.length; i++) {
 
-                 let list = MFT.fileList(res.data[i].attinfos);
 
-                 if (!list.length) continue;
 
-                 let obj = list.find(value => value.fileType == "image");
 
-                 if (!obj) continue;
 
-                 res.data[i].cover = MFT.getSpecifiedImage(obj);
 
-                 res.data[i].attinfos = list;
 
-             }
 
-             this.setData({
 
-                 list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
 
-                 ['content.pageNumber']: res.pageNumber + 1,
 
-                 ['content.pageTotal']: res.pageTotal,
 
-                 total: res.total,
 
-                 sort: res.sort
 
-             })
 
-         })
 
-     },
 
-     /* 处理批量删除 */
 
-     handleDelete(list) {
 
-         _Http.basic({
 
-             "classname": "webmanage.saletool.sharematerial.sharematerial",
 
-             "method": "delete",
 
-             "content": {
 
-                 "sat_sharematerialid": list
 
-             }
 
-         }).then(res => {
 
-             console.log("处理删除", res);
 
-             if (res.msg == '成功') this.getList();
 
-         })
 
-     },
 
-     /* 清除搜索输入 */
 
-     searchClear() {
 
-         this.setData({
 
-             ['content.where.condition']: ""
 
-         })
 
-     },
 
-     /* 搜索框输入 */
 
-     searchInput({
 
-         detail
 
-     }) {
 
-         clearTimeout(dowmCount);
 
-         this.setData({
 
-             ['content.where.condition']: detail.trim()
 
-         })
 
-         dowmCount = setTimeout(() => {
 
-             this.getList(true)
 
-         }, 1000);
 
-     },
 
-     /* 开关切换 */
 
-     changeSwitch({
 
-         detail
 
-     }) {
 
-         this.setData({
 
-             sort: detail
 
-         })
 
-         this.getList(true);
 
-     },
 
-     /* 查询分类 */
 
-     selectMenu(index = 0, res) {
 
-         if (index == 5) return wx.showToast({
 
-             title: res.data,
 
-             icon: "none"
 
-         });
 
-         _Http.basic({
 
-             "classname": "saletool.sharematerial.sharematerial",
 
-             "method": "select",
 
-             "content": {
 
-                 "parentid": 0
 
-             }
 
-         }).then(res => {
 
-             if (res.msg != '成功') return this.selectMenu(index + 1, res);
 
-             let str = JSON.stringify(res.data).replace(/classname/g, 'text').replace(/sat_sharematerial_classid/g, 'id');
 
-             this.setData({
 
-                 items: JSON.parse(str)
 
-             });
 
-         });
 
-     },
 
-     /* 切换分类 */
 
-     onClickItem({
 
-         detail = {}
 
-     }) {
 
-         this.setData({
 
-             activeId: this.data.activeId === detail.id ? null : detail.id,
 
-             activeName: this.data.activeName === detail.text ? null : detail.text
 
-         });
 
-         this.selectComponent('#item').toggle(false);
 
-         this.getList(true);
 
-     },
 
-     onClickNav({
 
-         detail = {}
 
-     }) {
 
-         this.setData({
 
-             mainActiveIndex: detail.index || 0,
 
-         });
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面初次渲染完成
 
-      */
 
-     onReady() {
 
-         //滚动区域高度
 
-         getHeight.getHeight('.menu', this).then(res => {
 
-             this.setData({
 
-                 scrollHeight: res
 
-             })
 
-         })
 
-     },
 
-     addData() {
 
-         this.setData({
 
-             sheetShow: true
 
-         });
 
-     },
 
-     sheetClose() {
 
-         this.setData({
 
-             sheetShow: false
 
-         });
 
-     },
 
-     sheetSelect({
 
-         detail
 
-     }) {
 
-         let type = '';
 
-         switch (detail.name) {
 
-             case "上传图片":
 
-                 type = 'image'
 
-                 break;
 
-             case "上传视频":
 
-                 type = 'video'
 
-                 break;
 
-             case "上传图文":
 
-                 type = 'richtext'
 
-                 break;
 
-         }
 
-         /* items是分类 */
 
-         wx.navigateTo({
 
-             url: `./upload?item=${JSON.stringify(this.data.items)}&type=${type}`
 
-         })
 
-     },
 
- })
 
 
  |