123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- // 统计数据
- // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
- import Vue from 'vue'
- const chartMixin = {
- data() {
- const currentDate = this.getDate({
- format: true
- })
- return {
- date: currentDate,
- current:0,
- timeList: [
- { label: '全年', current: 0 },
- { label: '半年', current: 1 },
- { label: '月', current: 2 },
- { label: '日', current: 3 }
- ]
- }
- },
- computed: {
- startDate() {
- return this.getDate('start')
- },
- endDate() {
- return this.getDate('end')
- }
- },
- methods: {
- handleTimeClick(type,index){
- //年月日点击
- this.current = index
- },
- bindStartDateChange(event) {
- //开始时间
- console.log('开始时间==>', event.detail.value)
- this.queryData.startAddTime = event.detail.value
- },
- bindEndDateChange(event) {
- //结束时间
- console.log('结束时间==>', event.detail.value)
- this.queryData.endAddTime = event.detail.value
- },
- getDate(type) {
- const date = new Date()
- let year = date.getFullYear()
- let month = date.getMonth() + 1
- let day = date.getDate()
- if (type === 'start') {
- year = year - 1
- } else if (type === 'end') {
- year = year + 1
- }
- month = month > 9 ? month : '0' + month
- day = day > 9 ? day : '0' + day
- return `${year}-${month}-${day}`
- }
- }
- }
- export default chartMixin
|