import user from '$utils/control/user';
import {Shield, UserConfigType} from "$utils/control/user/const";

export default <LibMixins>{

    provide(){
      return {
          sendGiveUserGift:(item:Record<string, any>,uid:Array<string | number>,integral:number)=> this.sendGiveUserGift(item,uid,integral),
      }
    },

    methods:{

        // 入场
        addAdmission(item,isMy:boolean=true){

            if (isMy) {
                item = this.agoraRTMIM.addUserInfo({...item},true);
                item.message = item.zq_title || '进入房间';
                // 提示别人加入了房间
                this.sendJoinRoom(item.message);
            }

            item.star_play_img = item.star_play_img || item.vip_tx;

            // 检查权限是否屏蔽了进场特效
            if (!user.getDataItem(UserConfigType.shield,Shield.approach) && item.star_play_img) {
                // 添加入场动画
                this.$refs.admission && this.$refs.admission.pushQueue(item);
            }

        },

        // 赠送礼物
        sendGiveUserGift(item:Record<string, any>,uid:Array<string | number>,integral:number){

            // 执行增加魅力值
            if (integral) {
                uid.map((item)=>{
                    this.updateUserIntegral(item,integral);
                });
            }

            // 检查权限是否屏蔽了进场特效
            if (!user.getDataItem(UserConfigType.shield,Shield.gift) && item.play_image) {
                // 添加入场动画
                this.$refs.queueGift && this.$refs.queueGift.pushGift(item,uid);
            }
        }

    }

}
