zx 3 years ago
parent 0f66601186
commit 89b19ac57d

@ -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()

@ -11,13 +11,26 @@
</view>
<view class="top">
<view class="box_title">
<picker mode="date" header-text="选择时间" fields="month" value="{{date}}" bindchange="bindDateChange">
<view class="{{boxSize1}}">
<!-- <text class="color3">填报时间:</text> -->
<text>{{date}}</text>
<text class="timeIcon">▼</text>
<van-dropdown-menu>
<van-dropdown-item title="{{currentDate == ''?'选择日期':currentDate}}">
<view style="margin: 24rpx">
<view class="filter">
<view wx:for="{{dateList}}" wx:key="index">
<view data-value="{{item}}" wx-if="{{currentDate == item}}" class="more-item-active" style="width: 200rpx" bindtap="changeDate">{{item}}</view>
<view data-value="{{item}}" wx-if="{{currentDate != item}}" class="more-item" style="width: 200rpx" bindtap="changeDate">{{item}}</view>
</view>
</picker>
<view>
<view data-value="past3" wx-if="{{currentDate == '近3个月'}}" class="more-item-active" style="width: 200rpx" bindtap="changePast">近3个月</view>
<view data-value="past3" wx-if="{{currentDate != '近3个月'}}" class="more-item" style="width: 200rpx" bindtap="changePast">近3个月</view>
</view>
<view>
<view data-value="past6" wx-if="{{currentDate == '近6个月'}}" class="more-item-active" style="width: 200rpx" bindtap="changePast">近6个月</view>
<view data-value="past6" wx-if="{{currentDate != '近6个月'}}" class="more-item" style="width: 200rpx" bindtap="changePast">近6个月</view>
</view>
</view>
</view>
</van-dropdown-item>
</van-dropdown-menu>
</view>
</view>
</view>

@ -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;
@ -358,3 +358,30 @@ 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;
}
Loading…
Cancel
Save