zhaoxiaohai 2 gadi atpakaļ
vecāks
revīzija
86856f8183

+ 12 - 9
pages/promotional/details.js

@@ -13,28 +13,31 @@ Page({
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
+    async onLoad(options) {
         this.setData({
             dataType: options.type
         })
-        _Http.basic({
+        const params = {
             "classname": "saletool.sharematerial.sharematerial",
             "method": "selectDetail",
             "content": {
                 "sat_sharematerialid": options.id
             }
-        }).then(res => {
-            console.log("详情", res)
-            if (res.msg != '成功') return wx.showToast({
-                title: res.msg,
-                icon: "none"
-            })
+        };
+        const res = wx.getStorageSync('userMsg').token ? await _Http.basic(params) : await _Http.base(params);
+        if (res.msg != '成功') await _Http.base(params);
+        if (res.msg == '成功') {
             let data = res.data;
             if (data.attinfos.length) data.attinfos = MFT.fileList(data.attinfos);
             this.setData({
                 detailsData: data
             })
-        })
+        } else {
+            wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+        }
     },
     openFile(e) {
         checkFile.checkFile(e.currentTarget.dataset.item);

+ 16 - 8
pages/promotional/index.js

@@ -4,10 +4,6 @@ const MFT = require("../../utils/matchingFeilType");
 let dowmCount = null;
 
 Page({
-
-    /**
-     * 页面的初始数据
-     */
     data: {
         isInsert: true, //是否具有新增权限
         tabsActiveIndex: 0,
@@ -41,10 +37,6 @@ Page({
             },
         ],
     },
-
-    /**
-     * 生命周期函数--监听页面加载
-     */
     onLoad(options) {
         if (options.auth) {
             let auth = JSON.parse(options.auth)[0].meta.auth;
@@ -224,4 +216,20 @@ Page({
             url: `./upload?item=${JSON.stringify(this.data.items)}&type=${type}`
         })
     },
+    onShareAppMessage() {
+        const promise = new Promise(resolve => {
+            setTimeout(() => {
+                let data = this.selectComponent("#list").data.shareData;
+                resolve({
+                    title: data.title,
+                    path: `/pages/promotional/details`,
+                    query: `id=${data.sat_sharematerialid}&type=${data.type}`,
+                    imageUrl: data.cover
+                })
+            }, 50)
+        })
+        return {
+            promise
+        }
+    },
 })

+ 1 - 1
pages/promotional/index.wxml

@@ -29,6 +29,6 @@
 
 <!-- 列表 -->
 <My_listBox id='ListBox' bindgetlist="getList" height='{{scrollHeight}}'>
-    <ProductList total="{{total}}" list="{{list}}" />
+    <ProductList id='list' total="{{total}}" list="{{list}}" />
     <view style="height: 50px;" />
 </My_listBox>

+ 8 - 2
pages/promotional/modules/productList.js

@@ -16,7 +16,8 @@ Component({
     },
 
     options: {
-        addGlobalClass: true
+        addGlobalClass: true,
+        shareData: null
     },
 
     /**
@@ -36,7 +37,12 @@ Component({
             wx.navigateTo({
                 url: `/pages/promotional/details?id=${item.sat_sharematerialid}&type=${item.type}`,
             })
-
+        },
+        handleShare(e) {
+            this.setData({
+                shareData: e.currentTarget.dataset.item
+            })
+            console.log(this.data.shareData)
         }
     }
 })

+ 1 - 1
pages/promotional/modules/productList.wxml

@@ -14,7 +14,7 @@
                 </view>
             </view>
         </navigator>
-        <van-button custom-class='share-button' open-type='share' size="large">一键分享</van-button>
+        <van-button custom-class='share-button' open-type='share' size="large" catchtap="handleShare" data-item="{{item}}">一键分享</van-button>
     </view>
 </My_card>
 <My_empty wx:if="{{!list.length}}" />