瀏覽代碼

营销物料

zhaoxiaohai 3 年之前
父節點
當前提交
ce77a4c8b3
共有 2 個文件被更改,包括 33 次插入24 次删除
  1. 30 21
      pages/tabbar/smartStore/modules/viewPage.js
  2. 3 3
      pages/tabbar/smartStore/modules/viewPage.wxml

+ 30 - 21
pages/tabbar/smartStore/modules/viewPage.js

@@ -48,6 +48,32 @@ Component({
      * 组件的方法列表
      */
     methods: {
+        /* 是否收藏 */
+        isCollect() {
+            _Http.basic({
+                "classname": "system.attachment.MediaCenter",
+                "method": this.data.fileSelected.isCollect == 0 ? "collectAttachment" : "uncollectAttachment",
+                "content": {
+                    "collecttype": "营销物料",
+                    "attachmentid": this.data.fileSelected.attachmentid
+                }
+            }).then(res => {
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                })
+                wx.showToast({
+                    title: this.data.fileSelected.isCollect == 0 ? '收藏成功' : "取消收藏",
+                })
+                let list = this.data.list,
+                    index = this.data.fileSelected.queryrow - 1;
+                this.data.tabActiveTitle == '列表' ? list[index].isCollect = this.data.fileSelected.isCollect == 0 ? 1 : 0 : list.splice(index, 1);
+                this.setData({
+                    list
+                })
+                this.closeShow();
+            })
+        },
         /* 获得列表 */
         getList(init = false) {
             if (init.detail != undefined) init = init.detail;
@@ -126,30 +152,13 @@ Component({
         /* 关闭修改 */
         closeShow() {
             this.setData({
-                fileSelected: {},
                 show: false
             })
-        },
-        addToFavorites() {
-            console.log(this.data.fileSelected)
-            _Http.basic({
-                "classname": "system.attachment.MediaCenter",
-                "method": "collectAttachment",
-                "content": {
-                    "collecttype": "媒体中心",
-                    "attachmentid": this.data.fileSelected.attachmentid
-                }
-            }).then(res => {
-                console.log(res)
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.data,
-                    icon: "none"
-                })
-                this.closeShow();
-                wx.showToast({
-                    title: '收藏成功',
+            setTimeout(() => {
+                this.setData({
+                    fileSelected: {}
                 })
-            })
+            }, 150)
         },
     }
 })

+ 3 - 3
pages/tabbar/smartStore/modules/viewPage.wxml

@@ -19,11 +19,11 @@
         <image src="/static/image/file/{{fileSelected.postfix}}.png" />
         <view class="line-1">{{fileSelected.document}}</view>
     </view>
-    <navigator url='#' class="option" bindtap="addToFavorites">
-        <block>
+    <navigator url='#' class="option" bindtap="isCollect">
+        <block wx:if="{{fileSelected.isCollect==0}}">
             <van-icon class="icon star-o" name="star-o" />收藏
         </block>
-        <block>
+        <block wx:else>
             <van-icon class="icon star" name="star" />取消收藏
         </block>
     </navigator>