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.

130 lines
4.2 KiB

3 years ago
import histogram from "../../option/columnarOption"
3 years ago
const app = getApp()
3 years ago
Component({
data: {
3 years ago
imageUrl: getApp().globalData.imageUrl,
3 years ago
showChart: true,
3 years ago
},
lifetimes: {
attached() {
this.getData()
}
3 years ago
},
methods: {
3 years ago
getData() {
3 years ago
wx.showToast({
title: '加载中',
icon: 'loading',
3 years ago
duration: 50000
3 years ago
})
3 years ago
Promise.all([this.getTimeData(), this.getBrandData(), this.getModelData()]).then(() => {
setTimeout(() => {
wx.hideToast();
}, 500)
})
},
// 获取时间
getTimeData() {
return new Promise((resolve, reject) => {
app.globalData.request({
action: 'getCheZhuLatestTimeHome',
sType: 'Marketing'
}).then(res => {
wx.setStorageSync('newTime', res)
this.setData({
newTime: wx.getStorageSync('newTime')
})
resolve(true)
}).catch(() => {
reject(false)
3 years ago
})
})
3 years ago
},
// 获取品牌的数据
getBrandData() {
return new Promise((resolve, reject) => {
app.globalData.request({
action: 'getCheZhuCarBrandRankingHome',
sType: 'Marketing',
sTimeType: 4,
sStartTime: wx.getStorageSync('newTime') || '',
sEndTime: wx.getStorageSync('newTime') || ''
}).then(res => {
console.log(res)
const carName = []
const carCount = []
res.forEach(e => {
carName.push(e.brand),
carCount.push(e.salescount)
});
this.setData({
3 years ago
brandOption: histogram(carName, carCount,'#0084FF'),
3 years ago
})
resolve(true)
}).catch(() => {
reject(false)
3 years ago
})
})
3 years ago
},
getModelData() {
return new Promise((resolve, reject) => {
app.globalData.request({
action: 'getCheZhuCarSeriesRankingHome',
sType: 'Marketing',
sTimeType: 4,
sStartTime: wx.getStorageSync('newTime') || "",
sEndTime: wx.getStorageSync('newTime') || ""
}).then(res => {
console.log(res)
const carName = []
const carCount = []
res.forEach(e => {
carName.push(e.seriesname),
carCount.push(e.salescount)
});
this.setData({
modelOption: histogram(carName, carCount, '#20CC62'),
})
resolve(true)
}).catch(() => {
reject(false)
3 years ago
})
})
3 years ago
},
priceSel(e) {
3 years ago
this.setData({
intervalSel: e.currentTarget.dataset.index
})
3 years ago
},
3 years ago
Rankdetail() {
3 years ago
wx.navigateTo({
url: "/pages/index/Salesranking/Salesranking"
})
3 years ago
},
//品牌排行
3 years ago
ranking() {
3 years ago
// if (!wx.getStorageSync('token')) {
// wx.navigateTo({
// url: '/pages/mine/pages/bindUser/index'
// })
// } else {
3 years ago
wx.navigateTo({
url: "/pages/index/Salesranking/Brandranking/Brandranking"
})
3 years ago
// }
3 years ago
},
//车型排行
3 years ago
vehicletype() {
3 years ago
// if (!wx.getStorageSync('token')) {
// wx.navigateTo({
// url: '/pages/mine/pages/bindUser/index'
// })
// } else {
3 years ago
wx.navigateTo({
url: "/pages/index/Salesranking/Salesranking"
})
3 years ago
// }
3 years ago
}
3 years ago
3 years ago
}
})