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