Message.ets 2.1 KB
import { Action } from './Action';

interface IImgItem {
  pic: string
  width: number
  height: number
}

export interface IImgListData {
  imgIndex: number
  imgArr: IImgItem[]
}

interface dataObject {
  // dataSource:
  // 1、图文详情数据
  // 2、英文端跳转推荐内容数据
  // 3、显示图片预览
  // 4、专题pageinfo数据
  // 5、专题comp运营位点击跳转(传给App记录浏览历史)
  // 6、图文详情引用内容跳转
  // 7、专题分享海报图上的数据列表(H5可选第一页前5条运营位数据)
  // 8、活动投稿 文章跳转
  // 9、活动投稿 视频跳转
  // 10、活动投稿 动态跳转
  // 11、活动投稿 图集跳转
  dataSource: WDH5WebDataSource
  operateType?: string
  webViewHeight?: string
  dataJson?: string
  appInnerLink?: string
  method?: string
  url?: string
  parameters?: object
  videoUrl?: string
  positionWidth?: string
  positionHeight?: string
  positionLeft?: string
  positionTop?: string
  videoLandscape?: string
  imgListData?: string
}

/**
 * 消息Message
 */
export class Message {
  callbackId: string = ""; //callbackId
  responseId: string = ""; //responseId
  responseData: string = ""; //responseData
  data?: dataObject; //data of message
  handlerName: string = ""; //name of handler

  /**
   * TODO 待验证
   * @returns
   */
  toJson(): string {
    let jsonString: string = JSON.stringify(this)
    return jsonString
  }

  /**
   * TODO 待验证
   * @param jsonStr
   * @returns
   */
  toList(jsonStr: string): Array<Message> {
    return JSON.parse(jsonStr)
  }
}

export enum WDH5WebDataSource {

  WDH5WebDataSourceUnknown = 0,
  WDH5WebDataSourceImageTextDetail = 1,
  WDH5WebDataSourceContentInfo = 2,
  WDH5WebDataSourcePictures = 3,
  WDH5WebDataSourceTopicPageInfo = 4,
  WDH5WebDataSourceCompPositionData = 5,
  WDH5WebDataSourceArticleRefDataJump = 6,
  WDH5WebDataSourceSharePosterListDatas = 7,

  WDH5WebDataSourcePartinActivityPublishArticle = 8,
  WDH5WebDataSourcePartinActivityPublishVideo = 9,
  WDH5WebDataSourcePartinActivityPublishDynamic = 10,
  WDH5WebDataSourcePartinActivityPublishPicture = 11,
}