import {
    getBannerList
} from '~/api/global'
Component({
    properties: {
        classify: {
            type: Number,
            value: 1
        }
    },
    data: {
        bannerList: []
    },
    lifetimes: {
        attached() {
            this.getBannerList()
        },
    },
    /**
     * 组件的方法列表
     */
    methods: {
        async getBannerList() {
            let bannerList = await getBannerList(this.properties.classify)
            this.setData({
                bannerList
            })
        },
        bannelEvent({
            currentTarget
        }) {
            //1:图片,2:邀新榜,3:热播榜,4:挑战pk榜,5,朗读赛,6,领取勋章
            let {
                type,
                id
            } = currentTarget.dataset
            if ([2, 3, 4].includes(type)) {
                wx.navigateTo({
                    url: `/pages/ranking/index?id=${id}&type=${type}`,
                })
            }
            if (type == 5) {
                wx.navigateTo({
                    url: '/pages/match/index',
                })
            }
        },
    }
})