app-scroll.vue 3.0 KB

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