yuanfeiyang02

feat:启动广告页接口数据获取

@@ -281,6 +281,11 @@ export class HttpUrlUtils { @@ -281,6 +281,11 @@ export class HttpUrlUtils {
281 * 更新 兴趣偏好 281 * 更新 兴趣偏好
282 */ 282 */
283 static readonly INTERESTS_UPDATETAG_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/updateUserTag"; 283 static readonly INTERESTS_UPDATETAG_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/updateUserTag";
  284 + /**
  285 + * 获取启动页相关数据
  286 + */
  287 + static readonly LAUNCH_PAGE_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/launchPage";
  288 +
284 private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; 289 private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
285 /** 290 /**
286 * 推荐列表 291 * 推荐列表
@@ -714,6 +719,12 @@ export class HttpUrlUtils { @@ -714,6 +719,12 @@ export class HttpUrlUtils {
714 return url; 719 return url;
715 } 720 }
716 721
  722 + static getLaunchPageDataUrl() {
  723 + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LAUNCH_PAGE_PATH;
  724 + return url;
  725 +
  726 + }
  727 +
717 static getLiveDetailsUrl() { 728 static getLiveDetailsUrl() {
718 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH 729 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH
719 return url 730 return url
@@ -12,6 +12,7 @@ struct LaunchAdvertisingPage { @@ -12,6 +12,7 @@ struct LaunchAdvertisingPage {
12 // url:'pages/MainPage' 12 // url:'pages/MainPage'
13 // }) 13 // })
14 WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) 14 WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
  15 + clearInterval(this.timer)
15 } 16 }
16 17
17 onPageShow(){ 18 onPageShow(){
@@ -9,6 +9,7 @@ import { GlobalContext } from '../../utils/GlobalContext' @@ -9,6 +9,7 @@ import { GlobalContext } from '../../utils/GlobalContext'
9 import { WDRouterRule } from 'wdRouter'; 9 import { WDRouterRule } from 'wdRouter';
10 import { WDRouterPage } from 'wdRouter'; 10 import { WDRouterPage } from 'wdRouter';
11 import { LaunchModel } from '../viewModel/LaunchModel' 11 import { LaunchModel } from '../viewModel/LaunchModel'
  12 +import { LaunchPageModel } from '../viewModel/LaunchPageModel'
12 13
13 @Entry 14 @Entry
14 @Component 15 @Component
@@ -44,7 +45,8 @@ struct LaunchPage { @@ -44,7 +45,8 @@ struct LaunchPage {
44 this.saveIsPrivacy(); 45 this.saveIsPrivacy();
45 //跳转引导页 46 //跳转引导页
46 this.jumpToGuidePage(); 47 this.jumpToGuidePage();
47 - 48 + //同意隐私协议后请求启动页相关数据
  49 + this.requestLaunchPageData();
48 } 50 }
49 51
50 jumpToAdvertisingPage() { 52 jumpToAdvertisingPage() {
@@ -90,9 +92,11 @@ struct LaunchPage { @@ -90,9 +92,11 @@ struct LaunchPage {
90 this.dialogController.open(); 92 this.dialogController.open();
91 // } 93 // }
92 } else { 94 } else {
  95 + //需要根据请求数据判断是否需要进入广告页,广告数据为nil则直接跳转到首页
93 //跳转广告页 96 //跳转广告页
94 this.jumpToAdvertisingPage(); 97 this.jumpToAdvertisingPage();
95 - 98 + //同意隐私协议后每次启动app请求启动页相关数据,并更新数据
  99 + this.requestLaunchPageData();
96 } 100 }
97 }); 101 });
98 }); 102 });
@@ -154,4 +158,12 @@ struct LaunchPage { @@ -154,4 +158,12 @@ struct LaunchPage {
154 launchModel.getAgreement() 158 launchModel.getAgreement()
155 } 159 }
156 160
  161 + requestLaunchPageData() {
  162 + //请求启动页相关接口数据并保存
  163 + let launchPageModel = new LaunchPageModel()
  164 + launchPageModel.getLaunchPageData()
  165 +
  166 + }
  167 +
  168 +
157 } 169 }
@@ -46,16 +46,6 @@ export class InterestsHobbiesModel { @@ -46,16 +46,6 @@ export class InterestsHobbiesModel {
46 Logger.debug("InterestsHobbiesModel兴趣偏好数据获取成功:success ", JSON.stringify(data)) 46 Logger.debug("InterestsHobbiesModel兴趣偏好数据获取成功:success ", JSON.stringify(data))
47 success(data.data); 47 success(data.data);
48 48
49 -  
50 - //保存数据  
51 - // for (let i = 0; i < data.data.length; i++) {  
52 - // if (data.data[i].type == 1) {  
53 - // SPHelper.default.save(SpConstants.USER_PROTOCOL, data.data[i].linkUrl)  
54 - // } else if (data.data[i].type == 2) {  
55 - // SPHelper.default.save(SpConstants.PRIVATE_PROTOCOL, data.data[i].linkUrl)  
56 - // }  
57 - // }  
58 -  
59 }, (error: Error) => { 49 }, (error: Error) => {
60 Logger.debug("InterestsHobbiesModel兴趣偏好数据获取失败:error ", error.toString()) 50 Logger.debug("InterestsHobbiesModel兴趣偏好数据获取失败:error ", error.toString())
61 fail(error.message) 51 fail(error.message)
  1 +
  2 +
  3 +export interface NetLayerLaunchOperatModel {
  4 +
  5 + ID : string
  6 + screenName : string //开机屏名称
  7 + objectType : string // WDPublicProgramType 对象类型 0:不跳转,1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,11:图文,12:组图,13:H5新闻,14:频道
  8 + objectId : string //跳转id
  9 + objectLevel : string //频道(1:一级频道,2:二级频道),专题(1:普通专题,2:主题专题,3:作者专题 21:文章专题,22:音频专题,23:直播专题,24:话题专题)
  10 + pageId : string //跳转页面id,objectType=5,14使用页面跳转
  11 + durations : string //展示时长(单位:秒)
  12 + linkUrl : string //转链接地址【objectType=6,13】
  13 + screenType : string // 0, 1 : WDDisplayStyle_Logo 2 : WDDisplayStyle_Full
  14 + bootScreenUrl : string //开机屏封面图/视频地址
  15 + bootVideoScreenUrl : string //视频封面地址
  16 + showType : string //文件类型WDPublicFileType 2: 视频 其他: 图片
  17 + isAd : string //0-非广告,1-是广告
  18 + bottomNavId : string //底部导航ID
  19 + relId : string //频道/专题内容关系id
  20 +
  21 +}
  22 +
  23 +
  24 +export interface NetLayerLauncherADMaterialModel{
  25 +
  26 + matType : string //1 video 其他 image
  27 + startStyle : number // 1 WDDisplayStyle_Full 全屏样式 其他 WDDisplayStyle_Logo 底部logo样式
  28 + advTitle : string
  29 + matImageUrl : string[] //取firstObject
  30 + matVideoUrl : string
  31 +
  32 + openType : string //链接打开方式,0-没链接,不用打开,1-端内打开,2-端外打开
  33 + linkUrl : string
  34 +
  35 +}
  36 +
  37 +export interface NetLayerLauncherADInfoModel{
  38 +
  39 + ID : string
  40 + startTime : number
  41 + endTime : number
  42 + displayDuration : number
  43 + displayRound : number
  44 + matInfo : NetLayerLauncherADMaterialModel
  45 +
  46 +}
  47 +
  48 +export interface NetLayerLauncherH5TemplateInfoModel{
  49 +
  50 + versionRangeMin : string
  51 + versionRangeMax : string
  52 + h5TemplateUrl : string
  53 + version : string
  54 + md5 : string
  55 +
  56 +}
  57 +
  58 +
  59 +export default interface LaunchDataModel{
  60 +
  61 + launchPageInfo : NetLayerLaunchOperatModel
  62 + launchAdInfo : NetLayerLauncherADInfoModel[]
  63 + h5Template : NetLayerLauncherH5TemplateInfoModel[]
  64 +
  65 +}
  1 +
  2 +import LaunchDataModel from '../viewModel/LaunchDataModel'
  3 +
  4 +import HashMap from '@ohos.util.HashMap';
  5 +import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
  6 +import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
  7 +import { Logger, SPHelper } from 'wdKit/Index';
  8 +import data from '@ohos.telephony.data';
  9 +import { SpConstants } from 'wdConstant/Index';
  10 +
  11 +
  12 +export class LaunchPageModel {
  13 +
  14 + getLaunchPageData() {
  15 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  16 + return new Promise<LaunchDataModel>((success, fail) => {
  17 + HttpRequest.get<ResponseDTO<LaunchDataModel>>(HttpUrlUtils.getLaunchPageDataUrl(), headers).then((data: ResponseDTO<LaunchDataModel>) => {
  18 + if (!data || !data.data) {
  19 + fail("数据为空")
  20 + return
  21 + }
  22 + if (data.code != 0) {
  23 + fail(data.message)
  24 + return
  25 + }
  26 + Logger.debug("LaunchPageModel获取启动相关数据获取成功:success ", JSON.stringify(data))
  27 + success(data.data);
  28 + //存储数据
  29 +
  30 +
  31 +
  32 + }, (error: Error) => {
  33 + Logger.debug("LaunchPageModel获取启动相关数据获取失败:error ", error.toString())
  34 + fail(error.message)
  35 + })
  36 + })
  37 + }
  38 +
  39 +
  40 +
  41 +}