123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <template>
- <scroll-view scroll-x class="app-scroll" :scroll-into-view="`${scrollId}`" scroll-with-animation>
- <view class="app-content">
- <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' : '']">
- <app-form-id @click="active(item, index)">
- <view class="app-ad dir-top-nowrap main-center cross-center" v-if="item.type !== 2">
- <view class="app-time" :class="{'active-color': activeIndex === index}">{{item.new_open_time}}</view>
- <view class="app-label" :class="{'active-color': activeIndex === index}">{{item.label}}</view>
- <view class="app-icon" :class="[activeIndex === index ? theme + '-m-border-m ' + theme : '']"></view>
- </view>
- <view class="app-ad" v-else>
- <text :class="{'active-color': activeIndex === index}">{{item.label}}</text>
- <view :class="[activeIndex === index ? theme + '-m-border-m ' + theme : '']" class="app-icon"></view>
- </view>
- </app-form-id>
- </view>
- </view>
- </scroll-view>
- </template>
- <script>
- export default {
- name: "app-scroll",
- props: {
- timeList: Array,
- theme: {
- type: String,
- default: 'a'
- }
- },
- data() {
- return {
- scrollId: '',
- activeIndex: 0,
- }
- },
- methods: {
- active(item, index) {
- this.activeIndex = index;
- let i = index - 2;
- this.scrollId = `ms_${i}`;
- this.$emit('click', index, item);
- }
- },
- watch: {
- timeList: {
- handler: function(value) {
- value.map((item, index) => {
- if (item.status === 1) {
- this.scrollId = `ms_${index-2}`;
- this.activeIndex = index;
- }
- });
- },
- immediate: true,
- }
- }
- }
- </script>
- <style lang="scss">
- .app-item {
- display: inline-block;
- width: #{150rpx};
- height: #{96rpx};
- background-color: #30353c;
- position: relative;
- .app-ad {
- width: #{150rpx};
- height: #{96rpx};
- }
- .app-d {
- font-size: #{32rpx};
- }
- view {
- color: #bbbbbb;
- text-align: center;
- }
- .app-time {
- width: #{150rpx};
- font-size: #{32rpx};
- }
- .app-label {
- width: #{150rpx};
- font-size: #{22rpx};
- }
- }
- .app-active-item {
- color: white !important;
- .app-icon {
- border: #{20rpx} solid ;
- position: absolute;
- bottom: #{-36rpx};
- left: 50%;
- transform: translateX(-50%);
- }
- .active-color {
- color: white !important;
- }
- }
- .app-scroll {
- white-space: nowrap;
- width: #{750rpx};
- height: #{120rpx};
- .app-content {
- width: #{750rpx};
- height: #{96rpx};
- /*white-space: nowrap;*/
- display: flex;
- z-index: 1601;
- background-color: #30353c;
- -webkit-flex-direction: row;
- flex-direction: row;
- .app-top {
- line-height: #{96rpx};
- }
- }
- }
- </style>
|