Browse Source

附件添加下载回调

zhaoxiaohai 3 years ago
parent
commit
b7e75786c8
2 changed files with 12 additions and 14 deletions
  1. 10 12
      components/My_accessory/index.js
  2. 2 2
      components/My_accessory/index.wxml

+ 10 - 12
components/My_accessory/index.js

@@ -12,12 +12,9 @@ Component({
             type: Array,
             value: []
         },
-        callBack: {
-            type: Function
-        },
-        deleteFile: {
-            type: Function
-        }
+        callBack: Function,
+        deleteFile: Function,
+        downLoadRecord: Function
     },
     options: {
         addGlobalClass: true
@@ -36,12 +33,13 @@ Component({
     methods: {
         butClick(e) {
             const {
-                item
+                item,
+                type
             } = e.currentTarget.dataset;
             const that = this;
-            if (this.data.butType == '播放') {
+            if (type == '播放') {
                 this.triggerEvent("callBack", item);
-            } else if (this.data.butType == '删除') {
+            } else if (type == '删除') {
                 wx.showModal({
                     title: "通知",
                     content: "是否确认删除该附件?",
@@ -49,7 +47,7 @@ Component({
                         if (res.confirm) that.triggerEvent("deleteFile", item);
                     }
                 })
-            } else if (this.data.butType == '下载') {
+            } else if (type == '下载') {
                 wx.downloadFile({
                     url: item.url,
                     success(res) {
@@ -75,8 +73,8 @@ Component({
                             icon: "none"
                         })
                     }
-                })
-
+                });
+                this.triggerEvent("downLoadRecord");
             };
         },
         callback(e) {

+ 2 - 2
components/My_accessory/index.wxml

@@ -7,6 +7,6 @@
         <view class="title line-1">{{item.document}}</view>
         <view class="time">{{item.createdate}}</view>
     </view>
-    <van-button wx:if="{{butType=='商学院'}}" type="info" data-item="{{item}}" custom-class='v-but' catchtap="{{item.fileType=='video'?'callback':'butClick'}}">{{item.fileType=='video'?'播放':'下载'}}</van-button>
-    <van-button wx:else type="{{butType==='下载'||butType==='播放'?'info':'danger'}}" data-item="{{item}}" custom-class='v-but' catchtap="butClick">{{butType}}</van-button>
+    <van-button wx:if="{{butType=='商学院'}}" type="info" data-item="{{item}}" custom-class='v-but' data-type="{{item.fileType=='video'?'播放':'下载'}}" catchtap="{{item.fileType=='video'?'callback':'butClick'}}">{{item.fileType=='video'?'播放':'下载'}}</van-button>
+    <van-button wx:else type="{{butType==='下载'||butType==='播放'?'info':'danger'}}" data-item="{{item}}" data-type="{{butType}}" custom-class='v-but' catchtap="butClick">{{butType}}</van-button>
 </navigator>