app-scroll.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <scroll-view scroll-x class="app-scroll" :scroll-into-view="`${scrollId}`" scroll-with-animation>
  3. <view class="app-content">
  4. <view class="app-item" v-for="(item, index) in timeList" :id="`ms_${index}`" :key="index" :class="[activeIndex === index ? 'app-active-item' : '', item.type === 2 ? 'app-top' : '']" :style="{'background-color': activeIndex === index ? theme.background : ''}">
  5. <app-form-id @click="active(item, index)">
  6. <view class="app-ad dir-top-nowrap main-center cross-center" v-if="item.type !== 2">
  7. <view class="app-time" :class="{'active-color': activeIndex === index}">{{item.new_open_time}}</view>
  8. <view class="app-label" :class="{'active-color': activeIndex === index}">{{item.label}}</view>
  9. <view class="app-icon" :style="{'border-color': activeIndex === index ? theme.border : ''}"></view>
  10. </view>
  11. <view class="app-ad" v-else>
  12. <text :class="{'active-color': activeIndex === index}">{{item.label}}</text>
  13. <view :style="{'border-color': activeIndex === index ? theme.border : ''}" class="app-icon"></view>
  14. </view>
  15. </app-form-id>
  16. </view>
  17. </view>
  18. </scroll-view>
  19. </template>
  20. <script>
  21. export default {
  22. name: "app-scroll",
  23. props: {
  24. timeList: Array,
  25. theme: {
  26. type: Object,
  27. }
  28. },
  29. data() {
  30. return {
  31. scrollId: '',
  32. activeIndex: 0,
  33. }
  34. },
  35. methods: {
  36. active(item, index) {
  37. this.activeIndex = index;
  38. let i = index - 2;
  39. this.scrollId = `ms_${i}`;
  40. this.$emit('click', index, item);
  41. }
  42. },
  43. watch: {
  44. timeList: {
  45. handler: function(value) {
  46. value.map((item, index) => {
  47. if (item.status === 1) {
  48. this.scrollId = `ms_${index-2}`;
  49. this.activeIndex = index;
  50. }
  51. });
  52. },
  53. immediate: true,
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. .app-item {
  60. display: inline-block;
  61. width: #{150rpx};
  62. height: #{96rpx};
  63. background-color: #30353c;
  64. position: relative;
  65. .app-ad {
  66. width: #{150rpx};
  67. height: #{96rpx};
  68. }
  69. .app-d {
  70. font-size: #{32rpx};
  71. }
  72. view {
  73. color: #bbbbbb;
  74. text-align: center;
  75. }
  76. .app-time {
  77. width: #{150rpx};
  78. font-size: #{32rpx};
  79. }
  80. .app-label {
  81. width: #{150rpx};
  82. font-size: #{22rpx};
  83. }
  84. }
  85. .app-active-item {
  86. color: white !important;
  87. .app-icon {
  88. border: #{20rpx} solid ;
  89. position: absolute;
  90. bottom: #{-36rpx};
  91. left: 50%;
  92. transform: translateX(-50%);
  93. }
  94. .active-color {
  95. color: white !important;
  96. }
  97. }
  98. .app-scroll {
  99. white-space: nowrap;
  100. width: #{750rpx};
  101. height: #{120rpx};
  102. .app-content {
  103. width: #{750rpx};
  104. height: #{96rpx};
  105. /*white-space: nowrap;*/
  106. display: flex;
  107. z-index: 1601;
  108. background-color: #30353c;
  109. -webkit-flex-direction: row;
  110. flex-direction: row;
  111. .app-top {
  112. line-height: #{96rpx};
  113. }
  114. }
  115. }
  116. </style>