diff --git a/pages/index/Brandsales/Brandsales.js b/pages/index/Brandsales/Brandsales.js index 8152515..46d7026 100644 --- a/pages/index/Brandsales/Brandsales.js +++ b/pages/index/Brandsales/Brandsales.js @@ -87,7 +87,6 @@ showPopup() { }, // // 点击日期组件确定事件 bindDateChange: function (e) { - let isBefore = moment(this.data.date2).isBefore(this.data.date) // console.log(isBefore) if(!isBefore){ diff --git a/pages/index/Brandsales/Brandsales.wxss b/pages/index/Brandsales/Brandsales.wxss index 99a66cd..ff28707 100644 --- a/pages/index/Brandsales/Brandsales.wxss +++ b/pages/index/Brandsales/Brandsales.wxss @@ -99,4 +99,11 @@ padding: 15px 0px; color: #909497; text-align: center; +} +.loading { + position: relative; + bottom: 5rpx; + padding: 10rpx; + text-align: center; + font-size: 12px; } \ No newline at end of file diff --git a/pages/index/Salesranking/Allbrands/Allbrands.js b/pages/index/Salesranking/Allbrands/Allbrands.js index 24b1eda..d665be6 100644 --- a/pages/index/Salesranking/Allbrands/Allbrands.js +++ b/pages/index/Salesranking/Allbrands/Allbrands.js @@ -1,6 +1,9 @@ // pages/index/Salesranking/Allbrands/Allbrands.js var newtime = new Date(); const app = getApp() +let iPageIndex = 1 // 当前第几页,0代表第一页 +let iPageSize =20 //每页显示多少数据 +import moment from "moment"; Page({ /** * 页面的初始数据 @@ -16,16 +19,39 @@ Page({ ranking: [], }, // 点击日期组件确定事件 - bindDateChange(e) { - that.setData({ - date: e.detail.value, - }) - }, - bindDateChange2(e) { - that.setData({ - date2: e.detail.value, - }) - }, + bindDateChange: function (e) { + let isBefore = moment(this.data.date2).isBefore(e.detail.value) + // console.log(isBefore) + if(!isBefore){ + iPageIndex=1 + iPageSize = 20 + this.setData({ + date:e.detail.value, + ranking:[], + }) + this.getData() + }else{ + this.setData({ + showDialog:isBefore, + }) + } + }, + bindDateChange2: function (e) { + let isBefore = moment(this.data.date2).isBefore(e.detail.value) + if(!isBefore){ + iPageIndex=1 + iPageSize = 20 + this.setData({ + date2:e.detail.value, + ranking:[], + }) + this.getData() + }else{ + this.setData({ + showDialog:isBefore, + }) + } + }, dropdownSel(e) { this.setData({ value1: e.detail @@ -78,76 +104,65 @@ Page({ icon: 'loading', duration: 30000 }) - // let sTimeType = wx.getStorageSync("sTimeType") || 34; - let sStartTime = wx.getStorageSync('newTime') || ''; - let sEndTime = wx.getStorageSync('newTime') || ''; - app.globalData.request({ - action: 'getCheZhuCarBrandRankingHome', - sType: 'Marketing', - sTimeType: '4', - sStartTime: sStartTime, - sEndTime: sEndTime, - iPageIndex: '1', - }).then(res => { - const arr = [] - res.forEach(e => { - let obj = { - name: e.brand, - img: e.img, - share: e.percentage, - sales: e.salescount + let obj={ + action: 'getCheZhuCarBrandRankingHome', + sType: 'Marketing', + sTimeType: '4', + sStartTime: this.data.date2 ||"", + sEndTime: this.data.date2 || "", + iPageIndex: iPageIndex, + } + //第一次加载数据 + if (iPageIndex == 1) { + this.setData({ + loadMore: true, //把"上拉加载"的变量设为true,显示 + loadAll: false //把“没有数据”设为false,隐藏 + }) + } + app.globalData.request(obj,(data)=>{ + }).then(res=>{ + if(res && res.length>0){ + iPageIndex++; + let list=this.data.ranking.concat(res); + console.log(list) + this.setData({ + ranking:list, + loadMore: false, + }); + if(res.length{ + wx.hideToast() + },500) } - arr.push(obj) - }); - this.setData({ - ranking: arr - }) }) - setTimeout(() => { - wx.hideToast(); - }, 1000) - }, - + onReachBottom:function() { + // console.log("上拉触底事件") + // console.log(iPageIndex) + let that = this + if (!that.data.loadMore) { + that.setData({ + loadMore: true, //加载中 + loadAll: false //是否加载完所有数据 + }); + //加载更多,这里做下延时加载 + that.getData(); + } +}, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } }) \ No newline at end of file diff --git a/pages/index/Salesranking/Allbrands/Allbrands.wxml b/pages/index/Salesranking/Allbrands/Allbrands.wxml index f28eb6d..bcb9397 100644 --- a/pages/index/Salesranking/Allbrands/Allbrands.wxml +++ b/pages/index/Salesranking/Allbrands/Allbrands.wxml @@ -31,21 +31,25 @@ - {{item.name}} + {{item.brand}} - {{item.share}} + {{item.percentage}} - {{item.sales}} - + {{item.salescount}} + 销量详情 - + + - \ No newline at end of file + + + 结束时间不能小于开始时间 + \ No newline at end of file diff --git a/pages/index/Salesranking/Allbrands/Allbrands.wxss b/pages/index/Salesranking/Allbrands/Allbrands.wxss index 9f686bd..31cdc4f 100644 --- a/pages/index/Salesranking/Allbrands/Allbrands.wxss +++ b/pages/index/Salesranking/Allbrands/Allbrands.wxss @@ -175,4 +175,17 @@ /* line-height: 102rpx; */ display:grid; flex-direction: row-reverse +} +.tc-d-t { + font-size: 14px; + padding: 15px 0px; + color: #909497; + text-align: center; +} +.loading { + position: relative; + bottom: 5rpx; + padding: 10rpx; + text-align: center; + font-size: 12px; } \ No newline at end of file