酷炫直播运营系统小程序版本

timeFiltrate.vue 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view>
  3. <view class="timeList">
  4. <view
  5. class="box"
  6. v-for="(item,index) in timeList"
  7. :key='item.id'
  8. :class="(start_time==item.start_time && end_time==item.end_time)?'active':''"
  9. @click="changeInit(item)">
  10. {{ item.name }}
  11. </view>
  12. <view class="time_container">
  13. <uni-datetime-picker
  14. class="timeCommon"
  15. v-model="time"
  16. :end="tomorrw"
  17. type="daterange"
  18. :clear-icon="false"
  19. @change="timeChange"
  20. rangeSeparator="至"/>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data(){
  28. return{
  29. tomorrw:this.$getDay(0, false),//今天以后不能选
  30. timeList: [
  31. // { id: 1, name: '昨日', start_time: this.$getDay(-1, false), end_time: this.$getDay(-1, false) },
  32. { id: 7, name: '近7日', start_time: this.$getDay(-7, false), end_time: this.$getDay(0, false) },
  33. { id: 30, name: '近30日', start_time: this.$getDay(-30, false), end_time: this.$getDay(0, false) }
  34. ],
  35. time: [this.$getDay(-30, false), this.$getDay(0, false)],
  36. start_time: this.$getDay(-30, false),
  37. end_time: this.$getDay(0, false),
  38. }
  39. },
  40. onLoad(){
  41. },
  42. created(){
  43. this.$emit('getchildTime',this.start_time,this.end_time)//将时间传给父组件
  44. },
  45. methods:{
  46. timeChange(e){
  47. this.start_time = e[0];
  48. this.end_time = e[1];
  49. this.$emit('getchildTime',this.start_time,this.end_time)//将时间传给父组件
  50. },
  51. changeInit (item) {// 时间筛选
  52. this.start_time = item.start_time;
  53. this.end_time = item.end_time;
  54. this.time = [item.start_time, item.end_time]
  55. this.$emit('getchildTime',this.start_time,this.end_time)//将时间传给父组件
  56. },
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .timeList{
  62. display: flex;
  63. align-items: center;
  64. //justify-content: space-between;
  65. padding: 20rpx 0;
  66. .box{
  67. border: 1px solid #5B80F4;
  68. border-radius: 8rpx;
  69. font-size: 28rpx;
  70. width: 120rpx;
  71. height: 50rpx;
  72. line-height: 48rpx;
  73. text-align: center;
  74. margin-right: 20rpx;
  75. }
  76. .active{
  77. background-color: #5B80F4;
  78. }
  79. .time_container{
  80. width: 61%;
  81. height: 50rpx;
  82. line-height: 50rpx;
  83. background-color: transparent;
  84. }
  85. }
  86. </style>