import NewAxiosInstanceFunc from '../Service/NewAxiosInstance'
import { INewResponse } from '../Service/INewResponse'
import { IHomeChartListItem, IPaging } from 'Material/Material.service'
import {
  IActivitySpecialListItem,
  IActivityTypeListItem,
  IAudioDetail,
  IPermissionItem
} from 'Activity/Activity.service'
import { IAuthInfo, IBillBoardItem, IIndustyListItem } from 'Indepth/Indepth.service'
import { IProductInteriorItem } from 'Personal/Personal.service'
import { IColumnDetail } from 'Column/Column.service'
import { IRoadshowistItem } from 'Material/MicroRoadshow.service'
import axios from 'axios'

export interface INewestItem {
  ActivityId?: number
  AuthInfo: IAuthInfo
  Id: number
  SourceId: number //资源ID
  Source: string //资源类型 报告 ：article 、图表 ：newchart、微路演 ：roadshow、活动 ：activity、活动视频：activityvideo、活动音频：activityvoice、专项调研活动：activityspecial"
  Title: string //标题
  Annotation: string //核心观点
  PublishDate: string //发布时间
  Abstract: string //摘要
  IsTop: boolean //是否置顶
  IsCollection: boolean //是否收藏
  BackgroundImg: string //背景图
  City: string //城市
  IsSignup: number //是否已报名（感兴趣） 1是 ，0 否
  IsAppointment: number //是否已预约纪要 1是 ，0 否
  IsCancelMeetingReminder: number //是否添加了消息消息提醒   1是 ，0 否
  ActiveState: string //活动进行状态 未开始：1、进行中2、已结束3
  ImgUrl: string //行业图片链接
  ImgUrlText: string //活动类型图片链接
  ActivityType: number //活动线上线下类型 1线上，0 线下，2线下
  IsShowOutboundCall: boolean //是否展示预约外呼
  IsShowMeetingReminder: boolean //是否展示会议提醒
  IsShowHelpSsk: boolean //是否展示帮我带问
  IsShowSignup: boolean //是否展示我要报名
  IsShowAppointment: boolean //是否展示预约纪要
  IsShowDetails: boolean //是否展示查看详情按钮
  TripStatus: number //行程进行状态 1：预报名，2：确定行程
  IsTrip: number //确定行程是否报名 1是 ，0 否
  ActivityTimeText: string //活动预期时间带文字
  TripImgLink: string //行程图片链接
  Speaker: string //主讲人
  Expert: string //专家
  ActivityTime: string
  ResourceUrl: string // 音频地址
  YidongActivityUrl: string // 易懂活动链接
  AudioLink?: boolean //是否展示回放按钮
  VoiceDetail?: IAudioDetail //音频数据
  VideoDetail?: {
    ActivityId: number //活动ID
    Id: number //视频id
    Title: string //视频名称
    ResourceUrl: string //视频地址
    VideoDuration: number //视频时长
  } //视频数据
  IsResearch: boolean // 是否属于研选
  Pv: number
  BodyImg: string // 文章封面图片
  DistinguishedGuest: string // 嘉宾名称
  IsExternalLabel: boolean // 是否仅展示外部资源
  IsResearchPoints: boolean // 是否仅展示研选扣点
  LabelKeywordImgLink: string // 标签关键字图片链接
}
export interface INewestList {
  Activity: IActivityTypeListItem
  Activityspecial: IActivitySpecialListItem
  Activityvideo: IRoadshowistItem
  Activityvoice: IRoadshowistItem
  Article: IBillBoardItem
  Meetingreviewchapt: IMeetingreviewchaptItem
  Minutessummary: IResearchsummaryItem
  Newchart: IHomeChartListItem // 待定哦
  Researchsummary: IResearchsummaryItem
  Roadshow: IRoadshowistItem
  ProductInterior: IProductInteriorItem
  IndustrialResource: IIndustyListItem
  ReportSelection: IReportSelectionItem
  YanxuanSpecial: IYanxuanSpecialItem
  AskserieVideo: IRoadshowistItem
  Id: number
  PublishDate: string
  Source: string //资源类型 报告 ：article 、图表 ：newchart、微路演 ：roadshow、活动 ：activity、活动视频：activityvideo、活动音频：activityvoice、专项调研活动：activityspecial 本周研究汇总： researchsummary 、 上周纪要汇总 ：minutessummary 、晨会精华 ：meetingreviewchapt "
  SourceId: number //资源ID
  TitleHighlight: string // 标红的标题
}
export interface IYanxuanSpecialItem extends IColumnDetail {
  Annotation: string
  AuthorStatus: number
  BodyHighlight: string[] // 标红的内容
  LabelKeywordImgLink: string
}

export interface IYanxuanSpecialAuthorItem extends IColumnDetail {
  FansNum: number
  LatestPublishDate: string
  Annotation: string
  AuthorStatus: number
  BodyHighlight: string[] // 标红的内容
  LabelKeywordImgLink: string
  SpecialArticleNum: number
  CollectNum: number
  FollowNum: number
}

export interface IReportSelectionItem {
  Abstract: string
  ArticleId: number
  CreateTime: string
  Department: string
  IsRed: boolean
  MarketStrategy: string
  Periods: string
  PublishDate: string
  Pv: number
  ReadNum: number
  Title: string
  UpdateDescription: string
}
export interface IMeetingreviewchaptItem {
  ChartPermissionId: number
  ChartPermissionName: string
  Content: string
  Id: number
  IndustrialSubjectIds: string
  IndustryId: number
  IndustryName: string
  LinkArticleId: number
  ListSubject: IMeetingreviewListSubject[]
  MeetingId: number
  PublishTime: string
  ReportLink: string
  Title: string
}
export interface IMeetingreviewListSubject {
  CreateTime: string
  IndustrialManagementId: number
  IndustrialSubjectId: number
  Source: number
  SubjectName: string
}
export interface IResearchsummaryItem {
  Abstract: string
  ArticleId: number
  CreateTime: string
  Department: string
  IsRed: boolean
  MarketStrategy: string
  Periods: string
  PublishDate: string
  Pv: number
  ReadNum: number
  Title: string
  UpdateDescription: string
}
export interface IBannerListRes {
  ListA: IHomeBannerList[]
  ListB: IHomeBannerList[]
  ListC: IHomeBannerList[]
}
export interface IHomeBannerList {
  IndexImg: string //封面图
  Path: string //跳转地址
  Describe: string //描述
  DescribeColor: string //描述的颜色
  Title: string //标题
  TitleColor: string //标题的颜色
}
export interface ITagList {
  ActivityTypes: string // 活动类型
  ArticleTypes: string // 系列
  CheckList: string[] // 归属类型
  CreateTime: string
  Industries: string // 产业
  ModifyTime: string
  OfflineTime: string // 下线时间
  OnlineTime: string // 上线时间
  Sort: number // 排序
  Status: number // 1上线 0下线
  SubjectNames: string // 标的
  TagId: number // 标签id
  TagName: string // 标签
}
const CancelToken = axios.CancelToken
const source = CancelToken.source()

export const NewestService = {
  getBannerList: (): INewResponse<IBannerListRes> =>
    NewAxiosInstanceFunc({
      url: `/banner/listhome`,
      method: 'get'
    }),
  getCustomTagList: (): INewResponse<{ List1: string[]; List2: string[]; List3: string[] }> =>
    NewAxiosInstanceFunc({
      url: `/tag/list/label`,
      method: 'get'
    }),
  getNewestList: (params: {
    PageSize: number
    CurrentIndex: number
    HashtagKeyword?: string // 主题标签
    LabelKeyword?: string // 全部活动/全部报告
    KeyWord?: string // 搜索关键字
  }): INewResponse<{ List: INewestList[]; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/home/new`,
      method: 'get',
      params: params,
      cancelToken: source.token
    }),

  postBannerAddHistory: (BannerId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/banner/add/history`,
      method: 'post',
      data: { BannerId }
    }),
  postTagAddHistory: (TagId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/tag/add/history`,
      method: 'post',
      data: { TagId },
      cancelToken: source.token
    }),
  postMorningMeetingRecord: (Id: number, SourcePage: string): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/morning_meeting/history/add`,
      method: 'post',
      data: { Id, SourcePage } // 页面来源 微信、首页、展开
    })
}
