浏览代码

推广素材

zhaoxiaohai 3 年之前
父节点
当前提交
99c34eb08f
共有 5 个文件被更改,包括 90 次插入73 次删除
  1. 39 50
      pages/promotional/index.js
  2. 2 1
      pages/promotional/index.json
  3. 2 0
      pages/promotional/index.wxml
  4. 23 2
      pages/promotional/upload.js
  5. 24 20
      pages/promotional/upload.wxml

+ 39 - 50
pages/promotional/index.js

@@ -27,7 +27,18 @@ Page({
                 condition: "",
                 sat_sharematerial_classid: ""
             }
-        }
+        },
+        sheetShow: false,
+        actions: [{
+                name: '上传图片',
+            },
+            {
+                name: '上传视频',
+            },
+            {
+                name: '上传图文',
+            },
+        ],
     },
 
     /**
@@ -72,7 +83,7 @@ Page({
                 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;
@@ -170,56 +181,34 @@ Page({
     },
 
     addData() {
-        wx.navigateTo({
-            url: './upload?item=' + JSON.stringify(this.data.items)
-        })
-    },
-
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {
+        this.setData({
+            sheetShow: true
+        });
 
     },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
-
+    sheetClose() {
+        this.setData({
+            sheetShow: false
+        });
     },
-
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage() {
-
+    sheetSelect({
+        detail
+    }) {
+        let type = '';
+        switch (detail.name) {
+            case "上传图片":
+                type = 'image'
+                break;
+            case "上传视频":
+                type = 'video'
+                break;
+            case "上传图文":
+                type = 'richtext'
+                break;
+        }
+        /* items是分类 */
+        wx.navigateTo({
+            url: `./upload?item=${JSON.stringify(this.data.items)}&type=${type}`
+        })
     },
-    /**
-     * 用户分享到朋友圈
-     */
-    onShareTimeline() {
-
-    }
 })

+ 2 - 1
pages/promotional/index.json

@@ -2,6 +2,7 @@
     "navigationBarTitleText": "推广素材",
     "usingComponents": {
         "ProductList": "./modules/productList",
-        "van-search": "@vant/weapp/search/index"
+        "van-search": "@vant/weapp/search/index",
+        "van-action-sheet": "@vant/weapp/action-sheet/index"
     }
 }

+ 2 - 0
pages/promotional/index.wxml

@@ -8,6 +8,8 @@
     </view>
 </van-search>
 
+<van-action-sheet show="{{ sheetShow }}" actions="{{ actions }}" bind:close="sheetClose" bind:cancel="sheetClose" bind:select="sheetSelect" cancel-text="取消" />
+
 <!-- tabs -->
 <van-tabs wx:if="{{isInsert}}" sticky color='var(--assist)' title-active-color='var(--assist)' bind:change='tabChange' title-inactive-color='#999' z-index='9'>
     <van-tab title="列表" />

+ 23 - 2
pages/promotional/upload.js

@@ -11,6 +11,7 @@ Page({
             "sat_sharematerial_classid": 9999,
             "notes": "",
             "tag": [],
+            "type": 1, //1图片2视频3图文
             "canfiledownload": 1,
             "content": "",
             "sat_sharematerialid": 0
@@ -22,15 +23,27 @@ Page({
         activeName: "",
         activeId: "",
         selectShow: false,
-        loading: false
+        loading: false,
+        uploadType: "image",
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
+        let type = 1;
+        switch (options.type) {
+            case 'video':
+                type = 2;
+                break;
+            case 'richtext':
+                type = 3;
+                break;
+        }
         if (options.item) {
             this.setData({
-                items: JSON.parse(options.item)
+                items: JSON.parse(options.item),
+                "content.type": type,
+                uploadType: options.type
             })
         } else {
             this.selectMenu();
@@ -53,6 +66,14 @@ Page({
             title: '请检查素材标题或所属分类',
             icon: "none"
         });
+        if (this.data.uploadType == 'image' || this.data.uploadType == 'video' && this.data.detailsData.attinfos.length == 0) return wx.showToast({
+            title: '您还未上传素材附件',
+            icon: "none"
+        });
+        if (this.data.uploadType == 'richtext' && this.data.content.content.length < 8) return wx.showToast({
+            title: '您还未编辑或保存图文内容',
+            icon: "none"
+        });
         if (this.data.loading || this.data.detailsData.status == "审核") return wx.showToast({
             title: '正在提交中',
             icon: "none"

+ 24 - 20
pages/promotional/upload.wxml

@@ -10,10 +10,12 @@
         <van-icon name="arrow-down" />
     </navigator>
 
-    <view class="label">素材文本</view>
-    <view class="input base" style="display: flex; justify-content: space-between; color: #999;">
-        {{content.content==''?'请编辑文本':'浏览文本'}} <text style="color: #3874F6;" catchtap="openEditRichText">编辑/预览</text>
-    </view>
+    <block wx:if="{{uploadType=='richtext'}}">
+        <view class="label">上传图文</view>
+        <view class="input base" style="display: flex; justify-content: space-between; color: #999;">
+            {{content.content==''?'请编辑文本':'浏览已编辑文本'}} <text style="color: #3874F6;" catchtap="openEditRichText">编辑/预览</text>
+        </view>
+    </block>
 
 
     <van-popup show="{{ selectShow }}" position="top" bind:close="onClose">
@@ -21,24 +23,26 @@
         <van-tree-select items="{{ items }}" main-active-class='main-active' content-active-class='content-active' main-active-index="{{ mainActiveIndex }}" active-id="{{content.sat_sharematerial_classid}}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
     </van-popup>
 
-    <view class="label">素材<text>已上传{{detailsData.attinfos.length}}个</text></view>
-    <view class="file-list">
-        <view class="file-box" wx:for="{{detailsData.attinfos}}" data-item="{{item}}" bindtap="openFile">
-            <view class="delete" catchtap="deleteFile" data-item="{{item}}" data-index="{{index}}">
-                <van-icon class="icon" name="clear" />
+    <block wx:if="{{uploadType!='richtext'}}">
+        <view class="label">上传{{uploadType=='image'?'图片':'视频'}}<text>已上传{{detailsData.attinfos.length}}个</text></view>
+        <view class="file-list">
+            <view class="file-box" wx:for="{{detailsData.attinfos}}" data-item="{{item}}" bindtap="openFile">
+                <view class="delete" catchtap="deleteFile" data-item="{{item}}" data-index="{{index}}">
+                    <van-icon class="icon" name="clear" />
+                </view>
+                <image wx:if="{{item.fileType=='image'}}" src="{{item.cover}}" mode="aspectFit" />
+                <image wx:elif="{{item.fileType=='video'}}" style="width: 100rpx; height: 100rpx;" src="../../static/image/file/video.png" />
             </view>
-            <image wx:if="{{item.fileType=='image'}}" src="{{item.cover}}" mode="aspectFit" />
-            <image wx:elif="{{item.fileType=='video'}}" style="width: 100rpx; height: 100rpx;" src="../../static/image/file/video.png" />
+            <My_upload accept='{{uploadType}}' binduploadCallback='getFile'>
+                <navigator url="#" class="file-box upload-file">
+                    <view>
+                        <view class="iconfont icon-a-tuiguangsucaishangchuan1"></view>
+                        <view>上传{{uploadType=='image'?'图片':'视频'}}</view>
+                    </view>
+                </navigator>
+            </My_upload>
         </view>
-        <My_upload accept='media' binduploadCallback='getFile'>
-            <navigator url="#" class="file-box upload-file">
-                <view>
-                    <view class="iconfont icon-a-tuiguangsucaishangchuan1"></view>
-                    <view>上传素材</view>
-                </view>
-            </navigator>
-        </My_upload>
-    </view>
+    </block>
 </My_card>
 
 <view class="but-bom">