dev
liuyongli 3 years ago
parent ece350738d
commit 62314db793

@ -110,7 +110,7 @@ Component({
//车型排行 //车型排行
vehicletype() { vehicletype() {
wx.navigateTo({ wx.navigateTo({
url: "/pages/index/Salesranking/Vehicletype/Vehicletype" url: "/pages/index/Salesranking/Salesranking"
}) })
} }

@ -1,25 +1,34 @@
// pages/index/Salesranking/Salesranking.js // pages/index/Salesranking/Salesranking.js
const app = getApp() const app = getApp()
import brokenLine from "../../../components/option/singleLineOption" import brokenLine from "../../../components/option/singleLineOption"
import histogram from "../../../components/option/columnarOption" import histogram from "../../../components/option/columnarOption"
import {times} from "../../../components/option/text" import {
times
} from "../../../components/option/text"
import moment from "moment" import moment from "moment"
let iPageIndex = 1 // 当前第几页,0代表第一页 let iPageIndex = 1 // 当前第几页,0代表第一页
let iPageSize =20 //每页显示多少数据 let iPageSize = 20 //每页显示多少数据
Page({ Page({
data: { data: {
active: 0, active: 0,
end:moment().format("YYYY-MM"), end: moment().format("YYYY-MM"),
showChart:true, showChart: true,
// select: false, // select: false,
grade_value1: "", grade_value1: "",
grade_value2: "", grade_value2: "",
grade_value3: "", grade_value3: "",
grade_value4: 0, grade_value4: 0,
grades4: [{text:'列表展示',value:0}, grades4: [{
{text:'图表展示',value:1}], text: '列表展示',
num:0, value: 0
num1:false, },
{
text: '图表展示',
value: 1
}
],
num: 0,
num1: false,
//弹出框 //弹出框
show: false, show: false,
duration: 300, duration: 300,
@ -30,33 +39,33 @@ Page({
//图表 //图表
// positiveOption:brokenLine(dName,dValue,dColor,data), // positiveOption:brokenLine(dName,dValue,dColor,data),
imageUrl: getApp().globalData.imageUrl, imageUrl: getApp().globalData.imageUrl,
date:wx.getStorageSync('newTime'), date: wx.getStorageSync('newTime'),
accountIndex:0, accountIndex: 0,
ranking:[], ranking: [],
accountIndex:0, accountIndex: 0,
sSpec: '', sSpec: '',
sPriceType: '', sPriceType: '',
sEnergyType: '', sEnergyType: '',
imageUrl: getApp().globalData.imageUrl, imageUrl: getApp().globalData.imageUrl,
mockData:[], mockData: [],
// //
ec: { ec: {
lazyLoad:true // 设置图表懒加载 lazyLoad: true // 设置图表懒加载
} }
}, },
// 标签切换点击事件 // 标签切换点击事件
onChange(val) { onChange(val) {
let n = val.detail.index; let n = val.detail.index;
this.setData({ this.setData({
active: n active: n
}) })
// wx.showToast({ // wx.showToast({
// // title: `切换到标签 ${event.detail.name}`, // // title: `切换到标签 ${event.detail.name}`,
// icon: 'none', // icon: 'none',
// }); // });
}, },
getData() { getData() {
wx.showToast({ wx.showToast({
title: '加载中', title: '加载中',
icon: 'loading', icon: 'loading',
@ -70,43 +79,42 @@ Page({
app.globalData.request({ app.globalData.request({
action: 'getUserBrand', action: 'getUserBrand',
token: 't%2BrswgjvzGM=', token: 't%2BrswgjvzGM=',
}).then(res => { }).then(res => {
let arr = [] let arr = []
for (let i = 65; i <= 90; i++) { for (let i = 65; i <= 90; i++) {
arr.push({ arr.push({
name: String.fromCharCode(i), name: String.fromCharCode(i),
data: [] data: []
}); });
} }
for(let i of res){ for (let i of res) {
for(let j of arr){ for (let j of arr) {
if(i.firstword == j.name){ if (i.firstword == j.name) {
j.data.push(i) j.data.push(i)
}
} }
} }
this.setData({ }
mockData:arr this.setData({
}) mockData: arr
setTimeout(() => { })
wx.hideToast(); setTimeout(() => {
}, 2000) wx.hideToast();
} }, 2000)
) })
setTimeout(() => { setTimeout(() => {
wx.hideToast(); wx.hideToast();
},500) }, 500)
}, },
// 排行榜数据 // 排行榜数据
getTrend(){ getTrend() {
wx.showToast({ wx.showToast({
title: '加载中', title: '加载中',
icon: 'loading', icon: 'loading',
duration: 300000 duration: 300000
}) })
let obj = { let obj = {
action: 'getCheZhuCarSeriesRankingHome', action: 'getCheZhuCarSeriesRankingHome',
sType:'Marketing', sType: 'Marketing',
sStartTime: this.data.date, sStartTime: this.data.date,
sEndTime: this.data.date, sEndTime: this.data.date,
iPageIndex: iPageIndex, iPageIndex: iPageIndex,
@ -122,25 +130,24 @@ Page({
loadAll: false //把“没有数据”设为false隐藏 loadAll: false //把“没有数据”设为false隐藏
}) })
} }
app.globalData.request(obj,(database)=>{ app.globalData.request(obj, (database) => {}).then(res => {
}).then(res => { const carName = []
const carName=[] const carValue = []
const carValue=[]
// console.log("这是数据",res) // console.log("这是数据",res)
if (res && res.length > 0) { if (res && res.length > 0) {
iPageIndex++; iPageIndex++;
//把新请求到的数据添加到列表里 //把新请求到的数据添加到列表里
let list = this.data.ranking.concat(res); let list = this.data.ranking.concat(res);
list.forEach(e=>{ list.forEach(e => {
carName.push(e.seriesname) carName.push(e.seriesname)
carValue.push(e.salescount) carValue.push(e.salescount)
}) })
// length=(carName.length/carName.length)*100 // length=(carName.length/carName.length)*100
// console.log(carName.length) // console.log(carName.length)
this.setData({ this.setData({
ranking: list, //获取数据数组 ranking: list, //获取数据数组
loadMore: false,//把"上拉加载"的变量设为false显示 loadMore: false, //把"上拉加载"的变量设为false显示
brandOption:histogram(carName,carValue,'#0084FF',false,(20/list.length)*100) brandOption: histogram(carName, carValue, '#0084FF', false, (20 / list.length) * 100)
}); });
if (res.length < iPageSize) { if (res.length < iPageSize) {
this.setData({ this.setData({
@ -160,27 +167,30 @@ Page({
}, 500) }, 500)
}) })
}, },
//页面上拉触底事件的处理函数 //页面上拉触底事件的处理函数
onReachBottom:function() { onReachBottom: function () {
// console.log("上拉触底事件") // console.log("上拉触底事件")
// console.log(iPageIndex) // console.log(iPageIndex)
let that = this let that = this
if (!that.data.loadMore) { if (!that.data.loadMore) {
that.setData({ that.setData({
loadMore: true, //加载中 loadMore: true, //加载中
loadAll: false //是否加载完所有数据 loadAll: false //是否加载完所有数据
}); });
//加载更多,这里做下延时加载 //加载更多,这里做下延时加载
that.getTrend(); that.getTrend();
} }
}, },
// 筛选列表 // 筛选列表
getAmount() { getAmount() {
//能源 //能源
app.globalData.request({ app.globalData.request({
action: 'getEnergy', action: 'getEnergy',
}).then(res => { }).then(res => {
let arr = [{text:"全部能源",value:""}] let arr = [{
text: "全部能源",
value: ""
}]
res.forEach(ele => { res.forEach(ele => {
let obj = { let obj = {
text: ele.value, text: ele.value,
@ -196,7 +206,10 @@ Page({
app.globalData.request({ app.globalData.request({
action: 'getPrice', action: 'getPrice',
}).then(res => { }).then(res => {
let arr = [{text:"全部价格",value:""}] let arr = [{
text: "全部价格",
value: ""
}]
res.forEach(ele => { res.forEach(ele => {
let obj = { let obj = {
text: ele.value, text: ele.value,
@ -213,7 +226,10 @@ Page({
action: 'getSpec', action: 'getSpec',
}).then(res => { }).then(res => {
// const data = res; // const data = res;
let arr = [{text:"全部级别",value:""}] let arr = [{
text: "全部级别",
value: ""
}]
res.forEach(ele => { res.forEach(ele => {
let obj = { let obj = {
text: ele.value, text: ele.value,
@ -236,118 +252,100 @@ Page({
}, },
// 按级别 // 按级别
mySelect1(e) { mySelect1(e) {
iPageIndex=1 iPageIndex = 1
iPageSize = 20 iPageSize = 20
this.setData({ this.setData({
ranking:[], ranking: [],
sSpec: e.detail, sSpec: e.detail,
}) })
this.getTrend() this.getTrend()
}, },
// 按价格 // 按价格
mySelect2(e) { mySelect2(e) {
iPageIndex=1 iPageIndex = 1
iPageSize = 20 iPageSize = 20
this.setData({ this.setData({
ranking:[], ranking: [],
sPriceType: e.detail, sPriceType: e.detail,
}) })
this.getTrend() this.getTrend()
}, },
// 按能源 // 按能源
mySelect3(e) { mySelect3(e) {
iPageIndex=1 iPageIndex = 1
iPageSize = 20 iPageSize = 20
this.setData({ this.setData({
ranking:[], ranking: [],
sEnergyType: e.detail, sEnergyType: e.detail,
}) })
this.getTrend() this.getTrend()
}, },
// 列表展示 // 列表展示
mySelect4(e) { mySelect4(e) {
iPageIndex=1 iPageIndex = 1
iPageSize = 20 iPageSize = 20
this.setData({ this.setData({
ranking:[], ranking: [],
a: e.detail != 0 a: e.detail != 0
}) })
this.getTrend() this.getTrend()
}, },
// 全部 // 全部
all(){ all() {
iPageIndex=1 iPageIndex = 1
iPageSize = 20 iPageSize = 20
this.data.num++ this.data.num++
let dj=this.data.num%2==0 let dj = this.data.num % 2 == 0
this.setData({ this.setData({
ranking:[], ranking: [],
grade_value1: "", grade_value1: "",
grade_value2: "", grade_value2: "",
grade_value3: "", grade_value3: "",
sSpec: '', sSpec: '',
sPriceType: '', sPriceType: '',
sEnergyType: '', sEnergyType: '',
boxSize:dj?'noall':'all1' boxSize: dj ? 'noall' : 'all1'
}) })
this.getTrend() this.getTrend()
},
//全部品牌
Allbrands(){
wx.navigateTo({
url: '/pages/index/Salesranking/Allbrands/Allbrands',
})
}, },
//单个品牌 bindDateChange: function (e) {
Brands(e){ this.data.num1 = true
var name=e.currentTarget.dataset.brand iPageIndex = 1
// console.log(name)
wx.navigateTo({
url: '/pages/index/Brandsales/Brandsales?carName='+name,
})
},
bindDateChange: function(e) {
this.data.num1=true
iPageIndex=1
iPageSize = 20 iPageSize = 20
this.setData({ this.setData({
date: e.detail.value, date: e.detail.value,
ranking:[], ranking: [],
boxSize1:!this.data.num1?'noall':'all1' boxSize1: !this.data.num1 ? 'noall' : 'all1'
}) })
this.getTrend() this.getTrend()
}, },
priceSel(e) { priceSel(e) {
this.setData({ this.setData({
intervalSel: e.currentTarget.dataset.index intervalSel: e.currentTarget.dataset.index
}) })
}, },
//弹出框 //弹出框
popup(e) {
popup(e) {
let duration = this.data.duration let duration = this.data.duration
let models = e.currentTarget.dataset.car let models = e.currentTarget.dataset.car
app.globalData.request({ app.globalData.request({
action:"getCheZhuCarSeriesListHome", action: "getCheZhuCarSeriesListHome",
sType:"Marketing", sType: "Marketing",
sSeriesName:models, sSeriesName: models,
sStartTime:times(this.data.date), sStartTime: times(this.data.date),
sEndTime: this.data.date, sEndTime: this.data.date,
}).then(res => { }).then(res => {
// console.log(res) // console.log(res)
const dataTime=[] const dataTime = []
const dataCar=[] const dataCar = []
res.forEach(e => { res.forEach(e => {
if((e.sourcetime).substring(5,6)=="0"){ if ((e.sourcetime).substring(5, 6) == "0") {
dataTime.push((e.sourcetime).substring((e.sourcetime).length-1,(e.sourcetime).length)+'月') dataTime.push((e.sourcetime).substring((e.sourcetime).length - 1, (e.sourcetime).length) + '月')
}else{ } else {
dataTime.push((e.sourcetime).substring((e.sourcetime).length-2,(e.sourcetime).length)+"月") dataTime.push((e.sourcetime).substring((e.sourcetime).length - 2, (e.sourcetime).length) + "月")
} }
dataCar.push(e.salescount) dataCar.push(e.salescount)
}); });
// console.log(dataCar,dataTime)
// console.log(models)
this.setData({ this.setData({
show: true, show: true,
duration, duration,
@ -364,8 +362,7 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {},
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成

@ -8,61 +8,12 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "",
"pathName": "pages/index/Salesranking/Vehicletype/Vehicletype",
"query": "",
"launchMode": "default",
"scene": null
},
{ {
"name": "详情", "name": "详情",
"pathName": "pages/detail/index", "pathName": "pages/detail/index",
"query": "id=452949383c124d65a4b315b64309d29e&mod=0", "query": "id=452949383c124d65a4b315b64309d29e&mod=0",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
},
{
"name": "品牌车型搜索",
"pathName": "pages/index/Salesranking/Salesranking",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/Salesranking/Allbrands/Allbrands",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/Salesranking/Brandranking/Brandranking",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/Brandsales/Brandsales",
"query": "carName=%E5%A5%A5%E8%BF%AA",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/Salesranking/Salesranking",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }

Loading…
Cancel
Save