Browse Source

跟进文件列表

zhaoxiaohai 2 years ago
parent
commit
0939b2b77d

+ 58 - 0
packageA/setclient/modules/trace/files/index.js

@@ -0,0 +1,58 @@
+Component({
+    properties: {
+        files: Object,
+        deleteFile: Function,
+        delete: {
+            type: Boolean,
+            value: true
+        }
+    },
+    methods: {
+        /* 预览媒体 */
+        viewMedias(e) {
+            const {
+                index,
+                type
+            } = e.currentTarget.dataset;
+            wx.previewMedia({
+                current: index,
+                sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
+            })
+        },
+        /* 预览文档 */
+        viewFlies(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            wx.showLoading({
+                title: '加载中...',
+            })
+            wx.downloadFile({
+                url: item.url,
+                complete({
+                    statusCode,
+                    tempFilePath
+                }) {
+                    if (statusCode != 200) return;
+                    wx.openDocument({
+                        filePath: tempFilePath,
+                        fileType: item.postfix,
+                        showMenu: true,
+                        complete({
+                            errMsg
+                        }) {
+                            wx.hideLoading();
+                            if (errMsg != "openDocument:ok") wx.showToast({
+                                title: '打开失败',
+                                icon: "none"
+                            })
+                        }
+                    })
+                }
+            })
+        },
+        handleDeleteFile(e) {
+            this.triggerEvent("deleteFile", e)
+        }
+    }
+})

+ 4 - 0
packageA/setclient/modules/trace/files/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 74 - 0
packageA/setclient/modules/trace/files/index.scss

@@ -0,0 +1,74 @@
+.media {
+    width: 100%;
+    display: flex;
+    flex-wrap: wrap;
+    margin-top: 20rpx;
+    padding: 0 30rpx;
+    box-sizing: border-box;
+
+    .item {
+        position: relative;
+        width: 158rpx;
+        height: 158rpx;
+        margin-right: 18rpx;
+        margin-bottom: 18rpx;
+        border-radius: 8rpx;
+        overflow: hidden;
+
+        image {
+            width: 100%;
+            height: 100%;
+        }
+
+        .delete {
+            position: absolute;
+            width: 40rpx;
+            height: 40rpx;
+            right: 0;
+            top: 0;
+        }
+
+        .shade {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            position: absolute;
+            width: 100%;
+            height: 100%;
+            background: rgba(0, 0, 0, 0.2);
+            top: 0;
+            left: 0;
+            color: #ffffff;
+
+        }
+
+    }
+
+    .item:nth-child(4n) {
+        margin-right: 0;
+    }
+
+    .file {
+        display: flex;
+        flex-direction: column;
+        border: 1px solid #CCCCCC;
+        box-sizing: border-box;
+        align-items: center;
+
+        .name {
+            width: 120rpx;
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            margin-top: 20rpx;
+            overflow: hidden;
+            white-space: nowrap;
+            text-overflow: ellipsis;
+        }
+
+        .image {
+            height: 58rpx;
+            margin-top: 24rpx;
+        }
+    }
+}

+ 24 - 0
packageA/setclient/modules/trace/files/index.wxml

@@ -0,0 +1,24 @@
+<view class="media">
+    <!-- 图片 -->
+    <navigator url="#" class="item" wx:for="{{files.images}}" wx:key="item.attachmentid">
+        <image src="{{item.url}}" data-index="{{index}}" data-type='image' mode="aspectFill" bindtap="viewMedias" />
+        <image wx:if="{{delete}}" class="delete" src="/static/image/delete.png" data-item="{{item}}" bindtap="handleDeleteFile" />
+    </navigator>
+    <!-- 视频 -->
+    <navigator url="#" class="item" wx:for="{{files.videos}}" wx:key="item.attachmentid">
+        <image src="{{item.subfiles[0].url}}" mode="aspectFill" />
+        <view class="shade" data-index="{{index}}" data-type='video' bindtap="viewMedias">
+            <van-icon size='48rpx' name="play" />
+        </view>
+        <image wx:if="{{delete}}" class="delete" src="/static/image/delete.png" data-item="{{item}}" bindtap="handleDeleteFile" />
+    </navigator>
+    <!-- 文件 -->
+    <navigator url="#" class="item file" wx:for="{{files.files}}" wx:key="item.attachmentid" data-item='{{item}}' bindtap="viewFlies">
+        <image class="image" src="{{item.cover}}" mode="heightFix" />
+        <view class="name">
+            {{item.document}}
+        </view>
+        <image wx:if="{{delete}}" class="delete" src="/static/image/delete.png" data-item="{{item}}" catchtap="handleDeleteFile" />
+    </navigator>
+</view>
+<!--  list="{{files.files}}" -->