<template>
  <view class="activity-content activity-search-content">
    <!-- 活动列表 -->
    <view :class="['activity-pages', tabsActiveSearch == 4 && 'content-padding']">
      <view class="collect-ul">
        <view class="collect-ltem" v-for="(item, index) in collectList" :key="index">
          <view class="title-date" @click="goDetail(item)">
            <text :class="item.ActivityType == 1 ? '' : 'xianxia'">{{ item.ActivityType == 1 ? "线上" : "线下" }}</text>
            {{ item.SourceType == 2 ? "" : item.ActivityTimeText }}
            <view class="audio-back" v-if="item.AudioLink" @click.stop="PlayBackAll(item)">
              <block v-if="item.FileType == 2">
                <image class="audio-img" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/video_play.png"></image>
              </block>
              <image
                v-else
                class="audio-img"
                :src="
                  curVoiceId === item.ActivityId && !curAudioPaused
                    ? 'https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/stop_play.png'
                    : 'https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/audio_play.png'
                "
              ></image>
              {{ curVoiceId === item.ActivityId && !curAudioPaused ? "暂停" : "回放" }}
            </view>
          </view>
          <view class="item-li">
            <view class="item-img" @click="goDetail(item)">
              <image :src="item.ImgUrl"></image>
              <text v-if="item.ActiveState == 1" class="img-status begin">未开始</text>
              <text v-else-if="item.ActiveState == 2" class="img-status proceed">进行中</text>
              <text v-else class="img-status">已结束</text>
              <view class="img-type">
                <image :src="item.ImgUrlText" mode=""></image>
              </view>
            </view>
            <view class="item">
              <view class="item-text" @click="goDetail(item)">
                <text class="activity-title"> {{ item.ActivityName }} </text>
                <text class="text_twoLine" v-if="item.Expert && item.SourceType == 1">专家背景:{{ item.Expert }} </text>
                <text class="text_twoLine" v-if="item.DistinguishedGuest">嘉宾:{{ item.DistinguishedGuest }} </text>
                <text class="text_twoLine" v-if="item.Speaker">主讲人:{{ item.Speaker }}</text>
                <view style="display: flex" class="text_twoLine" v-if="item.ActivityTimeText && item.SourceType == 2">
                  <text style="flex-shrink: 0"> 活动时间:</text>
                  <text> {{ item.ActivityTimeText }}</text>
                </view>
              </view>
              <block v-if="item.SourceType == 1">
                <block v-if="item.ActiveState == 1">
                  <view :class="['bottom-box', isEndBtn(item) > 3 && 'expert-item', item.City && 'city']">
                    <view class="city-img" v-if="item.City">
                      <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/location.png"></image>
                      {{ item.City }}
                    </view>
                    <view style="display: flex">
                      <text v-if="item.IsShowOutboundCall && item.ActivityTypeId == 1" class="button" @click="signupIsAddOfCancel(item, 1)">{{ item.IsSignup == 1 ? "取消外呼" : "预约外呼" }}</text>
                      <text v-if="item.IsShowAppointment" @click="summaryIsHandel(item)">{{ item.IsAppointment == 1 ? "取消纪要" : "预约纪要" }}</text>
                      <text v-if="item.IsShowMeetingReminder" @click="meetingReminderAdd(item.ActivityId, item.IsCancelMeetingReminder)">
                        {{ item.IsCancelMeetingReminder == 0 ? "消息提醒" : "取消提醒" }}
                      </text>
                      <view v-if="item.IsShowHelpSsk" style="width: 130rpx">
                        <text @click="askingGo(item)">帮我带问</text>
                      </view>
                      <text v-if="item.IsShowOutboundCall && item.ActivityTypeId != 1" class="button" @click="signupIsAddOfCancel(item, 1)">{{ item.IsSignup == 1 ? "取消外呼" : "预约外呼" }}</text>
                      <text v-if="item.IsShowDetails" @click="goDetail(item)" class="button">查看详情</text>
                      <block v-if="item.IsShowSignup">
                        <block v-if="item.IsCClassMeeting && !item.IsYidongConduct">
                          <text class="button" @click="signupIsAddOfCancel(item, 3, 'CClass')">{{ item.IsSignup == 1 ? "取消报名" : "我要报名" }}</text>
                        </block>
                        <block v-else>
                          <text class="button" v-if="item.IsSignup !== 1" @click="wanttosignup(item)">我要报名</text>
                          <text class="button" v-else @click="signupIsAddOfCancel(item, 2)">{{ item.SignupType == 1 ? "取消外呼" : "取消报名" }}</text>
                        </block>
                      </block>
                    </view>
                  </view>
                </block>
                <block v-else>
                  <view class="bottom-box city" v-if="item.City">
                    <view class="city-img">
                      <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/location.png"></image>
                      {{ item.City }}
                    </view>
                  </view>
                  <view class="bottom-box real-time" v-if="item.ActiveState == 2 && item.ActivityTypeId == 1">
                    <text class="button" @click="askingGo(item, '提问')">实时提问</text>
                  </view>
                </block>
              </block>
              <block v-if="item.SourceType == 2">
                <view class="bottom-box">
                  <view class="" style="width: 130rpx"> </view>
                  <text @click="lookImg(item)">行程安排</text>
                  <text v-if="item.ActiveState == 1" class="button" @click="applyOfcancel(item, 'back')">{{ item.IsSignup == 0 ? "我要报名" : "取消报名" }}</text>
                </view>
              </block>
            </view>
          </view>
          <view class="reminder-item" v-if="item.SourceType == 2">
            <image class="item" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/confirm_XC.png"></image>
          </view>
        </view>
      </view>
    </view>
    <!-- 各种自定义弹框 -->
    <modalDialog
      :isShow="isShow"
      :signupType="signupType"
      :goFollow="goFollow"
      :hasPermission="hasPermission"
      :jurisdictionList="jurisdictionList"
      :editIsShow="editIsShow"
      :isCancelShow="isCancelShow"
      :idTypeCancel="idTypeCancel"
      :countryCode="countryCode"
      :mobileEdit="mobileEdit"
      :goOnNextStep="goOnNextStep"
      :isShowhasPermission="isShowhasPermission"
      :applyForIsShow="applyForIsShow"
      :mailboxBinding="mailboxBinding"
    />
    <!-- 参会方式弹出层 -->
    <SelectPopup :selectShow.sync="selectShow" @signupIsAddOfCancel="signupIsAddOfCancel" :selectYdong="selectYdong" />
    <view v-if="showAudioBox">
      <audioModule :showAudioPop.sync="showAudioPop" />
    </view>
    <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
    <videoModule :showVideoPop.sync="showVideoPop" :videoPopList="videoPopList" />
    <u-modal
      v-model="specialGoFollowShow"
      :content-style="{ fontSize: '32rpx' }"
      :show-cancel-button="show_cancel_button"
      confirm-text="知道了"
      @cancel="isCancelBtn = false"
      :show-confirm-button="show_confirm_button"
      :show-title="false"
      :cancel-style="{ borderRight: '1rpx solid #EBEBEB' }"
      :confirm-style="{ fontWeight: '700' }"
      :mask-close-able="specialIsHintShow"
    >
      <view class="slot-content">
        <block v-if="specialPopupMsg">
          <text>{{ specialAccounts }}</text>
          <text class="light-hint">{{ specialPopupMsg }}</text>
        </block>
        <rich-text v-else :nodes="specialAccounts"></rich-text>
      </view>
    </u-modal>
    <ShowResearchDlg :isResearchModalShow.sync="isResearchModalShow" :jurisdictionList="jurisdictionList" :checkResearchList.sync="checkResearchList" />
  </view>
</template>

<script>
import modalDialog from "@/components/modalDialog.vue";
import specialMixins from "@/activityPages/components/specialMixins.js";
import myActivityMixin from "@/components/activity/indexActivity.js";
import mediaMixins from "@/components/activity/mediaMixins";
import freeCharge from "@/components/freeCharge";
import audioModule from "@/components/audioModule/index";
import videoModule from "@/components/videoModule/index";
import { activity } from "@/config/api";
import SelectPopup from "@/components/activity/selectPopup";
import ShowResearchDlg from "@/components/activity/showResearchDlg.vue";

export default {
  props: {
    collectLists: {
      type: Array,
      default: [],
    },
    tabsActiveSearch: {
      type: Number,
    },
  },
  data() {
    return {
      isShowSearch: false,
      status: "loadmore",
      totalPage: "",
      haveData: true,
      activeState: 0, //活动进行状态
      activeStateOption: [
        {
          name: "全部",
          state: 0,
        },
        {
          name: "可回放",
          state: 1,
        },
      ],
    };
  },
  mixins: [myActivityMixin, mediaMixins, specialMixins],
  components: {
    modalDialog,
    freeCharge,
    audioModule,
    videoModule,
    SelectPopup,
    ShowResearchDlg,
  },
  watch: {
    collectLists: {
      handler(newVal) {
        this.collectList = newVal;
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    //查看行程的事件
    lookImg(item) {
      this.getRecordTracking(this.$store.state.pageRouterActivity, { ActivityId: item.ActivityId, Source: "查看行程" });
      uni.previewImage({
        urls: [item.TripImgLink], //查看图片的数组
      });
    },
    // 判断几个按钮
    isEndBtn(item) {
      let isKeys = ["IsShowOutboundCall", "IsShowAppointment", "IsShowMeetingReminder", "IsShowHelpSsk", "IsShowDetails", "IsShowSignup"];
      let arr = [];
      Object.keys(item).forEach((key) => {
        if (isKeys.includes(key)) {
          item[key] && arr.push(item[key]);
        }
      });
      return arr.length;
    },
  },
};
</script>

<style scoped lang="scss">
.activity-pages {
  padding-bottom: 30rpx;
}
@import "@/components/activity/indexActivity.scss";
.activity-search-content {
  background-color: #f7f7f7;
  .ipt-right {
    z-index: 11;
  }
  .collect-ltem {
    margin-top: 0 !important;
    margin-bottom: 20rpx !important;
  }
  .select-conyent {
    display: flex;
    float: right;
    margin-bottom: 20rpx;
    height: 51rpx;
    width: 252rpx;
    border-radius: 47rpx;
    overflow: hidden;
    margin-right: 30rpx;
    .state-item {
      width: 126rpx;
      height: 51rpx;
      text-align: center;
      line-height: 51rpx;
      color: #999999;
      font-size: 24rpx;
      background-color: #f8f8fa;
    }
    .state-active-item {
      background: #3385ff;
      color: #fff;
      border-radius: 47rpx;
    }
  }
  .title-date {
    position: relative;
    .audio-back {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      width: 99rpx;
      height: 39rpx;
      font-size: 24rpx;
      color: #fff;
      display: flex;
      align-items: center;
      background-color: #3385ff;
      border-radius: 20rpx;
      padding-left: 4rpx;
      .audio-img {
        width: 30rpx;
        height: 30rpx;
        margin: 0 5rpx;
      }
    }
  }
  .top-content {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99;
    background-color: #fff;
    .searchTarget-header {
      position: relative;
      width: 100%;
      background-color: #fff;
      padding: 20rpx 0;
      display: flex;
      justify-content: center;
      align-items: center;
      .sea_ipt_placeholder {
        color: #8d8d8d;
      }
      .sea_ipt {
        width: 682rpx;
        height: 70rpx;
        line-height: 70rpx;
        box-sizing: border-box;
        background: #f9f9f9;
        font-size: 26rpx;
        color: #4a4a4a;
        padding: 0 180rpx 0 78rpx;
        border-radius: 70rpx;
      }
      .sea_ico {
        width: 31rpx;
        height: 31rpx;
        position: absolute;
        left: 60rpx;
        top: 50%;
        transform: translateY(-50%);
      }
      .ipt-right {
        display: flex;
        align-items: center;
        position: absolute;
        right: 59rpx;
        top: 50%;
        transform: translateY(-50%);
        color: #3385ff;
        .line {
          margin: 0 21rpx;
          color: #e0e0e0;
        }
      }
    }
    .search-cont {
      height: calc(100vh - 200rpx);
      padding-bottom: 20rpx;
      overflow: hidden;
      overflow-y: auto;
      background-color: #f7f7f7;
      .search-cont-top {
        padding: 0 34rpx 0;
        margin-bottom: 10rpx;
        padding-top: 20rpx;
        &:last-child {
          margin-bottom: 0;
        }
        .cont-tit {
          font-size: 32rpx;
          margin-bottom: 20rpx;
          font-weight: 500;
          display: flex;
          justify-content: space-between;
          .empty_ico {
            width: 32rpx;
            height: 33rpx;
          }
        }
        .targetList {
          display: flex;
          flex-wrap: wrap;
          font-size: 28rpx;
          .target-item {
            width: 50%;
            margin-bottom: 20rpx;
          }
          .chart-item {
            width: 100%;
            margin-bottom: 20rpx;
          }
        }
      }
    }
  }
}
.content-padding {
  padding-top: 90rpx !important;
}
</style>