陈剑华

Merge remote-tracking branch 'origin/main'

@@ -253,6 +253,13 @@ export class HttpUrlUtils { @@ -253,6 +253,13 @@ export class HttpUrlUtils {
253 * 早晚报获取PAGEID 253 * 早晚报获取PAGEID
254 * */ 254 * */
255 static readonly DAILY_PAPER_TOPIC: string = "/api/rmrb-bff-display-zh/display/zh/c/dailyPaperTopic"; 255 static readonly DAILY_PAPER_TOPIC: string = "/api/rmrb-bff-display-zh/display/zh/c/dailyPaperTopic";
  256 +
  257 + /**
  258 + * app启动页 兴趣偏好
  259 + */
  260 + static readonly INTERESTS_HOTS_DATA_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/queryTags";
  261 +
  262 +
256 private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; 263 private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
257 /** 264 /**
258 * 推荐列表 265 * 推荐列表
@@ -650,6 +657,12 @@ export class HttpUrlUtils { @@ -650,6 +657,12 @@ export class HttpUrlUtils {
650 return url 657 return url
651 } 658 }
652 659
  660 + static getInterestsUrl() {
  661 + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERESTS_HOTS_DATA_PATH;
  662 + return url;
  663 +
  664 + }
  665 +
653 static getLiveDetailsUrl() { 666 static getLiveDetailsUrl() {
654 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH 667 let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH
655 return url 668 return url
@@ -87,6 +87,9 @@ export class WDRouterPage { @@ -87,6 +87,9 @@ export class WDRouterPage {
87 static launchAdvertisingPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchAdvertisingPage"); 87 static launchAdvertisingPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchAdvertisingPage");
88 //主页 88 //主页
89 static mainPage = new WDRouterPage("phone", "ets/pages/MainPage"); 89 static mainPage = new WDRouterPage("phone", "ets/pages/MainPage");
  90 +
  91 + static launchInterestsPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchInterestsHobbiesPage");
  92 +
90 // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview"); 93 // static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
91 94
92 //播报页面 95 //播报页面
@@ -72,5 +72,6 @@ export interface ContentDTO { @@ -72,5 +72,6 @@ export interface ContentDTO {
72 corner: string; 72 corner: string;
73 rmhPlatform: number; 73 rmhPlatform: number;
74 newTags: string; 74 newTags: string;
  75 + titleShow?: number;
75 isSearch?: boolean; // 是否是搜索的结果,区分搜索和主页的数据 76 isSearch?: boolean; // 是否是搜索的结果,区分搜索和主页的数据
76 } 77 }
@@ -20,12 +20,18 @@ export struct CardSourceInfo { @@ -20,12 +20,18 @@ export struct CardSourceInfo {
20 .fontColor($r("app.color.color_B0B0B0")) 20 .fontColor($r("app.color.color_B0B0B0"))
21 .maxLines(1) 21 .maxLines(1)
22 .textOverflow({ overflow: TextOverflow.Ellipsis }) 22 .textOverflow({ overflow: TextOverflow.Ellipsis })
  23 + Image($r("app.media.point"))
  24 + .width(16)
  25 + .height(16)
23 } else if (this.contentDTO.source) { 26 } else if (this.contentDTO.source) {
24 Text(`${this.contentDTO.source}`) 27 Text(`${this.contentDTO.source}`)
25 .fontSize($r("app.float.font_size_12")) 28 .fontSize($r("app.float.font_size_12"))
26 .fontColor($r("app.color.color_B0B0B0")) 29 .fontColor($r("app.color.color_B0B0B0"))
27 .maxLines(1) 30 .maxLines(1)
28 .textOverflow({ overflow: TextOverflow.Ellipsis }) 31 .textOverflow({ overflow: TextOverflow.Ellipsis })
  32 + Image($r("app.media.point"))
  33 + .width(16)
  34 + .height(16)
29 } 35 }
30 // 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间 36 // 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间
31 if (this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime 37 if (this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime
@@ -34,9 +40,6 @@ export struct CardSourceInfo { @@ -34,9 +40,6 @@ export struct CardSourceInfo {
34 .contentDTO.publishTime)) 40 .contentDTO.publishTime))
35 .indexOf 41 .indexOf
36 ('-') === -1) { 42 ('-') === -1) {
37 - Image($r("app.media.point"))  
38 - .width(16)  
39 - .height(16)  
40 Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) 43 Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
41 .fontSize($r("app.float.font_size_12")) 44 .fontSize($r("app.float.font_size_12"))
42 .fontColor($r("app.color.color_B0B0B0")) 45 .fontColor($r("app.color.color_B0B0B0"))
@@ -17,7 +17,7 @@ export struct Card10Component { @@ -17,7 +17,7 @@ export struct Card10Component {
17 build() { 17 build() {
18 Column() { 18 Column() {
19 // 顶部标题,最多两行 19 // 顶部标题,最多两行
20 - if (this.contentDTO.newsTitle) { 20 + if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
21 Text(this.contentDTO.newsTitle) 21 Text(this.contentDTO.newsTitle)
22 .width(CommonConstants.FULL_WIDTH) 22 .width(CommonConstants.FULL_WIDTH)
23 .fontSize($r('app.float.font_size_17')) 23 .fontSize($r('app.float.font_size_17'))
@@ -42,16 +42,15 @@ export struct Card6Component { @@ -42,16 +42,15 @@ export struct Card6Component {
42 .alignItems(HorizontalAlign.Start) 42 .alignItems(HorizontalAlign.Start)
43 .justifyContent(FlexAlign.Start) 43 .justifyContent(FlexAlign.Start)
44 .width('58%') 44 .width('58%')
45 - if (this.contentDTO.coverUrl) {  
46 - Stack() {  
47 - Image(this.contentDTO.coverUrl)  
48 - .borderRadius(5)  
49 - .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)  
50 - .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180)  
51 - CardMediaInfo({ contentDTO: this.contentDTO })  
52 - }  
53 - .alignContent(Alignment.BottomEnd) 45 + Stack() {
  46 + Image(this.contentDTO.coverUrl)
  47 + .backgroundColor($r('app.color.color_B0B0B0'))
  48 + .borderRadius(5)
  49 + .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
  50 + .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180)
  51 + CardMediaInfo({ contentDTO: this.contentDTO })
54 } 52 }
  53 + .alignContent(Alignment.BottomEnd)
55 } 54 }
56 .onClick((event: ClickEvent) => { 55 .onClick((event: ClickEvent) => {
57 ProcessUtils.processPage(this.contentDTO) 56 ProcessUtils.processPage(this.contentDTO)
@@ -15,7 +15,7 @@ export struct Card9Component { @@ -15,7 +15,7 @@ export struct Card9Component {
15 build() { 15 build() {
16 Column() { 16 Column() {
17 // 顶部标题,最多两行 17 // 顶部标题,最多两行
18 - if (this.contentDTO.newsTitle) { 18 + if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
19 Text(this.contentDTO.newsTitle) 19 Text(this.contentDTO.newsTitle)
20 .width(CommonConstants.FULL_WIDTH) 20 .width(CommonConstants.FULL_WIDTH)
21 .fontSize($r('app.float.font_size_17')) 21 .fontSize($r('app.float.font_size_17'))
@@ -59,7 +59,9 @@ struct GuidePages { @@ -59,7 +59,9 @@ struct GuidePages {
59 .onClick(() => { 59 .onClick(() => {
60 if (index == 3) { 60 if (index == 3) {
61 // 跳转到首页 61 // 跳转到首页
62 - WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) 62 + //WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
  63 + //跳转到兴趣偏好选择页
  64 + WDRouterRule.jumpWithReplacePage(WDRouterPage.launchInterestsPage)
63 } 65 }
64 }) 66 })
65 .id('index') 67 .id('index')
  1 +import {InterestsHobbiesModel, InterestsList} from '../viewModel/InterestsHobbiesModel'
  2 +import { WDRouterRule } from 'wdRouter';
  3 +import { WDRouterPage } from 'wdRouter';
  4 +
  5 +@Entry
  6 +@Component
  7 +struct LaunchInterestsHobbiesPage {
  8 + @State message: string = 'Hello World'
  9 + @State dataArray: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  10 + @State selectCount: number = 0
  11 + @State interestsArray: InterestsList[] = []
  12 +
  13 +
  14 + aboutToAppear(){
  15 + //请求接口,获取兴趣偏好数据
  16 + this.requestInterestsData()
  17 + }
  18 +
  19 +
  20 + build() {
  21 + Column() {
  22 + Row(){
  23 + Blank()
  24 + Text('跳过')
  25 + .fontSize('27lpx')
  26 + .fontColor('#333333')
  27 + .width('54lpx')
  28 + .height('35lpx')
  29 + .margin({top:'27lpx',right:'46lpx'})
  30 + .onClick(()=>{
  31 + //直接跳过到首页
  32 + //跳转首页
  33 + WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
  34 + })
  35 + }
  36 + .width('100%')
  37 + .justifyContent(FlexAlign.End)
  38 +
  39 + Text('选择感兴趣的内容')
  40 + .fontSize('46lpx')
  41 + .fontWeight(FontWeight.Bold)
  42 + .textAlign(TextAlign.Center)
  43 + .fontColor('#333333')
  44 + .width('100%')
  45 + .height('61lpx')
  46 + .margin({top:'84lpx'})
  47 + Text('完善信息,将为您推荐个性化的内容')
  48 + .fontSize('27lpx')
  49 + .textAlign(TextAlign.Center)
  50 + .fontColor('#9E9E9E')
  51 + .width('100%')
  52 + .height('35lpx')
  53 + .margin({top:'12lpx'})
  54 +
  55 + Grid( ){
  56 + ForEach(this.interestsArray,(item:InterestsList,index:number)=>{
  57 + GridItem(){
  58 + Stack({alignContent:Alignment.TopStart}){
  59 +
  60 + Image(item.pic)
  61 + .width('100%')
  62 + .height('100%')
  63 + .backgroundColor(Color.White)
  64 + .borderRadius(5)
  65 + Stack(){
  66 + Column({}){
  67 + Text(item.name)
  68 + .fontSize('35lpx')
  69 + .fontColor('#FFFFFF')
  70 + .margin({top:'21lpx',left:'19lpx'})
  71 + .width('100%')
  72 + .height('46lpx')
  73 + .fontWeight(FontWeight.Bold)
  74 + Text(item.title)
  75 + .fontSize('23lpx')
  76 + .fontColor('#FFFFFF')
  77 + .margin({top:'2lpx',left:'19lpx'})
  78 + .width('100%')
  79 + .height('31lpx')
  80 + }.justifyContent(FlexAlign.Start)
  81 + }
  82 +
  83 + Stack(){
  84 + Image('')
  85 + .width('100%')
  86 + .height('100%')
  87 + .backgroundColor(Color.White)
  88 + .opacity(item.choose?0:0.7)
  89 + .borderRadius(5)
  90 + }
  91 + }
  92 + }
  93 + .width('192lpx')
  94 + .height('230lpx')
  95 + .borderRadius('8lpx')
  96 + .onClick(()=>{
  97 + //选择后改变已选择属性
  98 + item.choose = !item.choose
  99 + this.interestsArray.splice(index,1,item)
  100 + this.selectCount = this.interestsArray.filter(item => item.choose).length
  101 + })
  102 +
  103 + })
  104 +
  105 + }
  106 + .width('90%')
  107 + .height('70%')
  108 + .margin({top:'61lpx'})
  109 + .columnsTemplate('1fr 1fr 1fr')
  110 + // .rowsTemplate('1fr 1fr 1fr 1fr')
  111 + .columnsGap('23lpx')
  112 + .rowsGap('23lpx')
  113 +
  114 + Stack({alignContent:Alignment.Center}){
  115 + Button(this.selectCount == 0?'选好了':'选好了(' + this.selectCount + ')')
  116 + .fontSize('35lpx')
  117 + .fontColor('#FFFFFF')
  118 + .backgroundColor('#ED2800')
  119 + .type(ButtonType.Normal)
  120 + .borderRadius('10lpx')
  121 + .width('662lpx')
  122 + .height('84lpx')
  123 + .onClick(()=>{
  124 + //跳转首页
  125 + WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
  126 + })
  127 + }
  128 + .width('100%')
  129 + .height('108lpx')
  130 + // .position({y:})
  131 + // .margin({bottom:'1',top:'1'})
  132 + .backgroundColor('#FFFFFF')
  133 +
  134 + }
  135 + .width('100%')
  136 + .height('100%')
  137 + }
  138 +
  139 +
  140 + requestInterestsData() {
  141 + //请求隐私协议接口
  142 + let interestsModel = new InterestsHobbiesModel()
  143 + interestsModel.getInterestsHobbiesData()
  144 + .then((value:InterestsList[])=>{
  145 + this.interestsArray = value
  146 + })
  147 + .catch((err:Error)=>{
  148 + console.log('获取兴趣偏好数据出错' + err)
  149 + })
  150 + }
  151 +
  152 +}
  1 +import HashMap from '@ohos.util.HashMap';
  2 +import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
  3 +import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
  4 +import { Logger, SPHelper } from 'wdKit/Index';
  5 +import data from '@ohos.telephony.data';
  6 +
  7 +
  8 +export interface InterestsBean {
  9 +
  10 + // code : string
  11 + // message : string
  12 + // success : boolean
  13 + // timestamp : number
  14 + data : InterestsList[]
  15 +
  16 +}
  17 +
  18 +
  19 +export interface InterestsList{
  20 +
  21 + id : number
  22 + title : string
  23 + pic : string
  24 + name : string
  25 + choose : boolean
  26 +
  27 +}
  28 +
  29 +
  30 +export class InterestsHobbiesModel {
  31 +
  32 +
  33 + getInterestsHobbiesData() {
  34 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  35 + return new Promise<InterestsList[]>((success, fail) => {
  36 + HttpRequest.get<ResponseDTO<InterestsList[]>>(HttpUrlUtils.getInterestsUrl(), headers).then((data: ResponseDTO<InterestsList[]>) => {
  37 + if (!data || !data.data) {
  38 + fail("数据为空")
  39 + return
  40 + }
  41 + if (data.code != 0) {
  42 + fail(data.message)
  43 + return
  44 + }
  45 + Logger.debug("InterestsHobbiesModel兴趣偏好数据获取成功:success ", JSON.stringify(data))
  46 + success(data.data);
  47 +
  48 +
  49 + //保存数据
  50 + // for (let i = 0; i < data.data.length; i++) {
  51 + // if (data.data[i].type == 1) {
  52 + // SPHelper.default.save(SpConstants.USER_PROTOCOL, data.data[i].linkUrl)
  53 + // } else if (data.data[i].type == 2) {
  54 + // SPHelper.default.save(SpConstants.PRIVATE_PROTOCOL, data.data[i].linkUrl)
  55 + // }
  56 + // }
  57 +
  58 + }, (error: Error) => {
  59 + Logger.debug("InterestsHobbiesModel兴趣偏好数据获取失败:error ", error.toString())
  60 + fail(error.message)
  61 + })
  62 + })
  63 +
  64 +
  65 + }
  66 +
  67 +
  68 +}
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 "pages/launchPage/LaunchPage", 11 "pages/launchPage/LaunchPage",
12 "pages/launchPage/LaunchAdvertisingPage", 12 "pages/launchPage/LaunchAdvertisingPage",
13 "pages/broadcast/BroadcastPage", 13 "pages/broadcast/BroadcastPage",
  14 + "pages/launchPage/LaunchInterestsHobbiesPage",
14 "pages/SpacialTopicPage" 15 "pages/SpacialTopicPage"
15 ] 16 ]
16 -} 17 +}