wylyl22 3 years ago
parent 97b874ff46
commit 6a18a0845c

@ -87,7 +87,6 @@ showPopup() {
}, },
// // 点击日期组件确定事件 // // 点击日期组件确定事件
bindDateChange: function (e) { bindDateChange: function (e) {
let isBefore = moment(this.data.date2).isBefore(this.data.date) let isBefore = moment(this.data.date2).isBefore(this.data.date)
// console.log(isBefore) // console.log(isBefore)
if(!isBefore){ if(!isBefore){

@ -99,4 +99,11 @@
padding: 15px 0px; padding: 15px 0px;
color: #909497; color: #909497;
text-align: center; text-align: center;
}
.loading {
position: relative;
bottom: 5rpx;
padding: 10rpx;
text-align: center;
font-size: 12px;
} }

@ -1,6 +1,9 @@
// pages/index/Salesranking/Allbrands/Allbrands.js // pages/index/Salesranking/Allbrands/Allbrands.js
var newtime = new Date(); var newtime = new Date();
const app = getApp() const app = getApp()
let iPageIndex = 1 // 当前第几页,0代表第一页
let iPageSize =20 //每页显示多少数据
import moment from "moment";
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
@ -16,16 +19,39 @@ Page({
ranking: [], ranking: [],
}, },
// 点击日期组件确定事件 // 点击日期组件确定事件
bindDateChange(e) { bindDateChange: function (e) {
that.setData({ let isBefore = moment(this.data.date2).isBefore(e.detail.value)
date: e.detail.value, // console.log(isBefore)
}) if(!isBefore){
}, iPageIndex=1
bindDateChange2(e) { iPageSize = 20
that.setData({ this.setData({
date2: e.detail.value, 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) { dropdownSel(e) {
this.setData({ this.setData({
value1: e.detail value1: e.detail
@ -78,76 +104,65 @@ Page({
icon: 'loading', icon: 'loading',
duration: 30000 duration: 30000
}) })
// let sTimeType = wx.getStorageSync("sTimeType") || 34; let obj={
let sStartTime = wx.getStorageSync('newTime') || ''; action: 'getCheZhuCarBrandRankingHome',
let sEndTime = wx.getStorageSync('newTime') || ''; sType: 'Marketing',
app.globalData.request({ sTimeType: '4',
action: 'getCheZhuCarBrandRankingHome', sStartTime: this.data.date2 ||"",
sType: 'Marketing', sEndTime: this.data.date2 || "",
sTimeType: '4', iPageIndex: iPageIndex,
sStartTime: sStartTime, }
sEndTime: sEndTime, //第一次加载数据
iPageIndex: '1', if (iPageIndex == 1) {
}).then(res => { this.setData({
const arr = [] loadMore: true, //把"上拉加载"的变量设为true显示
res.forEach(e => { loadAll: false //把“没有数据”设为false隐藏
let obj = { })
name: e.brand, }
img: e.img, app.globalData.request(obj,(data)=>{
share: e.percentage, }).then(res=>{
sales: e.salescount 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<iPageSize){
this.setData({
loadMore: false,
loadAll: true
})
}else{
this.setData({
loadAll:true,
loadMore:false
})
}
setTimeout(()=>{
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 () { onShow: function () {
}, },
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
}) })

@ -31,21 +31,25 @@
</view> </view>
<view class="ranks_text1"> <view class="ranks_text1">
<image style="width: 96rpx;height: 72rpx;" src="{{item.img}}"></image> <image style="width: 96rpx;height: 72rpx;" src="{{item.img}}"></image>
<view style="margin-left: 15rpx; height: 102rpx;line-height: 102rpx;width: 180rpx;">{{item.name}} <view style="margin-left: 15rpx; height: 102rpx;line-height: 102rpx;width: 180rpx;">{{item.brand}}
</view> </view>
</view> </view>
<view class="ranks_text2">{{item.share}}</view> <view class="ranks_text2">{{item.percentage}}</view>
<view class="ranks_text3"> <view class="ranks_text3">
<view class="volume">{{item.sales}}</view> <view class="volume">{{item.salescount}}</view>
<view class="trend" bindtap="detail" data-carName='{{item.name}}'> <view class="trend" bindtap="detail" data-carName='{{item.brand}}'>
<van-icon size="16px" name="arrow" /> <van-icon size="16px" name="arrow" />
<view>销量详情</view> <view>销量详情</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="loading" hidden="{{!loadMore}}">正在载入更多...</view>
<view class="loading" hidden="{{!loadAll}}">已加载全部</view>
</view> </view>
</view> </view>
<van-dialog use-slot title="注意" show="{{ showDialog }}" bind:confirm="cdialog">
<view class="tc-d-t">结束时间不能小于开始时间</view>
</van-dialog>

@ -175,4 +175,17 @@
/* line-height: 102rpx; */ /* line-height: 102rpx; */
display:grid; display:grid;
flex-direction: row-reverse 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;
} }
Loading…
Cancel
Save