|
|
|
// pages/index/Rankdetail/Rankdetail.js
|
|
|
|
var newtime = new Date();
|
|
|
|
const app = getApp();
|
|
|
|
import {
|
|
|
|
times2
|
|
|
|
} from "../../../components/option/text"
|
|
|
|
import moment from "moment";
|
|
|
|
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
|
|
|
|
},
|
|
|
|
dropdownSel(e) {
|
|
|
|
this.setData({
|
|
|
|
value1: e.detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getData() {
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getCheZhuCarSeriesListHome',
|
|
|
|
sType: 'Marketing',
|
|
|
|
sBrand: this.data.carName || '',
|
|
|
|
sStartTime: this.data.date || "",
|
|
|
|
sEndTime: this.data.date2 || '',
|
|
|
|
}).then(res => {
|
|
|
|
const arr = []
|
|
|
|
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: this.data.carName
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (arr.length == 0) {
|
|
|
|
this.data.loadMore = true
|
|
|
|
} else {
|
|
|
|
this.data.loadMore = false
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
ranking: arr,
|
|
|
|
loadMore: this.data.loadMore
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
priceSel(e) {
|
|
|
|
this.setData({
|
|
|
|
priceSelected: e.currentTarget.dataset.index
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//详情跳转
|
|
|
|
detail(e) {
|
|
|
|
console.log(e)
|
|
|
|
const carBrand = e.currentTarget.dataset.carbrand
|
|
|
|
const carTime = e.currentTarget.dataset.cartime
|
|
|
|
// console.log(carbrand,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(this.data.date)
|
|
|
|
// console.log(isBefore)
|
|
|
|
if (!isBefore) {
|
|
|
|
this.setData({
|
|
|
|
date: e.detail.value
|
|
|
|
})
|
|
|
|
this.getData()
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
showDialog: isBefore,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
bindDateChange2: function (e) {
|
|
|
|
this.data.date2 = e.detail.value
|
|
|
|
let isBefore = moment(this.data.date2).isBefore(this.data.date)
|
|
|
|
if (!isBefore) {
|
|
|
|
this.setData({
|
|
|
|
date2: e.detail.value
|
|
|
|
})
|
|
|
|
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
|
|
|
|
}
|
|
|
|
this.getData()
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
date: this.data.date,
|
|
|
|
date2: this.data.date2,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
//动态设置标题
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: this.options.carName + "汽车销量"
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
onReachBottom: function () {
|
|
|
|
console.log("触发刷行")
|
|
|
|
},
|
|
|
|
onShow: function (options) {}
|
|
|
|
})
|