Jelajahi Sumber

营销物料

zhaoxiaohai 3 tahun lalu
induk
melakukan
17af616a0c

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

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

+ 53 - 3
pages/tabbar/smartStore/modules/flies.js

@@ -1,4 +1,4 @@
-// pages/tabbar/smartStore/modules/flies.js
+// const fs = wx.getFileSystemManager();
 Component({
     /**
      * 组件的属性列表
@@ -35,8 +35,58 @@ Component({
             const {
                 item
             } = e.currentTarget.dataset;
-            if (item.postfix == 'folder') return wx.navigateTo({
-                url: '/pages/tabbar/smartStore/folder?item=' + JSON.stringify(item),
+            if (item.fileType == 'folder') {
+                wx.navigateTo({
+                    url: '/pages/tabbar/smartStore/folder?item=' + JSON.stringify(item),
+                })
+            } else if (['image', 'video'].includes(item.fileType)) {
+                this.preViewMedia(item)
+            } else if (['word', 'excel', 'ppt', 'pdf'].includes(item.fileType)) {
+                this.openDocument(item)
+            } else {
+                wx.setClipboardData({
+                    data: item.url,
+                    success: function () {
+                        wx.showToast({
+                            title: '当前文件类型不支持在线浏览,已将文件下载地址复制到剪切板,您可在浏览器中打开链接下载到本地浏览',
+                            icon: "none",
+                            duration: 5000
+                        });
+                    }
+                })
+            }
+        },
+        preViewMedia(item) {
+            wx.previewMedia({
+                sources: [{
+                    url: item.url,
+                    type: item.fileType,
+                }],
+                current: 0,
+                showmenu: true
+            })
+        },
+        openDocument(item) {
+            wx.downloadFile({
+                url: item.url,
+                success: function (res) {
+                    console.log(res.tempFilePath)
+                    wx.openDocument({
+                        filePath: res.tempFilePath,
+                        fileType: item.postfix,
+                        showMenu: true,
+                        success: function (res) {
+                            console.log(res)
+                            console.log('打开文档成功')
+                        },
+                        fail: (err) => {
+                            wx.showToast({
+                                title: '打开失败',
+                                icon: "none"
+                            })
+                        }
+                    })
+                }
             })
         },
         changeChecked(e) {

+ 19 - 1
pages/tabbar/smartStore/modules/viewPage.js

@@ -6,7 +6,10 @@ Component({
      * 组件的属性列表
      */
     properties: {
-
+        padBot: {
+            type: Boolean,
+            value: true
+        }
     },
     options: {
         addGlobalClass: true
@@ -76,6 +79,21 @@ Component({
                 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;

+ 5 - 7
pages/tabbar/smartStore/modules/viewPage.wxml

@@ -6,17 +6,15 @@
         <My_switch bindchange='changeSwitch' />
     </view>
 </van-tabs>
-
 <My_listBox id="ListBox" height='{{listHeight}}' bind:getlist='getList'>
     <view class="unread">总共{{inTotal}}个,有1个更新</view>
     <My_files list="{{list}}" checkedId='{{fileSelected.attachmentid}}' bindchangeId='changeId' />
     <My_empty wx:if="{{list.length==0}}" />
-    <view style="height: 200rpx;" />
+    <view style="height: {{padBot?'200rpx;':'50rpx'}}" />
 </My_listBox>
-
 <van-action-sheet show="{{ show }}" bind:click-overlay='closeShow'>
     <view class="sheet-header">
-        <image src="/static/image/file/{{fileSelected.postfix}}.png" />
+        <image src="{{fileSelected.cover}}" />
         <view class="line-1">{{fileSelected.document}}</view>
     </view>
     <navigator url='#' class="option" bindtap="isCollect">
@@ -27,8 +25,8 @@
             <van-icon class="icon star" name="star" />取消收藏
         </block>
     </navigator>
-    <navigator wx:if="{{fileSelected.postfix!='folder'}}" url='#' class="option">
-        <text class="iconfont icon-a-tonggaoshujuxiazailiang icon" />下载
+    <navigator wx:if="{{fileSelected.postfix!='folder'}}" bindtap="dowmLoad" url='#' class="option">
+        <text class="iconfont icon-a-tonggaoshujuxiazailiang icon" />复制下载地址
     </navigator>
-    <view style="height: 115rpx;" />
+    <view wx:if="{{padBot}}" style="height: 115rpx;" />
 </van-action-sheet>