ProcessUtils.ets 2.31 KB
import { Action, ContentDTO, Params } from 'wdBean';
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
import { Logger } from 'wdKit';
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
import { WDRouterRule } from 'wdRouter';
import { ContentConstants } from '../constants/ContentConstants';

const TAG = 'ProcessUtils';

/**
 * 页面跳转业务封装
 */
export class ProcessUtils {
  /**
   * 页面跳转
   */
  static processPage(content: ContentDTO) {
    if (content == null) {
      Logger.error(TAG, "processPage, content is null");
      return;
    }
    if (StringUtils.isEmpty(content.objectType)) {
      Logger.error(TAG, "processPage, objectType is empty");
      return;
    }
    let type = content.objectType;
    switch (type) {
      case ContentConstants.TYPE_NONE:
        Logger.debug(TAG, "processPage, do nothing");
        break;
      case ContentConstants.TYPE_VOD:
        Logger.debug(TAG, "processPage, nonsupport!!!");
        ProcessUtils.gotoVod(content)
        break;
      case ContentConstants.TYPE_TELETEXT:
      // 图文详情,跳转h5
        ProcessUtils.gotoWeb(content);
        break;
      default:
        break;
    }
  }

  private static gotoWeb(content: ContentDTO) {
    //  // topicId
    // content.channelId;
    // content.linkUrl;
    // content.objectId;
    // // CompId
    // content.relId;
    // content.relType;
    // // ScrollToBottom
    // // FromPage
    let taskAction: Action = {
      type: 'JUMP_INNER_NEW_PAGE',
      params: {
        contentID: content?.objectId,
        pageID: 'IMAGE_TEXT_DETAIL',
        extra:{
          relType: content?.relType,
          relId: content?.relId,
          channelId: content?.channelId,
          sourcePage: '5'
        } as ExtraDTO
      } as Params,
    };
    WDRouterRule.jumpWithAction(taskAction)
    Logger.debug(TAG, `gotoWeb, ${content.objectId}`);
  }

  private static gotoVod(content: ContentDTO) {
    let taskAction: Action = {
      type: 'JUMP_DETAIL_PAGE',
      params: {
        detailPageType: 7,
        contentID: content?.objectId,
        extra:{
          relType: content?.relType,
          relId: content?.relId,
        } as ExtraDTO
      } as Params,
    };
    WDRouterRule.jumpWithAction(taskAction)
    Logger.debug(TAG, `gotoVod, ${content.objectId}`);
  }
}