Browse Source

推广素材

zhaoxiaohai 3 years ago
parent
commit
b730574225

+ 18 - 3
pages/promotional/details.js

@@ -1,18 +1,33 @@
-// pages/promotional/details.js
+const _Http = getApp().globalData.http;
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-
+        detailsData:{},
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
-
+        _Http.basic({
+            "classname": "saletool.sharematerial.sharematerial",
+            "method": "selectDetail",
+            "content": {
+                "sat_sharematerialid": options.id
+            }
+        }).then(res => {
+            console.log(res)
+            if(res.msg!='成功')return wx.showToast({
+              title: res.data,
+              icon:"none"
+            })
+            this.setData({
+                detailsData:res.data[0]
+            })
+        })
     },
 
     /**

+ 6 - 7
pages/promotional/details.wxml

@@ -1,16 +1,15 @@
 <view class="header">
-    <view class="title multi-line">撒旦士大夫士大夫广泛的fdgroiefdojgf34598734958sogiudsfgojo时代光华士大夫发搜i规划的发给你卢卡斯发达国家哦i房管局梵蒂冈</view>
+    <view class="title multi-line">{{detailsData.title}}</view>
     <view class="display-data">
-        <view>2022-12-12 12:20</view>
+        <view>{{detailsData.changedate}}</view>
         <view>
-            <text>浏览:30</text>
-            <text>分享:654</text>
-            <text>拉新:30</text>
+            <text>浏览:{{detailsData.readcount}}</text>
+            <text>分享:{{detailsData.sharecount}}</text>
+            <text>拉新:{{detailsData.newcount}}</text>
         </view>
     </view>
-    <view class="explain multi-line">撒旦士大夫士大夫广泛的fdgroiefdojgf34598734958sogiudsfgojo时代光华士大夫发搜i规划的发给你卢卡斯发达国家哦i房管局梵蒂冈</view>
+    <view class="explain multi-line">{{detailsData.content}}</view>
 </view>
-
 <view class="footer">
     <van-button custom-class='footer-button' color="var(--warning)">分享</van-button>
 </view>

+ 100 - 32
pages/promotional/index.js

@@ -1,4 +1,5 @@
 const getHeight = require("../../utils/getRheRemainingHeight");
+const _Http = getApp().globalData.http;
 Page({
 
     /**
@@ -9,53 +10,120 @@ Page({
         searchContent: "", //搜索内容
         mainActiveIndex: 0, //分类选择器打开分类的下标
         activeId: null, //分类选择器选择id
-        items: [{
-            text: '所有城市',
-            children: [{
-                    text: '温州',
-                    id: '温州',
-                },
-                {
-                    text: '杭州',
-                    id: '杭州',
-                },
-            ],
-        }, {
-            text: '可选城市',
-            children: [{
-                    text: '嘉兴',
-                    id: '嘉兴',
-                },
-                {
-                    text: '台州',
-                    id: '台州',
-                },
-            ],
-        }, ]
+        activeName: null,
+        items: [], //分类列表
+        total: 0,
+        sort: [],
+        content: {
+            pageNumber: 1,
+            pageSize: 20,
+            pageTotal: 1,
+            where: {
+                condition: ""
+            }
+        }
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {},
-    onClickNav({
-        detail = {}
+    onLoad(options) {
+        this.selectMenu();
+        this.getList();
+    },
+
+    /* 查询列表 */
+    getList(init = false) {
+        if (init.detail != undefined) init = init.detail;
+        if (init) this.setData({
+            ['content.pageNumber']: 1
+        })
+        if (this.data.content.pageNumber > this.data.content.pageTotal) return;
+        let content = this.data.content;
+        if (this.data.activeId) content.where.sat_sharematerial_classid = this.data.activeId;
+        if (this.data.sort[0]) content.sort = this.data.sort;
+        _Http.basic({
+            "classname": "saletool.sharematerial.sharematerial",
+            "method": "selectList",
+            content
+        }).then(res => {
+            console.log("列表", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
+                ['content.pageNumber']: res.pageNumber + 1,
+                ['content.pageTotal']: res.pageTotal,
+                total: res.total,
+                sort: res.sort
+            })
+        })
+    },
+    /* 清除搜索输入 */
+    searchClear() {
+        this.setData({
+            ['content.where.condition']: ""
+        })
+
+    },
+    /* 搜索框输入 */
+    searchInput({
+        detail
     }) {
         this.setData({
-            mainActiveIndex: detail.index || 0,
+            ['content.where.condition']: detail.trim()
+        })
+        this.getList(true)
+    },
+    /* 开关切换 */
+    changeSwitch({
+        detail
+    }) {
+        this.setData({
+            sort: detail
+        })
+        this.getList(true);
+    },
+    /* 查询分类 */
+    selectMenu(index = 0, res) {
+        if (index == 5) return wx.showToast({
+            title: res.data,
+            icon: "none"
+        });
+        _Http.basic({
+            "classname": "saletool.sharematerial.sharematerial",
+            "method": "select",
+            "content": {
+                "parentid": 0
+            }
+        }).then(res => {
+            if (res.msg != '成功') return this.selectMenu(index + 1, res);
+            let str = JSON.stringify(res.data).replace(/classname/g, 'text').replace(/sat_sharematerial_classid/g, 'id');
+            this.setData({
+                items: JSON.parse(str)
+            });
         });
     },
-
+    /* 切换分类 */
     onClickItem({
         detail = {}
     }) {
-        const activeId = this.data.activeId === detail.id ? null : detail.id;
-        console.log(activeId)
         this.setData({
-            activeId
+            activeId: this.data.activeId === detail.id ? null : detail.id,
+            activeName: this.data.activeName === detail.text ? null : detail.text
+        });
+        this.getList(true);
+    },
+    onClickNav({
+        detail = {}
+    }) {
+        this.setData({
+            mainActiveIndex: detail.index || 0,
         });
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 9 - 6
pages/promotional/index.wxml

@@ -1,5 +1,5 @@
 <!-- 搜索 -->
-<van-search value="{{ searchContent }}" use-action-slot shape="round" background="var(--primary)" placeholder="请输入搜索关键词">
+<van-search value="{{ searchContent }}" bind:change='searchInput' use-action-slot shape="round" bind:clear='searchClear' background="var(--primary)" placeholder="请输入搜索关键词">
     <view class="upload-box" slot='action'>
         <navigator url="/pages/promotional/upload" class="upload">
             <text class="iconfont icon-a-tuiguangsucaishangchuan1" />
@@ -7,22 +7,25 @@
         </navigator>
     </view>
 </van-search>
+
 <!-- tabs -->
 <van-tabs sticky color='var(--assist)' title-active-color='var(--assist)' title-inactive-color='#999' z-index='9'>
     <van-tab title="列表" />
     <van-tab title="我的素材" />
     <van-tab title="拉新清单" />
 </van-tabs>
+
 <!-- 下拉菜单 -->
 <van-dropdown-menu class="menu" activeColor='var(--assist)'>
-    <van-dropdown-item id="item" title="{{activeId||'默认'}}">
-        <van-tree-select items="{{ items }}"  main-active-class='main-active' content-active-class='content-active' main-active-index="{{ mainActiveIndex }}" active-id="{{activeId}}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
+    <van-dropdown-item id="item" title="{{activeName||'默认'}}">
+        <van-tree-select items="{{ items }}" main-active-class='main-active' content-active-class='content-active' main-active-index="{{ mainActiveIndex }}" active-id="{{activeId}}" bind:click-nav="onClickNav" bind:click-item="onClickItem" />
     </van-dropdown-item>
     <view class="switch">
-        <My_switch></My_switch>
+        <My_switch bindchange='changeSwitch' sort="{{sort}}" />
     </view>
 </van-dropdown-menu>
+
 <!-- 列表 -->
-<My_listBox height='{{scrollHeight}}'>
-    <ProductList />
+<My_listBox id='ListBox' bindgetlist="getList" height='{{scrollHeight}}'>
+    <ProductList total="{{total}}" list="{{list}}" />
 </My_listBox>

+ 16 - 1
pages/promotional/modules/productList.js

@@ -5,7 +5,14 @@ Component({
      * 组件的属性列表
      */
     properties: {
-
+        total: {
+            type: String,
+            value: "0"
+        },
+        list: {
+            type: Array,
+            value: []
+        }
     },
 
     options: {
@@ -21,6 +28,14 @@ Component({
      * 组件的方法列表
      */
     methods: {
+        toDetail(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            wx.navigateTo({
+                url: `/pages/promotional/details?id=${item.sat_sharematerialid}`,
+            })
 
+        }
     }
 })

+ 0 - 1
pages/promotional/modules/productList.scss

@@ -35,7 +35,6 @@
                 display: flex;
                 justify-content: space-around;
                 height: 28rpx;
-                line-height: 28rpx;
                 margin-top: 10rpx;
                 font-size: 20rpx;
                 color: #999999;

+ 10 - 9
pages/promotional/modules/productList.wxml

@@ -1,19 +1,20 @@
-<view class="unread">总共20个,有1个更新</view>
+<view class="unread">总共{{total}}个,有1个更新</view>
 <My_card custom-class='product-list'>
-    <view url="/pages/promotional/details" class="item" wx:for="{{20}}">
-        <navigator url="/pages/promotional/details">
-            <van-image width="336rpx" height="247rpx" fit='cover' src="https://img.yzcdn.cn/vant/cat.jpeg" lazy-load />
+    <view class="item" wx:for="{{list}}">
+        <navigator url="#" data-item="{{item}}" bindtap="toDetail">
+            <van-image width="336rpx" height="247rpx" fit='cover' src="{{item.cover}}" lazy-load />
             <view class="details">
                 <view class="title line-1">
-                    标题标题标题标题标题标题标题标题标题标题
+                    {{item.title}}
                 </view>
                 <view class="display-data">
-                    <view><text class="iconfont icon-a-tonggaoliulanliang" />99999</view>
-                    <view><text class="iconfont icon-a-tuiguangsucaifenxiangliang" />99999</view>
-                    <view><text class="iconfont icon-a-tuiguangsucailaxinliang" />99999</view>
+                    <view><text class="iconfont icon-a-tonggaoliulanliang" />{{item.readcount}}</view>
+                    <view><text class="iconfont icon-a-tuiguangsucaifenxiangliang" />{{item.sharecount}}</view>
+                    <view><text class="iconfont icon-a-tuiguangsucailaxinliang" />{{item.newcount}}</view>
                 </view>
             </view>
         </navigator>
         <van-button custom-class='share-button' open-type='share' size="large">一键分享</van-button>
     </view>
-</My_card>
+</My_card>
+<My_empty wx:if="{{!list.length}}" />