From 89b19ac57da64fa9cd407bc33ae160bf67bff866 Mon Sep 17 00:00:00 2001 From: zx <604444282@qq.com> Date: Tue, 29 Nov 2022 11:50:16 +0800 Subject: [PATCH] zx --- pages/index/Salesranking/Salesranking.js | 88 ++++++++++++++-------- pages/index/Salesranking/Salesranking.wxml | 27 +++++-- pages/index/Salesranking/Salesranking.wxss | 31 +++++++- 3 files changed, 105 insertions(+), 41 deletions(-) diff --git a/pages/index/Salesranking/Salesranking.js b/pages/index/Salesranking/Salesranking.js index b0f88e1..795ca8d 100644 --- a/pages/index/Salesranking/Salesranking.js +++ b/pages/index/Salesranking/Salesranking.js @@ -40,7 +40,6 @@ Page({ //图表 // positiveOption:brokenLine(dName,dValue,dColor,data), imageUrl: getApp().globalData.imageUrl, - date: '', accountIndex: 0, ranking: [], accountIndex: 0, @@ -57,6 +56,56 @@ Page({ ec: { lazyLoad: true // 设置图表懒加载 }, + dateList: [], //日期列表 + currentDate: '', + startDate: '', + endDate: '' + }, + onLoad() { + app.globalData.request({ + action: 'getCheZhuLatestTimeHome', + sType: 'Marketing', + token: wx.getStorageSync('token') || 't%2BrswgjvzGM=', + }).then(res => { + let dateArr = []; + for(let i=0; i<6;i++) { + let date = this.getLastMonth(res, i); + dateArr.push(date); + }; + this.setData({dateList: dateArr}); + }) + }, + getLastMonth(dt, number = 0) { + if(number >= 12) {return} + let year = new Date(dt).getFullYear(); //get年份 + let month = new Date(dt).getMonth() + 1; //get月份 + let m = month - number; + let y = year; + if(m < 0) { + y = y - 1; m = 12 + m; + }; + if(m < 10) { + m = '0' + m; + } + return y+'-'+m; + }, + changeDate(option) { + iPageIndex = 1 + iPageSize = 20 + let value = option.currentTarget.dataset.value; + this.setData({ranking: [], currentDate: value, startDate: value, endDate: value}); + this.getTrend(); + }, + changePast(option) { + iPageIndex = 1 + iPageSize = 20 + let value = option.currentTarget.dataset.value; + if(value == 'past3') { + this.setData({ranking: [], endDate: this.data.dateList[0], startDate: this.data.dateList[2], currentDate: '近3个月'}) + } else if(value == 'past6') { + this.setData({ranking: [], endDate: this.data.dateList[0], startDate: this.data.dateList[5], currentDate: '近6个月'}) + } + this.getTrend(); }, // 标签切换点击事件 onChange(val) { @@ -119,8 +168,8 @@ Page({ let obj = { action: 'getCheZhuCarSeriesRankingHome', sType: 'Marketing', - sStartTime: this.data.date, - sEndTime: this.data.date, + sStartTime: this.data.startDate, + sEndTime: this.data.endDate, iPageIndex: iPageIndex, iPageSize: iPageSize, sSpec: this.data.sSpec, @@ -308,17 +357,6 @@ Page({ }) this.getTrend() }, - bindDateChange: function (e) { - this.data.num1 = true - iPageIndex = 1 - iPageSize = 20 - this.setData({ - date: e.detail.value, - ranking: [], - boxSize1: !this.data.num1 ? 'noall' : 'all1' - }) - this.getTrend() - }, priceSel(e) { this.setData({ intervalSel: e.currentTarget.dataset.index @@ -332,8 +370,8 @@ Page({ action: "getCheZhuCarSeriesListHome", sType: "Marketing", sSeriesName: models, - sStartTime: times(this.data.date), - sEndTime: this.data.date, + sStartTime: times(this.data.startDate), + sEndTime: this.data.endDate, }).then(res => { // console.log(res) const dataTime = [] @@ -364,25 +402,11 @@ Page({ show: false }) }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) {}, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ onShow() { iPageIndex = 1; this.setData({ - date: wx.getStorageSync('newTime') + startDate: wx.getStorageSync('newTime'), + endDate: wx.getStorageSync('newTime') }) // this.getTabBar().init(); this.getData() diff --git a/pages/index/Salesranking/Salesranking.wxml b/pages/index/Salesranking/Salesranking.wxml index 7b31460..0704871 100644 --- a/pages/index/Salesranking/Salesranking.wxml +++ b/pages/index/Salesranking/Salesranking.wxml @@ -11,13 +11,26 @@ - - - - {{date}} - - - + + + + + + {{item}} + {{item}} + + + 近3个月 + 近3个月 + + + 近6个月 + 近6个月 + + + + + diff --git a/pages/index/Salesranking/Salesranking.wxss b/pages/index/Salesranking/Salesranking.wxss index 58b8472..b1059bc 100644 --- a/pages/index/Salesranking/Salesranking.wxss +++ b/pages/index/Salesranking/Salesranking.wxss @@ -46,9 +46,9 @@ } .box_title { - color: #000; + /* color: #000; width: 150rpx; - height: 60rpx; + height: 60rpx; */ line-height: 60rpx; font-size: 24rpx; text-align: center; @@ -357,4 +357,31 @@ van-dropdown-item van-dropdown-item--down { .is_show { display: block; +} + +/* 筛选项 */ +.filter { + display: flex; + flex-wrap: wrap; + width: 100%; +} +.more-item { + width: 296rpx; + height: 72rpx; + margin: 16rpx; + background: #F9F9F9; + text-align: center; + line-height: 72rpx; + font-size: 12px; + color: #111111; +} +.more-item-active { + width: 296rpx; + height: 72rpx; + margin: 16rpx; + background: #F0F5FF; + text-align: center; + line-height: 72rpx; + font-size: 12px; + color: #0084FF; } \ No newline at end of file