
import extSdk from 'extSdk'
export default {
    data() {
        return {
            bIndex : 0,    //切换轮播索引
        }
    },

    
    mounted() {
        this.$store.dispatch('getPrimaryData')
        this.$store.dispatch('getNewGameData')   
        this.$store.dispatch('getKaData') 
        this.$store.dispatch('getSyData')                        
    },
    methods: {
        getClass(index) {
            let i = this.bIndex
            let thisIndex = i + index
            let len = this.bannerList.length
            if(thisIndex < 0 ){
                thisIndex += len
            }
            switch(thisIndex)
            {
                case 0:
                    return 'first'
                    break
                case 1:
                    return 'second'
                    break
                case len - 1 :
                    return 'last'
                    break
                default:
                    return ''
            }
        },
        bNext() {
            let len = this.bannerList.length            
            this.bIndex++
            if(this.bIndex > 0 ) {
                this.bIndex -= len 
            }
        },
        bPrev() {
            let len = this.bannerList.length               
            this.bIndex--
            if(this.bIndex + len - 1 < 0 ) {
                this.bIndex = 0
            }
        },

        bClick(href) {
            debugger
            if (window.HostApp) {
                extSdk.openUrl(href, '', true);
            } else {
                location.href = href
            }
        }
    },
    computed: {
        bannerList() {
            return this.$store.state.primaryData
        },
        newGameList() {
            return this.$store.state.newGameData
        },
        kaList() {
            return this.$store.state.kaData
        },
        syList() {
            return this.$store.state.syData
        }
    },
    watch: {

    },
}