import NewAxiosInstanceFunc from '../Service/NewAxiosInstance'
import { INewResponse } from '../Service/INewResponse'
import { IGoodsListItem, IPaging } from 'Material/Material.service'

export interface IColumnAuthorList {
  BgImg: string
  CollectNum: number
  CompanyName: string
  CreateTime: string
  FollowNum: number
  HeadImg: string
  Id: number
  Introduction: string
  IsFollow: number
  Label: string
  LatestPublishDate: string
  LatestPublishTime: string
  Mobile: string
  ModifyTime: string
  NickName: string
  RealName: string
  SpecialArticleNum: number
  SpecialName: string
  Status: number // 1收藏2取消收藏
  UserId: number
}
export interface IUploadFileRes {
  Id: number
  PlaySeconds?: number
  ResourceUrl: string
  ResourceName?: string // 文件名
}

export interface IDocsList {
  DocName: string
  DocSuffix: string
  DocUrl: string
  DocIcon?: string
}
export interface IColumnInfo {
  BgImg: string
  BgImgPc: string
  CollectNum: number
  CompanyName: string
  CreateTime: string
  FollowNum: number
  HeadImg: string
  Id: number
  Introduction: string // 专栏介绍
  IsFollow: number // 是否已关注 1已关注 0 未关注
  Label: string
  showLabel?: string[]
  LatestPublishDate: string
  LatestPublishTime: string
  Mobile: string
  ModifyTime: string
  NickName: string
  RealName: string
  SpecialArticleNum: number
  SpecialName: string // 专栏名称
  Status: number // 1启用2禁用
  UserId: number
}
export interface IUpdateParams {
  SpecialColumnId: number
  SpecialName: string
  Introduction: string
  Label: string
  NickName: string
}
export interface IColumnDetail {
  LikeCount: number
  IsLikeCount: boolean
  SpecialLikeCount: number
  CompanyTags: string[] // 公司标签
  IndustryTags: string[] // 行业标签
  SpecialColumnId: number
  BgImg: string
  CollectNum: number
  Content: string
  ContentHasImg: number
  CreateTime: string
  DocUrl: string
  Docs: IDocsList[]
  HeadImg: string
  Id: number
  ImgUrl: string
  ImgUrlList: string[]
  Introduction: string
  IsCollect: number
  Label: string
  Mobile: string
  ModifyTime: string
  MyCollectNum: number
  NickName: string
  PublishTime: string
  RealName: string
  Reason: string
  SpecialName: string
  Status: number // 1:未发布，2:审核中 3:已发布 4:驳回
  TagList: string[]
  Tags: string
  Title: string
  Type: number //类型1:笔记，2:观点
  UserId: number
  Pv: number
  IsApprovalAdmin: boolean // 是否是审批人员
  IsFollowAuthor: boolean // 是否已关注
  ShareImg: string //分享图片
  GoodsList: IGoodsListItem[] // 商品信息
  HasPermission: number //1:有该行业权限,正常展示，2：无该行业权限，不存在权益客户下（ficc），3:无该品类权限,已提交过申请，4：无该品类权限,未提交过申请，5：潜在客户，未提交过申请，6：潜在客户,已提交过申请
  IsCompanyApply: boolean // 机构是否申请过试用
  IsNeedBusinessCard: boolean // 是否需要上传名片
  IsResearch: boolean // 是否是买方研选
  IsResearchSpecial: boolean // 是否属于特殊的研选
  IsShowWxPay: boolean // 是否展示微信支付
  OrderCode: string // 订单号
  PayTimeCountdown: number // 支付倒计时
  PopupMsg: string //权限弹窗信息
  PopupPriceMsg: string //价格弹窗信息
  Detail: IActivityDetialBase
}

export interface IMessageDetail {
  IsLikeCount: boolean
  LikeCount: number
  CreateTime: string
  RealName: string //用户实际名称
  Headimgurl: string //用户头像
  Content: string //留言内容
  SourceTitle: string //专栏标题
  CheckIds: number[]
  MessageId: number //留言消息ID
  YanxuanSpecialId: number
  Status: number //消息状态，0未公开、1：已公开
  TopTime: number //置顶时间（大于零置顶，等于零未置顶）
  HaveOtherTop: boolean //是否有其它的置顶
  ChildList: IMsgChildrenList[]
}

export interface IMsgChildrenList {
  Headimgurl: string | undefined
  CreateTime: string //创建时间
  MessageId: number
  Content: string //留言内容
}
export interface IActivityDetialBase {
  IsNeedBusinessCard: boolean // 是否需要上传名片
  CompanyTags: string[] // 公司标签
  IndustryTags: string[] // 行业标签
  SpecialColumnId: number
  BgImg: string
  CollectNum: number
  Content: string
  ContentHasImg: number
  CreateTime: string
  DocUrl: string
  Docs: IDocsList[]
  HasPermission: number // 1有权限 2无权限
  HeadImg: string
  Id: number
  ImgUrl: string
  ImgUrlList: string[]
  Introduction: string
  IsCollect: number
  Label: string
  Mobile: string
  ModifyTime: string
  MyCollectNum: number
  NickName: string
  PublishTime: string
  RealName: string
  Reason: string
  SpecialName: string
  Status: number // 1:未发布，2:审核中 3:已发布 4:驳回
  TagList: string[]
  Tags: string
  Title: string
  Type: number //类型1:笔记，2:观点
  UserId: number
  Pv: number
  IsApprovalAdmin: boolean // 是否是审批人员
  IsFollowAuthor: boolean // 是否已关注
  ShareImg: string //分享图片
}
export interface ISaveColumnDetailParams {
  Id: number
  Content: string
  IndustryTags: string[] // 行业标签
  CompanyTags: string[] // 公司标签
  DoType: number // 1保存2发布
  ImgUrl: string[]
  Docs: IDocsList[]
  Title: string
  Type: number //类型1:笔记，2:观点
  IsApprovalPersonnel?: boolean // 是否是审批人员
}
export interface IEditColumnDetail extends ISaveColumnDetailParams {
  SpecialColumnId: number
  HeadImg: string
  NickName: string
  PublishTime: string
  ImgUrlList: string[]
}

export const ColumnService = {
  getColumnAuthorList: (
    PageSize: number, // 每页数据条数
    CurrentIndex: number, // 当前页页码，从1开始
    UserId?: number,
    Status?: number // 1启用2禁用
  ): INewResponse<{
    List: IColumnAuthorList[]
    IsAuthor: boolean
    IsImproveInformation: boolean
    Paging: IPaging
    HeadImg: string
    SpecialColumnId: number
  }> =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/author/list`,
      method: 'get',
      params: { PageSize, CurrentIndex, UserId, Status }
    }),
  geColumnList: (
    PageSize: number, // 每页数据条数
    CurrentIndex: number, // 当前页页码，从1开始
    SpecialColumnId?: number
  ): INewResponse<{ List: IColumnDetail[]; IsAuthor: boolean; IsImproveInformation: boolean; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/list`,
      method: 'get',
      params: { PageSize, CurrentIndex, SpecialColumnId }
    }),
  getAuthorDetail: (SpecialColumnId: number): INewResponse<IColumnInfo> =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/author/detail`,
      method: 'get',
      params: { SpecialColumnId }
    }),
  getColumnDetail: (Id: number, InviteShareCode?: string): INewResponse<IColumnDetail> =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/detail`,
      method: 'get',
      params: { Id, InviteShareCode }
    }),
  getSearchIndustry: (Keyword: string): INewResponse<string[]> =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/industrySearch`,
      method: 'get',
      params: { Keyword }
    }),
  getSearchCompanyTags: (Keyword: string): INewResponse<string[]> =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/companySearch`,
      method: 'get',
      params: { Keyword }
    }),
  getColumnCenterList: (Status: number): INewResponse<IColumnDetail[]> =>
    NewAxiosInstanceFunc({
      url: `yanxuan_special/center`,
      method: 'get',
      params: { Status } // 1:未发布，2:审核中 3:已发布 4:驳回
    }),
  getColumnManageList: (
    PageSize: number, // 每页数据条数
    CurrentIndex: number, // 当前页页码，从1开始
    MessageType: number //留言类型1：普通留言、2：公开留言
  ): INewResponse<IMessageDetail[]> =>
    NewAxiosInstanceFunc({
      url: `yanxuan_special/message/manage/list`,
      method: 'get',
      params: { PageSize, CurrentIndex, MessageType } // 1:未发布，2:审核中 3:已发布 4:驳回
    }),
  getColumnAuthorFansList: (
    PageSize: number, // 每页数据条数
    CurrentIndex: number // 当前页页码，从1开始
  ): INewResponse<IMessageDetail[]> =>
    NewAxiosInstanceFunc({
      url: `yanxuan_special/author/fans_list`,
      method: 'get',
      params: { PageSize, CurrentIndex } // 1:未发布，2:审核中 3:已发布 4:驳回
    }),
  getColumnSpecialList: (
    PageSize: number, // 每页数据条数
    CurrentIndex: number, // 当前页页码，从1开始
    YanxuanSpecialId: number
  ): INewResponse<IMessageDetail[]> =>
    NewAxiosInstanceFunc({
      url: `yanxuan_special/message/special/list`,
      method: 'get',
      params: { PageSize, CurrentIndex, YanxuanSpecialId } //
    }),
  postUpdateAuthorHeadImg: (SpecialColumnId: number, HeadImg: string): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/author/head_img`,
      method: 'post',
      data: { SpecialColumnId, HeadImg }
    }),
  postColumnCollect: (Id: number, Status: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/collect`,
      method: 'post',
      data: { Id, Status } // Status 1收藏2取消收藏
    }),
  postColumnAuthorFollow: (FollowSpecialColumnId: number, Status: number, SpecialId?: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/follow`,
      method: 'post',
      data: { FollowSpecialColumnId, Status, SpecialId } // Status 1收藏2取消收藏
    }),
  postUpdateAuthorDetail: (params: IUpdateParams): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/author/save`,
      method: 'post',
      data: { ...params }
    }),
  postCheckColumnDetail: (params: { Content: string; ImgUrl: string[] }): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/check`,
      method: 'post',
      data: { ...params }
    }),
  postSaveColumnDetail: (params: ISaveColumnDetailParams): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/save`,
      method: 'post',
      data: { ...params }
    }),
  postUploadFile: (file: any): INewResponse<IUploadFileRes> => {
    const formData = new FormData()
    formData.set('file', file)
    return NewAxiosInstanceFunc({
      url: `/resource/file/upload`,
      method: 'post',
      data: formData
    })
  },
  postDeleteNote: (Id: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/del`,
      method: 'post',
      data: { Id }
    }),
  postCancelNote: (Id: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/cancel`,
      method: 'post',
      data: { Id }
    }),
  postCheckColumnNote: (Id: number, Status: number, Reason: string): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/enable`,
      method: 'post',
      data: { Id, Status, Reason } // 1通过2驳回
    }),
  postMessageAdd: (YanxuanSpecialId: number, Content: string, ParentId?: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/message/add`,
      method: 'post',
      data: { YanxuanSpecialId, ParentId, Content }
    }),
  postMessageDelete: (MessageId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/message/delete`,
      method: 'post',
      data: { MessageId }
    }),
  postMessagePublic: (MessageIds: (string | number)[], DoType: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/message/public`,
      method: 'post',
      data: { MessageIds, DoType }
    }),
  postMessageTop: (MessageId: number, DoType: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/message/top`,
      method: 'post',
      data: { MessageId, DoType }
    }),
  postMessageLike: (MessageId: number, DoType: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/message/like`,
      method: 'post',
      data: { MessageId, DoType }
    }),
  postColumnLike: (YanxuanSpecialId: number, DoType: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/yanxuan_special/like`,
      method: 'post',
      data: { YanxuanSpecialId, DoType }
    })
}
