// 机构画像 import Vue from 'vue' const chartMixin = { data() { const currentDate = this.getDate({ format: true }) return { date: currentDate, timeList: [ { label: '全年', current: 3 }, { label: '半年', current: 2 }, { label: '月', current: 1 }, { label: '日', current: 0 } ] } }, computed: { startDate() { return this.getDate('start') }, endDate() { return this.getDate('end') } }, methods: { bindStartDateChange(event,type) { //开始时间 console.log('开始时间==>', event.detail.value) this.params.startTime = event.detail.value this.userClubPortrait(type) }, bindEndDateChange(event,type) { //结束时间 console.log('结束时间==>', event.detail.value) this.params.endTime = event.detail.value this.userClubPortrait(type) }, 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