<template>
  <view class="container theme-container">
    <view class="top-title" v-if="!type">
      <view :class="['content-title', !contentDetail.IsJump && 'jump-title']" @click="jumpHandler">
        <text>{{ contentDetail.Label }}</text>
        <image v-if="contentDetail.IndustryNewLabel" class="new_icon" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/new_report.png" mode=""></image>
      </view>
    </view>
    <!-- 活动列表 -->
    <view>
      <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.ActivityTimeText }}
          </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.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>
              <block v-if="item.ActiveState == 1">
                <view :class="['bottom-box', item.ActivityTypeId == 1 && item.IsLimitPeople == 0 && '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">
                        <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>
            </view>
          </view>
        </view>
        <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20" v-if="totalPage > 1" />
      </view>
      <view class="select-box">
        <u-popup v-model="selectShow" mode="bottom">
          <view style="color: #333333; font-size: 28rpxrpx">请选择参会方式</view>
          <view style="color: #2c83ff" @click="signupIsAddOfCancel('', 1)">预约外呼</view>
          <view style="color: #2c83ff" @click="signupIsAddOfCancel('', 2)">自主拨入</view>
          <view style="color: #a9afb8" @click="selectShow = false">取消</view>
        </u-popup>
      </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"
      />
    </view>
    <areaCode :isAreaCode="isAreaCode" :areaCode="areaCode" />
    <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  </view>
</template>

<script>
import { activity, User } from "@/config/api.js";
import { Throttle } from "@/config/util.js";
import modalDialog from "@/components/modalDialog.vue";
import myMixin from "../components/index.js";
import myActivityMixin from "../components/indexActivity.js";
import areaCode from "@/activityPages/components/areaCode.vue";
import freeCharge from "@/components/freeCharge";
export default {
  mixins: [myMixin, myActivityMixin],
  data() {
    return {
      hasPermission: "", //是否有权限
      contentImg: "",
      contentLabel: "",
      contentDetail: {},
      label: "",
      type: "",
      permissionIds: "",
      whichDay: "",
    };
  },
  components: {
    areaCode,
    modalDialog,
    freeCharge,
  },
  methods: {
    async getActivityList() {
      const res = await activity.getActivityListNew({
        PageSize: this.pageSize,
        CurrentIndex: this.page_no,
        Label: this.type ? "" : this.label,
        ActiveState: 1,
        ActivityTypeId: this.type ? this.label : "",
        ChartPermissionIds: this.permissionIds,
        WhichDay: this.whichDay,
      });
      if (res.Ret === 200) {
        if (this.type) {
          uni.setNavigationBarTitle({
            title: this.type,
          });
        }
        this.contentImg = res.Data.ImgUrl;
        this.contentDetail = res.Data;
        this.status = this.page_no < res.Data.Paging.Pages ? "loadmore" : "nomore";
        if (this.page_no === 1) {
          this.collectList = res.Data.List || [];
          if (this.refresh) {
            uni.stopPullDownRefresh();
            this.refresh = false;
          }
        } else {
          this.collectList = this.collectList.concat(res.Data.List);
        }
      }
    },
    //获取是否需要填写区号接口
    countryCcode() {
      User.countryCcode().then((res) => {
        if (res.Ret == 200) {
          this.isNeedAddCountryCode = res.Data.IsNeedAddCountryCode;
        }
      });
    },
    jumpHandler() {
      if (this.contentDetail.IsJump) {
        if (this.contentDetail.IsResearch) {
          //严选
          this.$store.dispatch("checkHandle", "/reportPages/researchTheme/researchTheme?id=" + this.contentDetail.IndustrialManagementId);
        } else {
          //非严选
          this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + this.contentDetail.IndustrialManagementId);
        }
      }
    },
  },
  onLoad(option) {
    this.label = option.title;
    this.type = option.type;
    this.permissionIds = option.permissionIds || "";
    this.whichDay = option.whichDay || "";
    this.getActivityList();
    this.countryCcode();
  },
  onShow() {
    this.$store.dispatch("checkHandle");
  },
  /* 触底 */
  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();
  }),
  /** 用户点击分享 */
  onShareAppMessage: function (res) {
    return {
      title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : this.type || this.label,
      path: "/activityPages/themeActivity/themeActivity?title=" + this.label + "&permissionIds=" + this.permissionIds + "&whichDay=" + this.whichDay + "&type=" + this.type,
    };
  },
};
</script>

<style lang="scss" scoped>
.theme-container {
  background: #f7f7f7;
  padding-bottom: 30rpx;

  position: relative;
  .top-title {
    position: sticky;
    top: 0;
    z-index: 99;
    background-color: #fff;
    display: flex;
    align-items: center;
    color: #3385ff;
    font-size: 30rpx;
    padding: 30rpx 30rpx 20rpx;
    .content-title {
      display: flex;
      align-items: center;
      padding: 7rpx 12rpx;
      background-color: #f8f8fa;
      .new_icon {
        width: 60rpx;
        height: 30rpx;
        margin-left: 10rpx;
      }
    }
    .jump-title {
      color: #999;
    }
  }
  .collect-ul {
    padding-top: 10rpx;
  }
}
@import "../components/indexActivity.scss";
</style>