You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.1 KiB

3 years ago
// pages/index/Rankdetail/Rankdetail.js
3 years ago
var newtime = new Date();
3 years ago
const app = getApp();
3 years ago
import {
times2
} from "../../../components/option/text"
3 years ago
import moment from "moment";
3 years ago
let iPageIndex = 1 // 当前第几页,0代表第一页
let iPageSize = 20 //每页显示多少数据
3 years ago
Page({
/**
* 页面的初始数据
*/
data: {
3 years ago
// end: moment().format("YYYY-MM"),
3 years ago
show: false,
date: '',
date2: '',
3 years ago
// currentDate: new Date().getTime(),
// minDate: new Date().getTime(),
3 years ago
ranking: [],
3 years ago
carName: "",
3 years ago
showDialog: false,
3 years ago
loadMore: false, //"上拉加载"的变量默认false隐藏
loadAll: false, //“没有数据”的变量默认false隐藏
3 years ago
},
dropdownSel(e) {
this.setData({
value1: e.detail
})
},
getData() {
3 years ago
let obj = {
action: 'getCheZhuCarBrandTimeRankingHome',
3 years ago
sType: 'Marketing',
sBrand: this.data.carName || '',
sStartTime: this.data.date || "",
sEndTime: this.data.date2 || '',
3 years ago
iPageIndex: iPageIndex,
iPageSize: iPageSize,
}
//第一次加载数据
if (iPageIndex == 1) {
this.setData({
loadMore: true, //把"上拉加载"的变量设为true显示
loadAll: false //把“没有数据”设为false隐藏
3 years ago
})
3 years ago
}
app.globalData.request(obj).then(res => {
if (res && res.length > 0) {
iPageIndex++;
let arr = this.data.ranking.concat(res);
this.setData({
ranking: arr,
loadMore: false
3 years ago
})
3 years ago
if (res.length < iPageSize) {
this.setData({
loadMore: false, //隐藏加载中。。
loadAll: true //所有数据都加载完了
});
}
3 years ago
} else {
3 years ago
this.setData({
loadAll: true, //把“没有数据”设为true显示
loadMore: false //把"上拉加载"的变量设为false隐藏
});
3 years ago
}
})
3 years ago
},
3 years ago
3 years ago
priceSel(e) {
this.setData({
priceSelected: e.currentTarget.dataset.index
})
},
//详情跳转
detail(e) {
3 years ago
const carBrand = this.data.carName;
const carTime = e.currentTarget.dataset.cartime;
3 years ago
wx.navigateTo({
3 years ago
url: '/pages/index/detailedvolume/detailedvolume?brand=' + carBrand + "&time=" + carTime,
3 years ago
})
3 years ago
},
showPopup() {
this.setData({
show: true
});
},
onClose() {
this.setData({
show: false
});
},
onInput(event) {
this.setData({
currentDate: event.detail,
});
},
// // 点击日期组件确定事件
bindDateChange: function (e) {
3 years ago
let isBefore = moment(this.data.date2).isBefore(e.detail.value)
3 years ago
// console.log(isBefore)
if (!isBefore) {
3 years ago
iPageIndex = 1
iPageSize = 20
3 years ago
this.setData({
3 years ago
date: e.detail.value,
ranking: [],
3 years ago
})
this.getData()
} else {
this.setData({
showDialog: isBefore,
})
}
},
bindDateChange2: function (e) {
this.data.date2 = e.detail.value
3 years ago
let isBefore = moment(this.data.date).isBefore(e.detail.value)
if (isBefore) {
3 years ago
iPageIndex = 1
iPageSize = 20
3 years ago
this.setData({
3 years ago
date2: e.detail.value,
ranking: [],
3 years ago
})
this.getData()
} else {
this.setData({
3 years ago
showDialog: !isBefore,
3 years ago
})
}
},
3 years ago
/**
* 生命周期函数--监听页面加载
*/
3 years ago
onLoad(options) {
3 years ago
this.data.carName = options.carName
if (options.date == undefined) {
this.data.date = times2(wx.getStorageSync('newTime')),
3 years ago
this.data.date2 = wx.getStorageSync('newTime')
3 years ago
} else {
this.data.date = options.date
this.data.date2 = options.date2
}
3 years ago
iPageIndex = 1;
3 years ago
this.getData()
3 years ago
3 years ago
this.setData({
date: this.data.date,
date2: this.data.date2,
3 years ago
});
3 years ago
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
3 years ago
//动态设置标题
3 years ago
wx.setNavigationBarTitle({
title: this.options.carName + "汽车销量"
})
3 years ago
},
3 years ago
onReachBottom: function () {
3 years ago
console.log("上拉触底事件")
let that = this
if (!that.data.loadMore) {
that.setData({
loadMore: true, //加载中
loadAll: false //是否加载完所有数据
});
//加载更多,这里做下延时加载
that.getData();
}
3 years ago
},
3 years ago
onShow: function (options) {}
})