wylyl22 3 years ago
parent 97b874ff46
commit 6a18a0845c

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

@ -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;
}

@ -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<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 () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -31,21 +31,25 @@
</view>
<view class="ranks_text1">
<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 class="ranks_text2">{{item.share}}</view>
<view class="ranks_text2">{{item.percentage}}</view>
<view class="ranks_text3">
<view class="volume">{{item.sales}}</view>
<view class="trend" bindtap="detail" data-carName='{{item.name}}'>
<view class="volume">{{item.salescount}}</view>
<view class="trend" bindtap="detail" data-carName='{{item.brand}}'>
<van-icon size="16px" name="arrow" />
<view>销量详情</view>
</view>
</view>
</view>
</view>
<view class="loading" hidden="{{!loadMore}}">正在载入更多...</view>
<view class="loading" hidden="{{!loadAll}}">已加载全部</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; */
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;
}
Loading…
Cancel
Save