import personalDetail, {OpenType} from '$utils/control/personal-detail';
import popup, {PopupExportComponent} from "$utils/tool/popup";

export default <LibMixins>{

    data(){
        return {
            banner:[
                {
                    image:''
                }
            ],
        }
    },

    methods:{

        fetchBanner(){
            return this.$request({
                url:'banner/get_banner_list',
                cache:true
            }).then((data)=>{
                this.banner = data.data || {};
            });
        },

        triggerOpenBanner(item){
            if (item.type === 2) {
                if (item.url) {
                    popup.$open(PopupExportComponent.image,{
                        src:item.url,
                        webview:true
                    });
                }
            } else if (item.aid) {
                if (item.type === 3) {
                    return personalDetail.openDetail({
                        rid: item.aid
                    },OpenType.room);
                }
                else if (item.type === 4) {
                    if (item.aid) {
                        return personalDetail.openDetail({
                            uid: item.aid,
                            pid: item.player_id
                        },OpenType.play);
                    }
                }
            }

        }

    },

    created(){
        this.fetchBanner();
    }

}
