zhaoxiaohai 3 лет назад
Родитель
Сommit
f5efc90036

+ 150 - 0
pages/mediaLibrary/index.js

@@ -0,0 +1,150 @@
+const _Http = getApp().globalData.http;
+const MFT = require("../../utils/matchingFeilType");
+
+let parems = {
+    "classname": "saletool.salematerial.salematerial",
+    method: "selectList",
+    content: {
+        "nocache": true,
+        "parentid": '',
+        "pageNumber": 1,
+        "pageSize": 20,
+        "where": {
+            "condition": ""
+        }
+    }
+}
+
+
+Page({
+    data: {},
+    onLoad(options) {
+        if (options.item) {
+            let item = JSON.parse(options.item);
+            parems.content.parentid = item.attachmentid;
+            wx.setNavigationBarTitle({
+                title: item.document
+            });
+        } else {
+            parems.content.parentid = wx.getStorageSync('siteP').salematerialfolderid;
+        }
+        this.getList(true)
+    },
+    /* 获得列表 */
+    getList(init = false) {
+        if (init.detail != undefined) init = init.detail;
+        if (init) parems.content.pageNumber = 1;
+        if (parems.content.pageNumber > parems.content.pageTotal) return;
+        parems.content.sort = this.data.sort || [];
+        _Http.basic(parems).then(res => {
+            console.log('营销物料', res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            parems.content.pageNumber = res.pageNumber + 1;
+            parems.content.pageTotal = res.pageTotal;
+            this.setData({
+                list: (res.pageNumber == 1) ? MFT.fileList(res.data) : this.data.list.concat(MFT.fileList(res.data)),
+                total: res.total,
+                sort: res.sort
+            })
+        })
+    },
+    /* 是否收藏 */
+    changeCollect() {
+        const {
+            isCollect,
+            attachmentid,
+            rowindex
+        } = this.data.fileSelected;
+        _Http.basic({
+            "classname": "system.attachment.MediaCenter",
+            "method": isCollect == 0 ? "collectAttachment" : "uncollectAttachment",
+            "content": {
+                "collecttype": "营销物料",
+                "attachmentid": attachmentid
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            wx.showToast({
+                title: isCollect == 0 ? '收藏成功' : "已取消收藏",
+                icon: "none"
+            })
+            let list = this.data.list,
+                index = rowindex - 1;
+            parems.method == "selectList" ? list[index].isCollect = isCollect == 0 ? 1 : 0 : list.splice(index, 1);
+            this.setData({
+                list
+            })
+            this.closeShow();
+        })
+    },
+    /* 文件下载 */
+    dowmLoad() {
+        const that = this;
+        wx.setClipboardData({
+            data: this.data.fileSelected.url,
+            success: function () {
+                wx.showToast({
+                    title: '复制成功,将链接放置到浏览器中便可下载文件',
+                    icon: "none",
+                    duration: 3000
+                });
+                that.closeShow();
+            }
+        })
+    },
+    /* 搜索框输入 */
+    searchInput({
+        detail
+    }) {
+        parems.content.where.condition = detail;
+        console.log(detail)
+        this.getList(true)
+    },
+    /* 清除搜索输入 */
+    searchClear() {
+        parems.content.where.condition = '';
+        this.getList(true)
+    },
+    /* tab切换 */
+    tabsChange({
+        detail
+    }) {
+        parems.method = detail.title == '列表' ? "selectList" : "selectMyList";
+        this.getList(true);
+    },
+    /* 开关切换 */
+    changeSwitch({
+        detail
+    }) {
+        this.setData({
+            sort: detail
+        })
+        this.getList(true);
+    },
+    onReady() {
+        this.selectComponent("#ListBox").setHeight(".tabs", this);
+    },
+    /* 修改选中ID */
+    changeId({
+        detail
+    }) {
+        this.setData({
+            fileSelected: detail,
+            show: true
+        })
+    },
+    /* 关闭修改 */
+    closeShow() {
+        this.setData({
+            show: false
+        })
+        this.data.fileSelected = {}
+    },
+})

+ 1 - 1
pages/tabbar/smartStore/index.json → pages/mediaLibrary/index.json

@@ -1,6 +1,6 @@
 {
     "navigationBarTitleText": "营销物料",
     "usingComponents": {
-        "viewPage": "./modules/viewPage"
+        "My_files": "./modules/flies"
     }
 }

+ 5 - 4
pages/tabbar/smartStore/modules/viewPage.scss → pages/mediaLibrary/index.scss

@@ -1,5 +1,8 @@
-@import '../../../../static/unread.wxss';
-
+@import '../../static/unread.wxss';
+page {
+    height: 100vw;
+    overflow: hidden;
+}
 .switch {
     display: flex;
     align-items: center;
@@ -10,8 +13,6 @@
     justify-content: flex-end;
     background: #ffffff;
 }
-
-
 .sheet-header {
     display: flex;
     align-items: center;

+ 5 - 3
pages/tabbar/smartStore/modules/viewPage.wxml → pages/mediaLibrary/index.wxml

@@ -1,4 +1,4 @@
-<van-search value="{{ content.where.condition }}" bind:change='searchInput' bind:clear='searchClear' shape="round" background="var(--bgColor)" placeholder="搜索文件" />
+<van-search value="{{ content.where.condition }}" bind:search='searchInput' bind:clear='searchClear' shape="round" background="var(--bgColor)" placeholder="搜索文件" />
 <van-tabs class="tabs" color='var(--assist)' bind:change='tabsChange' title-active-color='var(--assist)' sticky>
     <van-tab title="列表" />
     <van-tab title="收藏夹" />
@@ -6,12 +6,14 @@
         <My_switch bindchange='changeSwitch' sort="{{sort}}" />
     </view>
 </van-tabs>
+
 <Yl_ListBox id="ListBox" bind:getlist='getList'>
-    <view class="unread">总共{{inTotal}}个</view>
+    <view class="unread">总共{{total}}个</view>
     <My_files list="{{list}}" checkedId='{{fileSelected.attachmentid}}' bindchangeId='changeId' />
     <My_empty wx:if="{{list.length==0}}" />
-    <view style="height: {{padBot?'200rpx;':'50rpx'}}" />
 </Yl_ListBox>
+
+
 <van-action-sheet show="{{ show }}" bind:click-overlay='closeShow'>
     <view class="sheet-header">
         <image src="{{fileSelected.cover}}" />

+ 33 - 0
pages/mediaLibrary/modules/flies.js

@@ -0,0 +1,33 @@
+const cf = require("../../../utils/checkFile");
+Component({
+    properties: {
+        list: Array,
+        checkedId: Number,
+        changeId: Function
+    },
+    options: {
+        addGlobalClass: true
+    },
+    data: {
+        show: false,
+        fileSelected: {},
+    },
+    methods: {
+        /* 打开文件 */
+        openFile(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            if (item.fileType == 'folder') {
+                wx.navigateTo({
+                    url: '/pages/mediaLibrary/index?item=' + JSON.stringify(item),
+                })
+            } else {
+                cf.checkFile(item)
+            }
+        },
+        changeChecked(e) {
+            this.triggerEvent("changeId", e.target.dataset.item)
+        }
+    }
+})

+ 0 - 0
pages/tabbar/smartStore/modules/flies.json → pages/mediaLibrary/modules/flies.json


+ 32 - 2
pages/tabbar/smartStore/modules/flies.scss → pages/mediaLibrary/modules/flies.scss

@@ -1,5 +1,35 @@
-@import '../../../../components/My_card/index.scss';
-@import "../../../../static/font-icon.wxss";
+.my-card {
+    width: 690rpx;
+    background: #FFFFFF;
+    border-radius: 16rpx;
+    margin: 0 auto;
+    margin-top: 20rpx;
+    box-sizing: border-box;
+    overflow: hidden;
+
+    .mtitle {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        width: 100%;
+        height: 90rpx;
+        padding: 0 20rpx 0 30rpx;
+        border-bottom: 1px solid #EEEEEE;
+        box-sizing: border-box;
+
+        .title-l {
+            font-size: 28rpx;
+            font-family: PingFang SC-Bold, PingFang SC;
+            font-weight: bold;
+            color: #333333;
+        }
+    }
+}
+
+.hover:hover {
+    opacity: .95;
+    // background: #f4f5f7;
+}
 
 .my-card {
     display: flex;

+ 0 - 0
pages/tabbar/smartStore/modules/flies.wxml → pages/mediaLibrary/modules/flies.wxml


+ 0 - 10
pages/tabbar/smartStore/folder.js

@@ -1,10 +0,0 @@
-Page({
-    onLoad(options) {
-        let obj = JSON.parse(options.item);
-        this.selectComponent("#viewPage").changeParentid(obj.attachmentid);
-        wx.setNavigationBarTitle({
-            title: obj.document
-        });
-    },
-    onShareAppMessage(res) { }
-})

+ 0 - 6
pages/tabbar/smartStore/folder.json

@@ -1,6 +0,0 @@
-{
-    "navigationBarTitleText": "文件夹",
-    "usingComponents": {
-        "viewPage": "./modules/viewPage"
-    }
-}

+ 0 - 5
pages/tabbar/smartStore/folder.scss

@@ -1,5 +0,0 @@
-page {
-    height: 100vh;
-    padding: 0;
-    overflow: hidden;
-}

+ 0 - 1
pages/tabbar/smartStore/folder.wxml

@@ -1 +0,0 @@
-<viewPage padBot='{{false}}' id='viewPage' />

+ 0 - 6
pages/tabbar/smartStore/index.js

@@ -1,6 +0,0 @@
-Page({
-    onShow() {
-        this.getTabBar().init();
-    },
-    onShareAppMessage(res) { }
-})

+ 0 - 3
pages/tabbar/smartStore/index.scss

@@ -1,3 +0,0 @@
-page{
-    padding: 0 !important;
-}

+ 0 - 3
pages/tabbar/smartStore/index.wxml

@@ -1,3 +0,0 @@
-<view style="height: 100vh; overflow: hidden;">
-    <viewPage />
-</view>

+ 0 - 49
pages/tabbar/smartStore/modules/flies.js

@@ -1,49 +0,0 @@
-const cf = require("../../../../utils/checkFile");
-Component({
-    properties: {
-        list: {
-            type: Array,
-            value: []
-        },
-        checkedId: {
-            type: String,
-            value: 0
-        },
-        changeId: {
-            type: Function
-        }
-    },
-    options: {
-        addGlobalClass: true
-    },
-    data: {
-        show: false,
-        fileSelected: {},
-    },
-    methods: {
-        /* 打开文件 */
-        openFile(e) {
-            const {
-                item
-            } = e.currentTarget.dataset;
-            if (item.fileType == 'folder') {
-                let pages = getCurrentPages();
-                let prevPage = pages[pages.length - 1]; // 获取当前的页面栈
-                if (prevPage.route == "pages/tabbar/smartStore/index") {
-                    wx.navigateTo({
-                        url: '/pages/tabbar/smartStore/folder?item=' + JSON.stringify(item),
-                    })
-                } else {
-                    wx.redirectTo({
-                        url: '/pages/tabbar/smartStore/folder?item=' + JSON.stringify(item),
-                    })
-                }
-            } else {
-                cf.checkFile(item)
-            }
-        },
-        changeChecked(e) {
-            this.triggerEvent("changeId", e.target.dataset.item)
-        }
-    }
-})

+ 0 - 180
pages/tabbar/smartStore/modules/viewPage.js

@@ -1,180 +0,0 @@
-const _Http = getApp().globalData.http;
-const MFT = require("../../../../utils/matchingFeilType");
-let dowmCount = null;
-Component({
-    properties: {
-        padBot: {
-            type: Boolean,
-            value: true
-        }
-    },
-    options: {
-        addGlobalClass: true
-    },
-    lifetimes: {
-        ready() {
-            this.getList();
-            this.selectComponent("#ListBox").setHeight(".tabs", this);
-        }
-    },
-    data: {
-        tabActiveTitle: "列表", //列表类型
-        show: false, //显示底部弹出
-        fileSelected: {}, //选中文件详情
-        content: { //请求搜索条件
-            "nocache": true,
-            "pageNumber": 1,
-            "pageSize": 20,
-            "parentid": "默认",
-            "pageTotal": 1,
-            "where": {
-                "condition": ""
-            }
-        },
-        list: [], //文件列表
-        inTotal: 0, //总计
-        sort: [], //排序规则
-    },
-    methods: {
-        /* 是否收藏 */
-        changeCollect() {
-            const {
-                isCollect,
-                attachmentid,
-                rowindex
-            } = this.data.fileSelected;
-            _Http.basic({
-                "classname": "system.attachment.MediaCenter",
-                "method": isCollect == 0 ? "collectAttachment" : "uncollectAttachment",
-                "content": {
-                    "collecttype": "营销物料",
-                    "attachmentid": attachmentid
-                }
-            }).then(res => {
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.msg,
-                    icon: "none"
-                })
-                wx.showToast({
-                    title: isCollect == 0 ? '收藏成功' : "已取消收藏",
-                    icon: "none"
-                })
-                let list = this.data.list,
-                    index = rowindex - 1;
-                this.data.tabActiveTitle == '列表' ? list[index].isCollect = isCollect == 0 ? 1 : 0 : list.splice(index, 1);
-                this.setData({
-                    list
-                })
-                this.closeShow();
-            })
-        },
-        /* 文件下载 */
-        dowmLoad() {
-            const that = this;
-            wx.setClipboardData({
-                data: this.data.fileSelected.url,
-                success: function () {
-                    wx.showToast({
-                        title: '复制成功,将链接放置到浏览器中便可下载文件',
-                        icon: "none",
-                        duration: 3000
-                    });
-                    that.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;
-            let content = this.data.content;
-            if (content.parentid == '默认') content.parentid = wx.getStorageSync('siteP').salematerialfolderid;
-            if (this.data.sort[0]) content.sort = this.data.sort;
-            _Http.basic({
-                "classname": "saletool.salematerial.salematerial",
-                "method": (this.data.tabActiveTitle == '列表') ? "selectList" : "selectMyList",
-                content
-            }).then(res => {
-                console.log('营销物料', res)
-                this.selectComponent('#ListBox').RefreshToComplete();
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.msg,
-                    icon: "none"
-                })
-                this.setData({
-                    list: (res.pageNumber == 1) ? MFT.fileList(res.data) : this.data.list.concat(MFT.fileList(res.data)),
-                    ['content.pageNumber']: res.pageNumber + 1,
-                    ['content.pageTotal']: res.pageTotal,
-                    inTotal: res.total,
-                    sort: res.sort
-                })
-            })
-        },
-        /* 搜索框输入 */
-        searchInput({
-            detail
-        }) {
-            clearTimeout(dowmCount);
-            this.setData({
-                ['content.where.condition']: detail.trim()
-            })
-            dowmCount = setTimeout(() => {
-                this.getList(true)
-            }, 1000);
-
-        },
-        /* 清除搜索输入 */
-        searchClear() {
-            this.setData({
-                ['content.where.condition']: ""
-            })
-        },
-        /* tab切换 */
-        tabsChange({
-            detail
-        }) {
-            this.setData({
-                tabActiveTitle: detail.title
-            })
-            this.getList(true);
-        },
-        /* 开关切换 */
-        changeSwitch({
-            detail
-        }) {
-            this.setData({
-                sort: detail
-            })
-            this.getList(true);
-        },
-        /* 修改ID */
-        changeParentid(id) {
-            this.setData({
-                ['content.parentid']: id
-            })
-        },
-        /* 修改选中ID */
-        changeId({
-            detail
-        }) {
-            this.setData({
-                fileSelected: detail,
-                show: true
-            })
-        },
-        /* 关闭修改 */
-        closeShow() {
-            this.setData({
-                show: false
-            })
-            setTimeout(() => {
-                this.setData({
-                    fileSelected: {}
-                })
-            }, 150)
-        },
-    }
-})

+ 0 - 8
pages/tabbar/smartStore/modules/viewPage.json

@@ -1,8 +0,0 @@
-{
-    "component": true,
-    "usingComponents": {
-        "van-dropdown-menu": "@vant/weapp/dropdown-menu/index",
-        "van-dropdown-item": "@vant/weapp/dropdown-item/index",
-        "My_files": "./flies"
-    }
-}