import { activity, User } from "@/config/api.js";
export default {
  data() {
    return {
      showAudioPop: false,
      showVideoPop: false,
      videoPopList: {},
    };
  },
  computed: {
    curVoiceId() {
      //当前正在播放的音频id
      return this.$store.state.audioBg.activityId;
    },
    curAudioPaused() {
      //当前音频是否暂停状态
      return this.$store.state.audioBg.paused;
    },
    showAudioBox() {
      return this.$store.state.audioBg.parseIntShow;
    },
    // 播放列表数据
    playlistData() {
      return this.$store.state.audioJoinPlaylist.playlist;
    },
  },
  methods: {
    //点击了回放
    async PlayBackAll(item) {
      if (!item.BackAudioPlay) {
        const res = await activity.getActivityDetail({
          ActivityId: item.ActivityId,
        });
        if (res.Ret === 200) {
          item.BackAudioPlay = res.Data;
        }
      }
      this.hasPermission = item.BackAudioPlay.HasPermission;
      this.jurisdictionList.ActivityId = item.ActivityId;
      if (this.hasPermission == 1) {
        item.FileType == 2 ? this.handelVideoPlay(item) : this.audioPlayBack(item);
      } else if (this.hasPermission == 2) {
        this.jurisdictionList.SellerMobile = item.BackAudioPlay.SellerMobile;
        this.jurisdictionList.SellerName = item.BackAudioPlay.SellerName;
        this.jurisdictionList.PopupMsg = item.BackAudioPlay.PopupMsg;
        this.isShowhasPermission = true;
      } else if (this.hasPermission == 3 || this.hasPermission == 4 || this.hasPermission == 5) {
        this.jurisdictionList.PopupMsg = item.BackAudioPlay.PopupMsg;
        this.applyForIsShow = true;
      }
    },
    //视频的播放事件
    handelVideoPlay(item) {
      if (this.$store.state.videoPlay.playVideoActId != item.VideoDetail.ActivityId) {
        this.$store.commit("videoPlay/palyTimeUpdate", 0);
        this.$store.commit("videoPlay/playVideoActivity", item.VideoDetail.ActivityId);
      }
      this.globalBgAudioManager.stop();
      this.videoPopList = item.VideoDetail;
      this.showVideoPop = true;
    },
    //音频的播放事件
    audioPlayBack(item) {
      this.$store.commit("audioBg/parseIntAudio", true);
      // 判断是否为同一个音频
      if (this.$store.state.audioBg.indexId == item.ActivityId) {
        if (this.globalBgAudioManager.paused) {
          this.globalBgAudioManager.play();
        } else {
          this.globalBgAudioManager.pause();
        }
      } else {
        this.$store.commit("audioBg/addAudio", { list: item.VoiceList, indexId: item.ActivityId, activityId: item.ActivityId, activityTitle: item.VoiceList.Name, recordList: item });
      }
      this.showAudioPop = true;
    },
  },
};