<template>
    <!-- 快捷运营 -->
    <view class="quick-oprea">
        <swiper class="swiper" :autoplay="false" @change="swiperChange" :circular="true">
            <swiper-item v-for="(item, index) in footList" :key="index" class="swiper-item">
                <view class="content" v-for="(i, o) in item" :key="i" @click="NavToDetailPage(i)">
                    <view class="list">
                        <div class="list-icon">
                            <image :src="i.icon" style="width: 100%;height: 100%;" mode=""></image>
                        </div>
                        <div class="list-title">
                            <div class="title-1">
                                <div class="title-1-item">
                                    <view style="display: inline-block;">{{ i.name }}</view>
                                    <text class="title-2-item">GO></text>
                                </div>
                            </div>
                            <div class="title-2">{{i.remark || ''}}</div>
                        </div>
                    </view>
                </view>
            </swiper-item>
        </swiper>
        <view class="swiper__dots-box">
            <view
                v-for="(item, idx) in footList"
                :key="idx"
                :class="[idx === current ? 'swiper__dots-long' : 'none']"
                :data-index="current"
                class="swiper__dots-item"
            ></view>
        </view>
    </view>
</template>

<script>
import cmsMixins from '@/mixins/cmsMixins.js'
import { mapState } from 'vuex'
export default {
    mixins: [cmsMixins],
    props: {
        list: {
            type: Array,
            default: () => []
        }
    },
    data() {
        return {
            current: 0 // 切换轮播
        }
    },
    computed: {
        ...mapState(['hasLogin']),
        // 快捷运营列表
        footList() {
            let newArr = [],
                a = []
            this.list.map((item, index) => {
                if (index !== 0 && index % 4 === 0) {
                    newArr.push(a)
                    a = []
                    a.push(item)
                } else a.push(item)
                if (this.list.length === index + 1) {
                    newArr.push(a)
                }
            })
            return newArr
        }
    },
    watch: {},
    mounted() {},
    methods: {
        // 链接跳转
        NavToDetailPage(pros) {
			this.$api.FlooryNavigateTo(pros)
        },
        swiperChange(e) {
            //轮播图切换
            this.current = e.detail.current
        }
    }
}
</script>

<style lang="scss" scoped>
.quick-oprea {
    background-color: #f7f7f7;
    padding: 20rpx;
    position: relative;
    height: 400rpx;
    .swiper__dots-box {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 32rpx;
        display: flex;
        flex: 1;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        .swiper__dots-item {
            width: 14rpx;
            height: 5rpx;
            border-radius: 100%;
            margin-left: 6px;
            background-color: #e15621;
            opacity: 0.2;
        }
        .swiper__dots-long {
            width: 26rpx;
            height: 5rpx;
            border-radius: 4rpx;
            background-color: #e15621;
            transition: all 0.4s;
            opacity: 1;
        }
    }
}
.swiper {
    height: 340rpx;
    .swiper-item {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
        grid-gap: 18rpx;
        .content {
            box-sizing: border-box;
            border-radius: 16rpx;
            background-color: #fff;
            display: flex;
            align-items: center;
            background: linear-gradient(180deg, #FFF1EB 0%, #FFFFFF 100%);
            .list {
                width: 100%;
                display: flex;
                height: 80rpx;
                .list-icon {
                    width: 80rpx;
                    height: 100%;
                    border-radius: 50%;
                    margin-left: 24rpx;
                    overflow: hidden;
                }
                .list-title {
                    margin-left: 16rpx;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-between;
                    .title-1 {
                        .title-1-item {
                            color: #333333;
                            font-size: 28rpx;
                            width: 222rpx;
                            display: flex;
                            align-items: center;
                            .title-2-item {
                                width: 62rpx;
                                height: 32rpx;
                                background: #ff5b00;
                                border-radius: 14rpx;
                                font-size: 22rpx;
                                text-align: center;
                                height: 32rpx;
                                color: white;
                                margin-left: 6rpx;
                            }
                        }
                    }
                    .title-2 {
                        color: #999999;
                        font-size: 22rpx;
                    }
                }
            }
        }
    }
}
</style>
