<template>
  <view class="container activity-content">

    <view class="collect-ul" v-if="haveData">
      <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.ActivityTimeText }}
        </view>
        <view class="item-li">
          <view class="item-img" @click="goDetail(item)">
            <image :src="item.ImgUrl">
            <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.ActivityTypeName == '专家电话会' || item.ActivityTypeName == '专家线下沙龙' || item.ActivityTypeName == '研选电话会'">专家背景：{{ item.Expert }} </text>
              <text class="text_twoLine" v-if="item.ActivityTypeName == '公司调研电话会' || item.ActivityTypeName == '公司线下调研'">嘉宾：{{ item.DistinguishedGuest }} </text>
              <text class="text_twoLine" v-if="item.ActivityTypeName == '分析师电话会' || item.ActivityTypeName == '分析师线下沙龙'">主讲人：{{ item.Speaker }}</text>
            </view>
            <block v-if="item.ActiveState == 1">
              <view class="bottom-box city" v-if="item.ActiveState == 1 && item.IsLimitPeople == 1 && item.ActivityTypeName == '公司调研电话会'">
                <view class="city-img">
                  <image v-if="item.City" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/location.png" />
                  {{ item.City }}
                </view>
                <text class="button" v-if="item.IsSignup !== 1" @click="wanttosignup(item.ActivityId)">我要报名</text>
                <text class="button" v-else @click="signupCancel(item.ActivityId, 2, item.ActivityTime)">{{ item.SignupType == 1 ? "取消外呼" : "取消报名" }}</text>
              </view>
              <view class="bottom-box" v-else-if="item.ActivityType == 1">
                <view class="" style="width: 130rpx">
                  <text v-if="item.ActivityTypeId == 1" @click="askingGo(item)">帮我带问</text>
                </view>
                <text @click="meetingReminderAdd(item.ActivityId)" v-if="item.IsCancelMeetingReminder == 0">会议提醒</text>
                <text @click="meetingReminderCancel(item.ActivityId)" v-else>取消提醒</text>
                <text class="button" v-if="item.IsSignup !== 1" @click="signupAdd(item.ActivityId, 1)">预约外呼</text>
                <text class="button" @click="signupCancel(item.ActivityId, 1, item.ActivityTime)" v-else>取消外呼</text>
              </view>
              <view class="bottom-box city" v-else>
                <view class="city-img">
                  <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/location.png" />
                  {{ item.City }}
                </view>
                <text class="button" v-if="item.IsSignup !== 1" @click="signupAdd(item.ActivityId, 3)">我要报名</text>
                <text class="button" v-else @click="signupCancel(item.ActivityId, 3, item.ActivityTime)">取消报名</text>
              </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" />
                  {{ 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>
          </view>
        </view>
      </view>
      <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20" v-if="totalPage > 1" />
    </view>
    <view class="nodata" v-if="!haveData">
      <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/act_search.png" mode="" class="nodata_ico"></image>
      <text>{{ tabsActive == 0 ? "暂时没有符合条件的活动" : "暂无我的日程" }}</text>
    </view>
      <!-- 所有自定义弹框 -->
      <modalDialog
        :isShow="isShow"
        :signupType="signupType"
        :goFollow="goFollow"
        :signupStatus="signupStatus"
        :hasPermission="hasPermission"
        :jurisdictionList="jurisdictionList"
        :editIsShow="editIsShow"
        :isCancelShow="isCancelShow"
        :idTypeCancel="idTypeCancel"
        @cancelShowBtn="cancelEnsure"
        :countryCode="countryCode"
        :mobileEdit="mobileEdit"
        :goOnNextStep="goOnNextStep"
        :isShowhasPermission="isShowhasPermission"
        :applyForIsShow="applyForIsShow"
        :mailboxBinding="mailboxBinding"
      />
   <freeCharge class="free-charge" :isShowFreeBtn="isShowFree"/>
  </view>
</template>

<script>
import { activity } from "@/config/api.js";
import { Throttle } from "@/config/util.js";
import myActivityMixin from "@/activityPages/components/indexActivity.js";
import modalDialog from "@/components/modalDialog.vue";
import freeCharge from '@/components/freeCharge'
let app = getApp();
export default {
  mixins: [myActivityMixin],
  components: {
    modalDialog, freeCharge
  },
  data() {
    return {
      collectTypeList: [],
      haveData: true,
      whichDay: "",
      listChartPermission: [],
      listChartPermissionInit: [],
      chartPermissionIds: "",
      isShowJurisdiction: false, //
      isGetJurisdiction: 0,
      isrefresh: true,
      activityTypeId: '',
    };
  },
  methods: {
    //
    async getActivityList() {
      const res = await activity.getScheduleList({ PageSize: this.pageSize, CurrentIndex: this.page_no });
      if (res.Ret === 200) {
        this.contentImg = res.Data.ImgUrl;
        this.contentLabel = res.Data.Label;
        this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
        if (this.page_no === 1) {
          this.collectList = res.Data.List || [];
          this.haveData = this.collectList.length ? true : false;
          if (this.refresh) {
            uni.stopPullDownRefresh();
            this.refresh = false;
          }
        } else {
          this.collectList = this.collectList.concat(res.Data.List);
        }
      }
    },
  },
  //load
  onLoad(option) {
   this.getActivityList();
  },
  async onShow() {
    await this.$store.dispatch("checkHandle", "noGO");
  },
  /* 触底 */
  onReachBottom: Throttle(function () {
    if (this.status === "nomore") return;
    this.status = "loading";
    this.page_no++;
     this.getActivityList();
  }),
  /* 下拉刷新 */
  onPullDownRefresh: Throttle(function () {
    this.page_no = 1;
    this.refresh = true;
    this.getActivityList();
  }),
 
};
</script>

<style scoped lang="scss">
.activity-content {
  background-color: #f7f7f7;
  padding-bottom: 90rpx;
  position: relative;
  padding-top: 20rpx;
  .nodata_ico {
    width: 374rpx;
    height: 288rpx;
  }
}
@import "@/activityPages/components/indexActivity.scss";
</style>
