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.

139 lines
3.2 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
Page({
/**
* 页面的初始数据
*/
data: {
3 years ago
end:newtime.toLocaleDateString(),
3 years ago
show:false,
3 years ago
date:wx.getStorageSync('newTime'),
3 years ago
date2:times2(wx.getStorageSync('newTime')),
3 years ago
currentDate: new Date().getTime(),
minDate: new Date().getTime(),
3 years ago
ranking: [],
3 years ago
},
dropdownSel(e){
this.setData({
value1:e.detail
})
3 years ago
},
3 years ago
getData(carName,sStartTime=times2(wx.getStorageSync('newTime')),sEndTime=wx.getStorageSync('newTime')){
3 years ago
app.globalData.request({
action: 'getCheZhuCarSeriesListHome',
sType: 'Marketing',
3 years ago
sBrand: carName|| '',
sStartTime:sStartTime ||"",
sEndTime:sEndTime||'',
3 years ago
}).then(res => {
const arr=[]
3 years ago
const time=[]
const obj={}
var totalSum=0
var num=0
res.forEach(i=>{
totalSum+=parseInt(i.salescount)
// console.log(i.salescount)
if(!obj[i.sourcetime]){
obj[i.sourcetime] = []
time.push(i.sourcetime)
num++
}
obj[i.sourcetime].push(i)
})
for(let j=0;j<num;j++){
var sum=0
for(let a=0;a<obj[time[j]].length;a++){
sum+= parseInt( obj[time[j]][a].salescount)
}
arr.push({times:time[j],sales:sum,share:((sum/totalSum)*100).toFixed(2),brand:carName})
}
this.setData({
ranking:arr
})
})
3 years ago
},
3 years ago
3 years ago
priceSel(e){
this.setData({
priceSelected: e.currentTarget.dataset.index
})
},
3 years ago
//详情跳转
3 years ago
detail(e){
console.log(e)
const carBrand=e.currentTarget.dataset.carbrand
const carTime=e.currentTarget.dataset.cartime
// console.log(carbrand,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,
});
},
3 years ago
// // 点击日期组件确定事件
3 years ago
bindDateChange: function (e) {
3 years ago
// console.log(this.data)
// this.getData('',this.data.date,"")
3 years ago
this.setData({
3 years ago
date:e.detail.value
3 years ago
})
},
bindDateChange2: function (e) {
3 years ago
// this.getData("","",this.data.date)
3 years ago
this.setData({
3 years ago
date2: e.detail.value
3 years ago
})
},
3 years ago
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
3 years ago
this.getData(this.options.carName)
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(){
console.log("触发刷行")
},
3 years ago
/**
* 生命周期函数--监听页面显示
*/
3 years ago
onShow: function (options) {
// console.log(this.data)
// this.getData(this.options.carName)
3 years ago
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
})