zhaoxiaohai 3 lat temu
rodzic
commit
a70046ee77

+ 11 - 3
pages/promotional/details.js

@@ -1,6 +1,8 @@
-const _Http = getApp().globalData.http;
-Page({
+const _Http = getApp().globalData.http,
+    MFT = require("../../utils/matchingFeilType"),
+    checkFile = require("../../utils/checkFile");
 
+Page({
     /**
      * 页面的初始数据
      */
@@ -24,11 +26,17 @@ Page({
                 title: res.data,
                 icon: "none"
             })
+            let data = res.data[0];
+            if (data.content.length) data.content = decodeURIComponent(data.content);
+            if (data.attinfos.length) data.attinfos = MFT.fileList(data.attinfos);
             this.setData({
-                detailsData: res.data[0]
+                detailsData: data
             })
         })
     },
+    openFile(e) {
+        checkFile.checkFile(e.currentTarget.dataset.item);
+    },
 
     /**
      * 生命周期函数--监听页面初次渲染完成

+ 4 - 1
pages/promotional/details.json

@@ -1,4 +1,7 @@
 {
     "navigationBarTitleText": "素材详情",
-    "usingComponents": {}
+    "usingComponents": {
+        "mp-html": "/components/mp-html/index",
+        "van-sticky": "@vant/weapp/sticky/index"
+    }
 }

+ 22 - 6
pages/promotional/details.scss

@@ -31,15 +31,31 @@
             margin-right: 0rpx;
 
         }
+    }
+}
+
+.explain {
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+    margin-top: 20rpx;
+    width: 750rpx;
+    padding: 30rpx;
+    box-sizing: border-box;
+    background-color: #ffffff;
 
+    .title {
+        font-size: 30rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #333333;
     }
 
-    .explain {
-        font-size: 28rpx;
-        font-family: PingFang SC-Regular, PingFang SC;
-        font-weight: 400;
-        color: #666666;
-        margin-top: 30rpx;
+    .video {
+        width: 690rpx;
+        height: 360rpx;
+        border-radius: 16rpx;
+        overflow: hidden;
     }
 }
 

+ 26 - 9
pages/promotional/details.wxml

@@ -1,15 +1,32 @@
-<view class="header">
-    <view class="title multi-line">{{detailsData.title}}</view>
-    <view class="display-data">
-        <view>{{detailsData.changedate}}</view>
-        <view>
-            <text>浏览:{{detailsData.readcount}}</text>
-            <text>分享:{{detailsData.sharecount}}</text>
-            <text>拉新:{{detailsData.newcount}}</text>
+<van-sticky>
+    <view class="header">
+        <view class="title multi-line">{{detailsData.title}}</view>
+        <view class="display-data">
+            <view>{{detailsData.changedate}}</view>
+            <view>
+                <text>浏览:{{detailsData.readcount}}</text>
+                <text>分享:{{detailsData.sharecount}}</text>
+                <text>拉新:{{detailsData.newcount}}</text>
+            </view>
         </view>
     </view>
-    <view class="explain multi-line">{{detailsData.content}}</view>
+</van-sticky>
+<view />
+
+<view class="explain" wx:if="{{detailsData.content}}">
+    <mp-html content="{{detailsData.content}}" />
 </view>
+
+<view class="explain" wx:if="{{detailsData.attinfos[0]}}">
+    <view class="title" style="margin-bottom: 20rpx;">附件</view>
+    <view wx:for="{{detailsData.attinfos}}">
+        <van-image wx:if="{{item.fileType=='image'}}" width="690rpx" height="360rpx" data-item="{{item}}" bindtap="openFile" radius='16rpx' src="{{item.url}}" lazy-load />
+        <video class="video" wx:elif="{{item.fileType=='video'}}" src="{{item.url}}" />
+        <view style="height:20rpx;" />
+    </view>
+</view>
+
+<view style="height: 50px;" />
 <view class="footer">
     <van-button custom-class='footer-button' color="var(--warning)">分享</van-button>
 </view>

+ 10 - 1
pages/promotional/index.js

@@ -1,5 +1,6 @@
 const getHeight = require("../../utils/getRheRemainingHeight");
 const _Http = getApp().globalData.http;
+const MFT = require("../../utils/matchingFeilType");
 Page({
 
     /**
@@ -61,7 +62,15 @@ Page({
             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 = obj.url;
+                res.data[i].attinfos = list;
+            }
             this.setData({
                 list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
                 ['content.pageNumber']: res.pageNumber + 1,

+ 2 - 1
pages/promotional/upload.js

@@ -60,10 +60,11 @@ Page({
         this.setData({
             loading: true
         })
+        content.content = encodeURIComponent(content.content);
         _Http.basic({
             "classname": "webmanage.saletool.sharematerial.sharematerial",
             "method": "insertOrUpdate",
-            content: this.data.content
+            content: content
         }).then(res => {
             if (res.msg != '成功') {
                 wx.showToast({

+ 1 - 1
pages/promotional/upload.scss

@@ -75,7 +75,7 @@
             color: #FF3B30;
             top: 0rpx;
             right: 0rpx;
-            z-index: 99999;
+            z-index: 9;
             padding: 0 8rpx 0 5rpx;
         }
     }