陈剑华

Merge remote-tracking branch 'origin/main'

... ... @@ -253,6 +253,13 @@ export class HttpUrlUtils {
* 早晚报获取PAGEID
* */
static readonly DAILY_PAPER_TOPIC: string = "/api/rmrb-bff-display-zh/display/zh/c/dailyPaperTopic";
/**
* app启动页 兴趣偏好
*/
static readonly INTERESTS_HOTS_DATA_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/queryTags";
private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
/**
* 推荐列表
... ... @@ -650,6 +657,12 @@ export class HttpUrlUtils {
return url
}
static getInterestsUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERESTS_HOTS_DATA_PATH;
return url;
}
static getLiveDetailsUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH
return url
... ...
... ... @@ -87,6 +87,9 @@ export class WDRouterPage {
static launchAdvertisingPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchAdvertisingPage");
//主页
static mainPage = new WDRouterPage("phone", "ets/pages/MainPage");
static launchInterestsPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchInterestsHobbiesPage");
// static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
//播报页面
... ...
... ... @@ -72,5 +72,6 @@ export interface ContentDTO {
corner: string;
rmhPlatform: number;
newTags: string;
titleShow?: number;
isSearch?: boolean; // 是否是搜索的结果,区分搜索和主页的数据
}
\ No newline at end of file
... ...
... ... @@ -20,12 +20,18 @@ export struct CardSourceInfo {
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Image($r("app.media.point"))
.width(16)
.height(16)
} else if (this.contentDTO.source) {
Text(`${this.contentDTO.source}`)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Image($r("app.media.point"))
.width(16)
.height(16)
}
// 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间
if (this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime
... ... @@ -34,9 +40,6 @@ export struct CardSourceInfo {
.contentDTO.publishTime))
.indexOf
('-') === -1) {
Image($r("app.media.point"))
.width(16)
.height(16)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
... ...
... ... @@ -17,7 +17,7 @@ export struct Card10Component {
build() {
Column() {
// 顶部标题,最多两行
if (this.contentDTO.newsTitle) {
if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_17'))
... ...
... ... @@ -42,16 +42,15 @@ export struct Card6Component {
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
.width('58%')
if (this.contentDTO.coverUrl) {
Stack() {
Image(this.contentDTO.coverUrl)
.borderRadius(5)
.aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180)
CardMediaInfo({ contentDTO: this.contentDTO })
}
.alignContent(Alignment.BottomEnd)
Stack() {
Image(this.contentDTO.coverUrl)
.backgroundColor($r('app.color.color_B0B0B0'))
.borderRadius(5)
.aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180)
CardMediaInfo({ contentDTO: this.contentDTO })
}
.alignContent(Alignment.BottomEnd)
}
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
... ...
... ... @@ -15,7 +15,7 @@ export struct Card9Component {
build() {
Column() {
// 顶部标题,最多两行
if (this.contentDTO.newsTitle) {
if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_17'))
... ...
... ... @@ -59,7 +59,9 @@ struct GuidePages {
.onClick(() => {
if (index == 3) {
// 跳转到首页
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
//WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
//跳转到兴趣偏好选择页
WDRouterRule.jumpWithReplacePage(WDRouterPage.launchInterestsPage)
}
})
.id('index')
... ...
import {InterestsHobbiesModel, InterestsList} from '../viewModel/InterestsHobbiesModel'
import { WDRouterRule } from 'wdRouter';
import { WDRouterPage } from 'wdRouter';
@Entry
@Component
struct LaunchInterestsHobbiesPage {
@State message: string = 'Hello World'
@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]
@State selectCount: number = 0
@State interestsArray: InterestsList[] = []
aboutToAppear(){
//请求接口,获取兴趣偏好数据
this.requestInterestsData()
}
build() {
Column() {
Row(){
Blank()
Text('跳过')
.fontSize('27lpx')
.fontColor('#333333')
.width('54lpx')
.height('35lpx')
.margin({top:'27lpx',right:'46lpx'})
.onClick(()=>{
//直接跳过到首页
//跳转首页
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
})
}
.width('100%')
.justifyContent(FlexAlign.End)
Text('选择感兴趣的内容')
.fontSize('46lpx')
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.fontColor('#333333')
.width('100%')
.height('61lpx')
.margin({top:'84lpx'})
Text('完善信息,将为您推荐个性化的内容')
.fontSize('27lpx')
.textAlign(TextAlign.Center)
.fontColor('#9E9E9E')
.width('100%')
.height('35lpx')
.margin({top:'12lpx'})
Grid( ){
ForEach(this.interestsArray,(item:InterestsList,index:number)=>{
GridItem(){
Stack({alignContent:Alignment.TopStart}){
Image(item.pic)
.width('100%')
.height('100%')
.backgroundColor(Color.White)
.borderRadius(5)
Stack(){
Column({}){
Text(item.name)
.fontSize('35lpx')
.fontColor('#FFFFFF')
.margin({top:'21lpx',left:'19lpx'})
.width('100%')
.height('46lpx')
.fontWeight(FontWeight.Bold)
Text(item.title)
.fontSize('23lpx')
.fontColor('#FFFFFF')
.margin({top:'2lpx',left:'19lpx'})
.width('100%')
.height('31lpx')
}.justifyContent(FlexAlign.Start)
}
Stack(){
Image('')
.width('100%')
.height('100%')
.backgroundColor(Color.White)
.opacity(item.choose?0:0.7)
.borderRadius(5)
}
}
}
.width('192lpx')
.height('230lpx')
.borderRadius('8lpx')
.onClick(()=>{
//选择后改变已选择属性
item.choose = !item.choose
this.interestsArray.splice(index,1,item)
this.selectCount = this.interestsArray.filter(item => item.choose).length
})
})
}
.width('90%')
.height('70%')
.margin({top:'61lpx'})
.columnsTemplate('1fr 1fr 1fr')
// .rowsTemplate('1fr 1fr 1fr 1fr')
.columnsGap('23lpx')
.rowsGap('23lpx')
Stack({alignContent:Alignment.Center}){
Button(this.selectCount == 0?'选好了':'选好了(' + this.selectCount + ')')
.fontSize('35lpx')
.fontColor('#FFFFFF')
.backgroundColor('#ED2800')
.type(ButtonType.Normal)
.borderRadius('10lpx')
.width('662lpx')
.height('84lpx')
.onClick(()=>{
//跳转首页
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
})
}
.width('100%')
.height('108lpx')
// .position({y:})
// .margin({bottom:'1',top:'1'})
.backgroundColor('#FFFFFF')
}
.width('100%')
.height('100%')
}
requestInterestsData() {
//请求隐私协议接口
let interestsModel = new InterestsHobbiesModel()
interestsModel.getInterestsHobbiesData()
.then((value:InterestsList[])=>{
this.interestsArray = value
})
.catch((err:Error)=>{
console.log('获取兴趣偏好数据出错' + err)
})
}
}
\ No newline at end of file
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { Logger, SPHelper } from 'wdKit/Index';
import data from '@ohos.telephony.data';
export interface InterestsBean {
// code : string
// message : string
// success : boolean
// timestamp : number
data : InterestsList[]
}
export interface InterestsList{
id : number
title : string
pic : string
name : string
choose : boolean
}
export class InterestsHobbiesModel {
getInterestsHobbiesData() {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<InterestsList[]>((success, fail) => {
HttpRequest.get<ResponseDTO<InterestsList[]>>(HttpUrlUtils.getInterestsUrl(), headers).then((data: ResponseDTO<InterestsList[]>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
Logger.debug("InterestsHobbiesModel兴趣偏好数据获取成功:success ", JSON.stringify(data))
success(data.data);
//保存数据
// for (let i = 0; i < data.data.length; i++) {
// if (data.data[i].type == 1) {
// SPHelper.default.save(SpConstants.USER_PROTOCOL, data.data[i].linkUrl)
// } else if (data.data[i].type == 2) {
// SPHelper.default.save(SpConstants.PRIVATE_PROTOCOL, data.data[i].linkUrl)
// }
// }
}, (error: Error) => {
Logger.debug("InterestsHobbiesModel兴趣偏好数据获取失败:error ", error.toString())
fail(error.message)
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@
"pages/launchPage/LaunchPage",
"pages/launchPage/LaunchAdvertisingPage",
"pages/broadcast/BroadcastPage",
"pages/launchPage/LaunchInterestsHobbiesPage",
"pages/SpacialTopicPage"
]
}
}
\ No newline at end of file
... ...