chart.mixin.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // 机构画像
  2. import Vue from 'vue'
  3. const chartMixin = {
  4. data() {
  5. const currentDate = this.getDate({
  6. format: true
  7. })
  8. return {
  9. date: currentDate,
  10. timeList: [
  11. { label: '全年', current: 3 },
  12. { label: '半年', current: 2 },
  13. { label: '月', current: 1 },
  14. { label: '日', current: 0 }
  15. ]
  16. }
  17. },
  18. computed: {
  19. startDate() {
  20. return this.getDate('start')
  21. },
  22. endDate() {
  23. return this.getDate('end')
  24. }
  25. },
  26. methods: {
  27. bindStartDateChange(event,type) {
  28. //开始时间
  29. console.log('开始时间==>', event.detail.value)
  30. this.params.startTime = event.detail.value
  31. this.userClubPortrait(type)
  32. },
  33. bindEndDateChange(event,type) {
  34. //结束时间
  35. console.log('结束时间==>', event.detail.value)
  36. this.params.endTime = event.detail.value
  37. this.userClubPortrait(type)
  38. },
  39. getDate(type) {
  40. const date = new Date()
  41. let year = date.getFullYear()
  42. let month = date.getMonth() + 1
  43. let day = date.getDate()
  44. if (type === 'start') {
  45. year = year - 1
  46. } else if (type === 'end') {
  47. year = year + 1
  48. }
  49. month = month > 9 ? month : '0' + month
  50. day = day > 9 ? day : '0' + day
  51. return `${year}-${month}-${day}`
  52. }
  53. }
  54. }
  55. export default chartMixin