yangsunyue_wd

Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool

# Conflicts:
#	sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
Showing 99 changed files with 2878 additions and 724 deletions

Too many changes to show.

To preserve performance only 99 of 99+ files are displayed.

import { SearchComponent } from 'wdComponent'
@Entry
@Component
struct SearchPage {
build() {
Column(){
SearchComponent()
}.height('100%')
.width('100%')
}
}
\ No newline at end of file
... ...
... ... @@ -14,6 +14,7 @@
"pages/LaunchPage",
"pages/LaunchAdvertisingPage",
"pages/PrivacyPage",
"pages/OtherNormalUserHomePage"
"pages/OtherNormalUserHomePage",
"pages/SearchPage"
]
}
}
\ No newline at end of file
... ...
{
"code": "0",
"data": [
{
"hotEntry": "习语",
"mark": 1,
"sequence": 1
},
{
"hotEntry": "党史学习教育工作",
"mark": 1,
"sequence": 2
},
{
"hotEntry": "2024年全国两会新闻中心启用",
"mark": 1,
"sequence": 3
},
{
"hotEntry": "第二艘国产大型邮轮后年底交付",
"mark": 0,
"sequence": 4
},
{
"hotEntry": "268名跨境电诈犯罪嫌疑人移交",
"mark": 0,
"sequence": 5
},
{
"hotEntry": "高考倒计时100天",
"mark": 2,
"sequence": 6
},
{
"hotEntry": "日本开始第四轮核污染水排放",
"mark": 0,
"sequence": 7
},
{
"hotEntry": "国台办点名管碧玲",
"mark": 0,
"sequence": 8
},
{
"hotEntry": "美方称不会向乌克兰派兵",
"mark": 2,
"sequence": 9
},
{
"hotEntry": "电动车乱停乱充电",
"mark": 2,
"sequence": 10
}
],
"message": "Success",
"success": true,
"timestamp": 1712631086296
}
\ No newline at end of file
... ...
... ... @@ -44,4 +44,6 @@ export { FollowFirstTabsComponent } from "./components/page/mine/follow/FollowFi
export { MyHomeComponent } from "./components/page/mine/home/MyHomeComponent"
export { OtherUserHomeComponent } from "./components/page/mine/home/OtherUserHomeComponent"
\ No newline at end of file
export { OtherUserHomeComponent } from "./components/page/mine/home/OtherUserHomeComponent"
export { SearchComponent } from "./components/page/search/SearchComponent"
\ No newline at end of file
... ...
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import RouteManager from '../../utils/RouteManager'
/**
* 首页顶部搜索导航栏
* 竖向滚动实现方案
... ... @@ -61,6 +62,9 @@ export struct FirstTabTopComponent{
.backgroundImage($r('app.media.top_search_bg'))
.backgroundImageSize(ImageSize.Cover)
.alignItems(VerticalAlign.Center)
.onClick(()=>{
RouteManager.jumpNewPage("pages/SearchPage")
})
Image($r('app.media.top_title_bg'))
.objectFit(ImageFit.Auto)
... ...
... ... @@ -62,13 +62,15 @@ export struct MinePageComponent {
//Grid 区域
MinePagePersonFunctionUI({personalData:$personalData})
//Card
MinePageCardUI()
// MinePageCardUI()
//创作者区域
MinePageCreatorFunctionUI({creatorData:$creatorData})
// MinePageCreatorFunctionUI({creatorData:$creatorData})
//更多功能
MinePageMoreFunctionUI({moreData:$moreData})
}.width('100%')
.height('100%')
.justifyContent(FlexAlign.Start)
}
@Styles setFullWidthAndHeight(){
... ...
import { CommonConstants, ViewType } from 'wdConstant';
import { CollectionUtils, Logger } from 'wdKit';
import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit';
import { CompDTO } from '../../repository/bean/CompDTO';
import PageViewModel from '../../viewmodel/PageViewModel';
import { EmptyComponent } from '../view/EmptyComponent';
... ... @@ -65,7 +65,9 @@ export struct PageComponent {
CompParser({ compDTO: compDTO, compIndex: compIndex });
}
}
})
},
(compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp
)
// 加载更多
ListItem() {
... ... @@ -136,6 +138,11 @@ export struct PageComponent {
} else {
this.pageModel.hasMore = false;
}
PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// 刷新,替换所有数据
this.pageModel.compList.replaceAll(...data)
this.pageModel.timestamp = DateTimeUtils.getCurrentTimeMillis().toString()
})
} else {
Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
this.pageModel.viewType = ViewType.EMPTY;
... ...
import router from '@ohos.router'
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils'
import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel'
import { SearchHistoryItem } from '../../../viewmodel/SearchHistoryItem'
import { SearchHistoryComponent } from './SearchHistoryComponent'
import { SearchHotsComponent } from './SearchHotsComponent'
const TAG = "SearchComponent"
@Component
export struct SearchComponent {
@State searchTextData: string[] = []
@State hasInputContent: boolean = false
@State hasChooseSearch: boolean = false
private swiperController: SwiperController = new SwiperController()
@State searchText: string = ''
controller: TextInputController = new TextInputController()
@State searchHistoryData: SearchHistoryItem[] = []
scroller: Scroller = new Scroller()
aboutToAppear() {
//获取提示滚动
this.getSearchHint()
//获取搜索历史
this.getSearchHistoryData()
}
getSearchHint() {
SearcherAboutDataModel.getSearchHintData(getContext(this)).then((value) => {
if (value != null) {
this.searchTextData = value
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
getSearchHistoryData() {
this.searchHistoryData = SearcherAboutDataModel.getSearchHistoryData()
}
build() {
Column() {
this.searchInputComponent()
if (!this.hasInputContent) {
Scroll(this.scroller) {
Column() {
SearchHistoryComponent({ searchHistoryData: $searchHistoryData })
//分隔符
Divider()
.width('100%')
.height('1lpx')
.color($r('app.color.color_EDEDED'))
.strokeWidth('1lpx')
SearchHotsComponent()
}
}
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
.padding({ left: '31lpx', right: '31lpx' })
} else {
if (this.hasChooseSearch) {
//搜索结果
//搜索结果为null(空布局 + 为你推荐)
} else {
//联想搜索
}
}
}.height('100%')
.width('100%')
}
//搜索框
@Builder searchInputComponent() {
Row() {
//左
Stack({ alignContent: Alignment.Start }) {
if (this.searchTextData != null && this.searchTextData.length > 0 && !this.hasInputContent) {
Swiper(this.swiperController) {
ForEach(this.searchTextData, (item: string, index: number) => {
Text(item)
.fontWeight('400lpx')
.fontSize('25lpx')
.fontColor($r('app.color.color_666666'))
.lineHeight('35lpx')
.textAlign(TextAlign.Start)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Clip })
.margin({ left: '40lpx' })
})
}
.loop(true)
.autoPlay(true)
.interval(3000)
.indicator(false)
.vertical(true)
.enabled(false)
.focusable(false)
}
TextInput({ text: this.searchText, placeholder: '', controller: this.controller })
.caretColor(Color.Pink)
.fontSize('27lpx')
.fontColor(Color.Black)
.onChange((value: string) => {
this.searchText = value
if (this.searchText.length > 0) {
this.hasInputContent = false
} else {
this.hasInputContent = true
}
})
.backgroundColor($r('app.color.color_transparent'))
}
.backgroundImage($r('app.media.search_page_input_bg'))
.backgroundImageSize(ImageSize.Cover)
.layoutWeight(1)
.height('69lpx')
//右
Text("取消")
.textAlign(TextAlign.Center)
.fontWeight('400lpx')
.fontSize('31lpx')
.lineHeight('58lpx')
.fontColor($r('app.color.color_222222'))
.width('125lpx')
.height('58lpx')
.onClick(() => {
router.back()
// SearcherAboutDataModel.putSearchHistoryData(this.searchText)
// if(StringUtils.isNotEmpty(this.searchText)){
// if(this.searchHistoryData.length===10){
// this.searchHistoryData.pop()
// }
// this.searchHistoryData.push(new SearchHistoryItem(this.searchText))
// }
})
}
.height('85lpx')
.padding({ left: '31lpx' })
.alignItems(VerticalAlign.Center)
.margin({ bottom: '36lpx' })
}
}
\ No newline at end of file
... ...
import { SearchHistoryItem } from '../../../viewmodel/SearchHistoryItem'
/**
* 搜索历史
*/
@Component
export struct SearchHistoryComponent{
@Link searchHistoryData:SearchHistoryItem[]
build(){
Column(){
Row(){
Text("搜索历史")
.textAlign(TextAlign.Center)
.fontWeight('400lpx')
.fontSize('27lpx')
.lineHeight('38lpx')
.fontColor($r('app.color.color_999999'))
.height('38lpx')
Image($r('app.media.search_delete_icon'))
.height('31lpx')
.width('31lpx')
.objectFit(ImageFit.Auto)
.onClick(()=>{
//清空记录
})
}.justifyContent(FlexAlign.SpaceBetween)
.margin({bottom:'17lpx'})
.width('100%')
Grid(){
ForEach(this.searchHistoryData,(item:SearchHistoryItem,index:number)=>{
GridItem(){
Row(){
Text(`${item.searchContent}`)
.height('23lpx')
.fontColor($r('app.color.color_222222'))
.fontSize('23lpx')
.maxLines(1)
.constraintSize({maxWidth:index%2 === 0?'270lpx':'250lpx'})
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textAlign(TextAlign.Start)
Image($r('app.media.search_item_delete_icon'))
.width('46lpx')
.height('46lpx')
.margin({right:'31lpx',left:'4lpx'})
.interpolation(ImageInterpolation.Medium)
.objectFit(ImageFit.Auto)
Blank()
if(index%2 === 0 && index != this.searchHistoryData.length-1 ){
Divider()
.width('2lpx')
.height('23lpx')
.color($r('app.color.color_CCCCCC'))
.strokeWidth('2lpx')
.vertical(true)
}
}.height('100%')
.alignItems(VerticalAlign.Center)
.width('100%')
.margin({left:index%2 === 1?'23lpx':'0lpx'})
}.onClick(()=>{
})
.height('46lpx')
})
}
.height(this.getCategoryViewHeight())
.rowsTemplate(this.getCategoryRowTmpl())
.columnsTemplate('1fr 1fr')
.rowsGap('23lpx')
}
.margin({bottom:'46lpx'})
}
getCategoryRowCount() {
return Math.ceil(this.searchHistoryData.length / 2);
}
getCategoryRowTmpl() {
const count = this.getCategoryRowCount();
const arr: string[] = new Array(count || 1).fill('1fr');
console.log('tmpl ', arr.join(' '))
return arr.join(' ');
}
getCategoryViewHeight() {
return `${46 * this.getCategoryRowCount()}lpx`;
}
}
\ No newline at end of file
... ...
import SearcherAboutDataModel from '../../../model/SearcherAboutDataModel'
import { SearchHotContentItem } from '../../../viewmodel/SearchHotContentItem'
const TAG = "SearchHotsComponent"
/**
* 热门搜索
*/
@Component
export struct SearchHotsComponent{
@State searchHotsData:SearchHotContentItem[] = []
aboutToAppear(){
//获取搜索热词
this.getSearchHotsData()
}
getSearchHotsData(){
SearcherAboutDataModel.getSearchHotsData(getContext(this)).then((value)=>{
if(value!=null){
this.searchHotsData = value
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
build(){
Column(){
Row() {
Image($r('app.media.search_hot_icon'))
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.margin({right:'8lpx'})
.interpolation(ImageInterpolation.Medium)
Text("热门搜索")
.textAlign(TextAlign.Center)
.fontWeight('600lpx')
.fontSize('33lpx')
.lineHeight('46lpx')
.fontColor($r('app.color.color_222222'))
.height('38lpx')
}
.width('100%')
List(){
ForEach(this.searchHotsData,(item:SearchHotContentItem,index:number)=>{
ListItem(){
Column(){
Column(){
Row(){
Row(){
if(item.sequence <=3){
Image(item.sequence===1?$r('app.media.search_hot_num1'):item.sequence===2?$r('app.media.search_hot_num2'):$r('app.media.search_hot_num3'))
.width('27lpx')
.height('35lpx')
.objectFit(ImageFit.Auto)
.margin({right:'12lpx'})
}else {
Text(`${item.sequence}`)
.height('31lpx')
.fontColor($r('app.color.color_666666'))
.fontSize('27lpx')
.fontWeight('400lpx')
.lineHeight('31lpx')
.margin({right:'12lpx'})
}
Text(`${item.hotEntry}`)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontColor($r('app.color.color_222222'))
.fontSize('31lpx')
.maxLines(1)
.fontWeight('400lpx')
.lineHeight('42lpx')
}.layoutWeight(1)
if(item.mark!=0){
Image(item.mark===1?$r('app.media.search_hots_mark1'):$r('app.media.search_hots_mark2'))
.width('42lpx')
.height('31lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.Medium)
}
}.alignItems(VerticalAlign.Center)
.height('84lpx')
.justifyContent(FlexAlign.SpaceBetween)
if(index != this.searchHotsData.length-1 ){
Divider()
.width('100%')
.height('1lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
}
}.height('108lpx')
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Start)
.padding({left:'27lpx'})
}
}
.onClick(()=>{
})
.height('117lpx')
})
}.onScrollFrameBegin((offset, state) => {
return { offsetRemain: 0 }
}).layoutWeight(1)
}.width('100%')
.height('100%')
.margin({top:'46lpx'})
}
}
\ No newline at end of file
... ...
... ... @@ -35,6 +35,8 @@ export struct BigPicCardComponent {
Column() {
Column() {
// TODO 测试代码
Text("likeNum " + this.contentDTO?.interactData?.likeNum)
//新闻标题
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize(17)
... ...
... ... @@ -3,6 +3,8 @@ import { Logger, ResourcesUtils } from 'wdKit';
import { ResponseDTO, WDHttp } from 'wdNetwork';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils } from '../network/HttpUrlUtils';
import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem';
import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem';
const TAG = "SearcherAboutDataModel"
/**
... ... @@ -10,6 +12,7 @@ const TAG = "SearcherAboutDataModel"
*/
class SearcherAboutDataModel{
private static instance: SearcherAboutDataModel;
searchHistoryData:SearchHistoryItem[] = []
private constructor() { }
... ... @@ -25,6 +28,53 @@ class SearcherAboutDataModel{
}
/**
* 静态搜索历史记录
*/
getSearchHistoryData():SearchHistoryItem[]{
if(this.searchHistoryData.length > 0){
return this.searchHistoryData
}
this.searchHistoryData.push(new SearchHistoryItem("评论"))
this.searchHistoryData.push(new SearchHistoryItem("关注关注"))
this.searchHistoryData.push(new SearchHistoryItem("收藏收藏收藏"))
this.searchHistoryData.push(new SearchHistoryItem("历史"))
this.searchHistoryData.push(new SearchHistoryItem("消息消息消息消息消息"))
this.searchHistoryData.push(new SearchHistoryItem("留言板留言板留言板留言板留言板"))
this.searchHistoryData.push(new SearchHistoryItem("预约"))
return this.searchHistoryData
}
// async putSearchHistoryData(content:string){
// let history = await SPHelper.default.get(SearcherAboutDataModel.SEARCH_HISTORY_KEY, '[]') as string;
// this.searchHistoryData = JSON.parse(history)
// this.searchHistoryData.push(new SearchHistoryItem(content))
// await SPHelper.default.save(SearcherAboutDataModel.SEARCH_HISTORY_KEY, JSON.stringify(this.searchHistoryData));
// }
// getSearchHistoryData():Promise<SearchHistoryItem[]>{
// return new Promise<SearchHistoryItem[]>(async (success, error) => {
// if(this.searchHistoryData!=null && this.searchHistoryData.length>0){
// success(this.searchHistoryData)
// return
// }
// try {
// let history = await SPHelper.default.get(SearcherAboutDataModel.SEARCH_HISTORY_KEY, '') as string;
// console.log('ycg',history);
// }catch (error){
// console.log('ycg',"1111");
// }
//
// this.searchHistoryData = JSON.parse(history)
// this.searchHistoryData.push(new SearchHistoryItem("评论"))
// this.searchHistoryData.push(new SearchHistoryItem("关注关注"))
// this.searchHistoryData.push(new SearchHistoryItem("收藏收藏收藏"))
//
// success(this.searchHistoryData)
// })
// }
/**
* 首页 搜索提示滚动内容
*/
getSearchHintData(context: Context): Promise<string[]> {
... ... @@ -62,6 +112,45 @@ class SearcherAboutDataModel{
return compRes.data
}
/**
* 搜索主页 热词
*/
getSearchHotsData(context: Context): Promise<SearchHotContentItem[]> {
return new Promise<SearchHotContentItem[]>((success, error) => {
Logger.info(TAG, `getSearchHintData start`);
this.fetchSearchHotsData().then((navResDTO: ResponseDTO<SearchHotContentItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getSearchHotsDataLocal(context))
return
}
Logger.info(TAG, "getSearchHotsData then,getSearchHotsData.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as SearchHotContentItem[]
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchHotsData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getSearchHotsDataLocal(context))
})
})
}
fetchSearchHotsData() {
let url = HttpUrlUtils.getSearchHotsDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.get<ResponseDTO<SearchHotContentItem[]>>(url, headers)
};
async getSearchHotsDataLocal(context: Context): Promise<SearchHotContentItem[]> {
Logger.info(TAG, `getSearchHotsDataLocal start`);
let compRes: ResponseDTO<SearchHotContentItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchHotContentItem[]>>('search_hots_data.json' ,context);
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchHotsDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getSearchHotsDataLocal compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
}
... ...
... ... @@ -121,6 +121,11 @@ export class HttpUrlUtils {
*/
static readonly SEARCH_HINT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hints";
/**
* 搜索主页 热词
*/
static readonly SEARCH_HOTS_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hots";
private static hostUrl: string = HttpUrlUtils.HOST_UAT;
static getCommonHeaders(): HashMap<string, string> {
... ... @@ -308,6 +313,10 @@ export class HttpUrlUtils {
return url
}
static getSearchHotsDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.SEARCH_HOTS_DATA_PATH
return url
}
/**
* 点赞操作
... ...
/**
* 批查接口查询互动相关数据,返回数据bean
*/
export interface InteractDataDTO {
export class InteractDataDTO {
collectNum: number;
commentNum: number;
contentId: string;
... ...
... ... @@ -4,6 +4,8 @@ import { RefreshConstants as Const, RefreshState } from './RefreshConstants';
import PageViewModel from '../viewmodel/PageViewModel';
import { PageDTO } from '../repository/bean/PageDTO';
import { touchMoveLoadMore, touchUpLoadMore } from './PullUpLoadMore';
import { CompDTO } from '../repository/bean/CompDTO';
import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils';
export function listTouchEvent(pageModel: PageModel, event: TouchEvent) {
switch (event.type) {
... ... @@ -73,6 +75,7 @@ export function touchUpPullRefresh(pageModel: PageModel) {
PageViewModel.getPageData(self)
.then((data: PageDTO) => {
self.timestamp = DateTimeUtils.getCurrentTimeMillis().toString()
if (data == null || data.compList == null || data.compList.length == 0) {
self.hasMore = false;
} else {
... ... @@ -84,6 +87,11 @@ export function touchUpPullRefresh(pageModel: PageModel) {
}
// 刷新,替换所有数据
self.compList.replaceAll(...data.compList)
PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => {
// 刷新,替换所有数据
self.compList.replaceAll(...data)
self.timestamp = DateTimeUtils.getCurrentTimeMillis().toString()
})
}
closeRefresh(self, true);
}).catch((err: string | Resource) => {
... ...
... ... @@ -3,6 +3,8 @@ import PageModel from '../viewmodel/PageModel';
import { RefreshConstants as Const } from './RefreshConstants';
import PageViewModel from '../viewmodel/PageViewModel';
import { PageDTO } from '../repository/bean/PageDTO';
import { CompDTO } from '../repository/bean/CompDTO';
import { DateTimeUtils } from 'wdKit';
export function touchMoveLoadMore(model: PageModel, event: TouchEvent) {
// list size +1
... ... @@ -38,7 +40,13 @@ export function touchUpLoadMore(model: PageModel) {
} else {
self.hasMore = false;
}
let sizeBefore = self.compList.size();
self.compList.push(...data.compList)
PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => {
// 刷新,替换所有数据
self.compList.updateItems(sizeBefore, data)
self.timestamp = DateTimeUtils.getCurrentTimeMillis().toString()
})
}
}).catch((err: string | Resource) => {
promptAction.showToast({ message: err });
... ...
... ... @@ -34,4 +34,6 @@ export default class PageModel {
isPullRefreshOperation = false;
isLoading: boolean = false;
isCanLoadMore: boolean = false;
// keyGenerator相关字符串,用于刷新list布局
timestamp: String = '1';
}
\ No newline at end of file
... ...
... ... @@ -40,7 +40,7 @@ export class PageViewModel extends BaseViewModel {
if (mock_switch) {
return this.getBottomNavDataMock(context);
}
return this.getNavData();
return this.getNavData(context);
}
async getBottomNavDataMock(context?: Context): Promise<NavigationBodyDTO> {
... ... @@ -54,12 +54,13 @@ export class PageViewModel extends BaseViewModel {
return compRes.data
}
private getNavData(): Promise<NavigationBodyDTO> {
private getNavData(context?: Context): Promise<NavigationBodyDTO> {
return new Promise<NavigationBodyDTO>((success, error) => {
Logger.info(TAG, `getNavData start`);
PageRepository.fetchNavigationDataApi().then((navResDTO: ResponseDTO<NavigationBodyDTO>) => {
if (this.isRespondsInvalid(navResDTO, 'getNavData')) {
error("page data invalid");
// error("page data invalid");
success(this.getBottomNavDataMock(context))
return
}
Logger.info(TAG, "getNavData then,navResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -147,14 +148,6 @@ export class PageViewModel extends BaseViewModel {
return;
}
success(resDTO.data);
// TODO 打开同步请求互动数据,待优化为异步加载
if (CollectionUtils.isEmpty(resDTO.data.compList)) {
success(resDTO.data);
} else {
this.getInteractData(resDTO.data.compList).then(() => {
success(resDTO.data);
})
}
})
.catch((err: Error) => {
Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`);
... ... @@ -249,7 +242,8 @@ export class PageViewModel extends BaseViewModel {
}
if (id == content.objectId) {
content.interactData = interactData;
content.interactData.likeNum = 109;
// TODO 测试代码,待删除
// content.interactData.likeNum = Math.floor(Math.random() * Math.floor(999));;
break outer;
}
}
... ...
export class SearchHistoryItem{
searchContent:string = ""
searchUserId:string = ""
searchTime:string = ""
constructor(searchContent: string,searchUserId?:string,searchTime?:string) {
this.searchContent = searchContent
this.searchUserId = searchUserId
this.searchTime = searchTime
}
}
\ No newline at end of file
... ...
export class SearchHotContentItem{
hotEntry:string = ""
mark:number = 0 //1 热 2 新
sequence:number = 0//序号
constructor(hotEntry: string , mark: number , sequence: number ) {
this.hotEntry = hotEntry
this.mark = mark
this.sequence = sequence
}
}
\ No newline at end of file
... ...
... ... @@ -254,4 +254,10 @@ export class LazyDataSource<T> extends BasicDataSource<T> {
sort(comparator: (firstValue: T, secondValue: T) => number): void {
this.dataArray.sort(comparator)
}
public updateItems(start: number, data: T[]): void {
// 从数组中的start位置开始删除dataArray.length个元素,并在同一位置插入((1个或多个))新元素。
this.dataArray.splice(start, this.dataArray.length, ...data);
this.notifyDataReload()
}
}
\ No newline at end of file
... ...
... ... @@ -19,8 +19,8 @@
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": "4.0.0(10)",
"compatibleSdkVersion": "4.0.0(10)",
"compileSdkVersion": "4.1.0(11)",
"compatibleSdkVersion": "4.1.0(11)",
"runtimeOS": "HarmonyOS",
}
],
... ...
... ... @@ -9,5 +9,14 @@ export class SpConstants{
static USER_LONG_TIME_NO_LOGIN_MARK="longTimeNoLoginMark"
static USER_STATUS="user_status"
static USER_TEMP_TOKEN="tempToken"
static USER_PHONE = "user_phone"
//协议相关
static USER_PROTOCOL = "user_protocol" //用户协议
static PRIVATE_PROTOCOL = "private_protocol" //隐私协议
//设置页面
static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关
static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关
static SETTING_SUSPENSION_SWITCH = "setting_suspension_switch" //悬浮窗 开关
static SETTING_PUSH_SWITCH = "setting_push_switch" //推送 开关
}
\ No newline at end of file
... ...
/**
* 组件Style/展示样式
*/
export const enum CompStyle {
Label_03 = 'Label-03', // 标题卡:icon+文字
Carousel_Layout_01 = 'Zh_Carousel_Layout-01', // 通用轮播卡:视频、直播、活动、专题、榜单、外链
Carousel_Layout_02 = 'Carousel_Layout-02', // 直播轮播卡:直播
Single_Row_01 = 'Zh_Single_Row-01', // 三格方形小卡(排名):专题、活动
Zh_Single_Row_01 = 'Zh_Single_Row-01', // 横划卡 imageScale-封面图比例 1-4:3, 2-16:9, 3-3:2
Single_Row_02 = 'Zh_Single_Row-02', // 通用横划卡:视频、直播、专题
Single_Row_03 = 'Single_Row-03', // 直播横划卡:直播
Single_Row_04 = 'Single_Row-04', // 三格方形小卡:专题、活动
... ... @@ -17,17 +15,52 @@ export const enum CompStyle {
Single_Column_04 = 'Single_Column-04', // 大卡横屏(带背景):视频、直播
Single_Column_05 = 'Single_Column-05', // 海报图卡:/
Single_Column_06 = 'Single_Column-06', // 留言板卡:/
Zh_Single_Column_02 = 'Zh_Single_Column-02', // 头图卡
Grid_Layout_01 = 'Grid_Layout-01', // 横屏宫格卡:视频、直播
Grid_Layout_02 = 'Grid_Layout-02', // 竖屏宫格卡:视频、直播、榜单
Masonry_Layout_01 = 'Masonry_Layout-01', // 双列瀑布流/瀑布流卡:视频、直播、专题、活动
Title_Abbr_01 = '11', // 标题缩略
Title_All_01 = '3', // 全标题
Single_ImageCard_03 = '13',//单图卡:3行标题
Single_ImageCard_01 = '6',//单图卡,竖图
ZhGrid_Layout_03 = 'Zh_Grid_Layout-03', //金刚位卡
Album_Card_01 = '17', //图卡集
Zh_Carousel_Layout_01 = 'Zh_Carousel_Layout-01', //1 轮播图卡
Zh_Single_Row_01 = 'Zh_Single_Row-01', //2 横划卡 imageScale-封面图比例 1-4:3, 2-16:9, 3-3:2
Zh_Single_Row_02 = 'Zh_Single_Row-02', //3 小视频横划卡
Zh_Single_Row_03 = 'Zh_Single_Row-03', //6 直播预约卡
Zh_Single_Row_04 = 'Zh_Single_Row-04', // 地方精选卡
CompStyle_09 = '9', // 时间链卡
CompStyle_10 = '10', // 大专题卡
Zh_Single_Row_05 = 'Zh_Single_Row-05', //15 人民号横划卡
Zh_Single_Row_06 = 'Zh_Single_Row-06', //20 热门评论卡--精选评论卡
Zh_Single_Column_01 = 'Zh_Single_Column-01', //5 专题时间链卡
Zh_Single_Column_02 = 'Zh_Single_Column-02', //10 头图卡
Zh_Single_Column_03 = 'Zh_Single_Column-03', //9 直播大图卡
Zh_Single_Column_04 = 'Zh_Single_Column-04', //17 人民号主题卡
Zh_Single_Column_05 = 'Zh_Single_Column-05', //16 人民号入驻卡
Zh_Single_Column_06 = 'Zh_Single_Column-06', //12 本地问政卡
Zh_Single_Column_07 = 'Zh_Single_Column-07', //14 热门留言卡
Zh_Single_Column_08 = 'Zh_Single_Column-08', //12 问政提问卡
Zh_Single_Column_10 = 'Zh_Single_Column-10', //18 服务组合卡
Zh_Single_Column_11 = 'Zh_Single_Column-11', //19 问政组合卡
Zh_Grid_Layout_01 = 'Zh_Grid_Layout-01', //4 信息流组合卡
Zh_Grid_Layout_02 = 'Zh_Grid_Layout-02', //7 双列流小视频,一行两图卡
Zh_Grid_Layout_03 = 'Zh_Grid_Layout-03', //11 金刚位卡
Card_01 = '1', // 小图卡
Card_02 = '2', // 大图卡
Card_03 = '3', // 无图卡(全标题)
Card_04 = '4', // 三图卡
Card_05 = '5', // 头图卡
Card_06 = '6', // 小视频卡
Card_07 = '7', // 作者卡
Card_08 = '8', // 财经快讯卡
Card_09 = '9', // 时间轴卡
Card_10 = '10', // 大专题卡
Card_11 = '11', // 无图卡(标题省略)
Card_12 = '12', // 无图卡人民号
Card_13 = '13', // 单图卡--同6
Card_14 = '14', // 单图卡人民号
Card_15 = '15', // 大图卡人民号
Card_16 = '16', // 三图卡人民号
Card_17 = '17', // 图卡集
Card_18 = '18', // 图卡集人民号
Card_19 = '19', // 动态图文卡人民号
Card_20 = '20', // 动态视频卡人民号
Card_21 = '21', // 小视频卡人民号
Card_22 = '22', // 时间链
Card_23 = '23', // 问政卡
}
... ...
... ... @@ -7,7 +7,7 @@ export class Message {
callbackId: string = ""; //callbackId
responseId: string = ""; //responseId
responseData: string = ""; //responseData
data?: Action; //data of message
data?: object; //data of message
handlerName: string = ""; //name of handler
/**
... ...
import { Action } from '../bean/Action'
import { Message } from '../bean/Message'
/**
* 注册回调接口
*/
export type Callback = (data: string) => void
export interface BridgeHandler {
handle: (data: Action, f: Callback) => void
export interface BridgeHandler {
handle: (data: Message, f: Callback) => void
}
export class DefaultBridgeHandler implements BridgeHandler {
handle(data: Action, f: Callback) {
handle(data: Message, f: Callback) {
//1,2.3
f("DefaultHandler response data")
}
... ...
... ... @@ -5,6 +5,9 @@ import { BridgeUtil } from '../utils/BridgeUtil';
import { Message } from '../bean/Message';
import { CallBackMessage } from '../bean/CallBackMessage';
import { StringUtils } from '../utils/StringUtils';
import hilog from '@ohos.hilog';
// import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG = 'BridgeWebViewControl';
... ... @@ -47,6 +50,7 @@ export class BridgeWebViewControl extends webview.WebviewController {
* 刷新消息
*/
flushMessageQueue() {
hilog.error(0xFF00, TAG, 'flushMessageQueue');
this.loadUrlCustom(BridgeUtil.JS_FETCH_QUEUE_FROM_JAVA, (data: string) => {
let list: Array<Message> = JSON.parse(data)
if (list == null || list.length == 0) {
... ... @@ -66,11 +70,13 @@ export class BridgeWebViewControl extends webview.WebviewController {
} else {
let responseFunction: Callback;
let callbackId: string = value.callbackId
let handlerName: string = value.handlerName
if (StringUtils.isNotEmpty(callbackId)) {
responseFunction = (data: string) => {
let msg: CallBackMessage = new CallBackMessage()
msg.responseId = callbackId
msg.responseData = data
msg.handlerName = handlerName
this.queueMessage(msg)
}
} else {
... ... @@ -86,7 +92,7 @@ export class BridgeWebViewControl extends webview.WebviewController {
handle = new DefaultBridgeHandler()
}
if (handle != undefined && value.data != undefined) {
handle.handle(value.data, responseFunction)
handle.handle(value, responseFunction)
}
}
})
... ... @@ -107,12 +113,15 @@ export class BridgeWebViewControl extends webview.WebviewController {
*/
private dispatchMessage(msg: CallBackMessage) {
let messageJson: string = msg.toJson()
hilog.error(0xFF00, TAG, 'dispatchMessage '+ messageJson);
// messageJson = messageJson.replace("%7B", encodeURIComponent("%7B"));
// messageJson = messageJson.replace("%7D", encodeURIComponent("%7D"));
// messageJson = messageJson.replace("%22", encodeURIComponent("%22"));
let javascriptCommand: string = StringUtils.formatStringForJS(BridgeUtil.JS_HANDLE_MESSAGE_FROM_JAVA, messageJson);
this.runJavaScript(javascriptCommand)
this.runJavaScript(javascriptCommand).then((res)=>{
hilog.error(0xFF00, TAG, 'dispatchMessage res: '+ res);
})
}
/**
... ...
... ... @@ -34,4 +34,8 @@ export { PermissionUtil } from './src/main/ets/utils/PermissionUtil'
export { UserDataLocal } from './src/main/ets/utils/UserDataLocal'
export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils'
\ No newline at end of file
export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils'
// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils'
export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils'
\ No newline at end of file
... ...
import { cryptoFramework } from '@kit.CryptoArchitectureKit';
import { util } from '@kit.ArkTS';
const TAG: string = '[AesUtils]'
/**
* ASE密钥 TODO 示例密钥,业务需要按实际密钥修改
*/
const AES_ENCRYPT_KEY: string = '5QXzAbJj0TJN9OQNvxFhhw==';
const AES128: string = 'AES128';
const AES128_ECB_PKCS5: string = 'AES128|ECB|PKCS5'; // 'AES128|PKCS5';
/**
* AES加密/解密
*/
export class AesUtils {
static stringToUint8Array(str: string) {
let arr: number[] = new Array();
for (let i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
let tmpArray = new Uint8Array(arr);
return tmpArray;
}
static uint8ArrayToString(array: Uint8Array): string {
let arrayString = '';
for (let i = 0; i < array.length; i++) {
arrayString += String.fromCharCode(array[i]);
}
return arrayString;
}
/**
* aes加密
* @param message
* @param callback
*/
static async aesEncrypt(message: string, secretKey?: string): Promise<string> {
// Logger.debug(TAG, `aesEncrypt message: ${message}`);
// 组装convertKey所需的二进制密钥数据
let base64Helper = new util.Base64Helper();
let pubKey = base64Helper.decodeSync(secretKey ?? AES_ENCRYPT_KEY); // AES密钥
let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKey };
// 创建对称密钥生成器
let aesGenerator = cryptoFramework.createSymKeyGenerator(AES128);
// 转换/生成对称密钥对象
let symKey: cryptoFramework.SymKey = await aesGenerator.convertKey(pubKeyBlob)
// 生成加解密生成器
let cipher = cryptoFramework.createCipher(AES128_ECB_PKCS5);
// 初始化加密
await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null)
// 封装加密所需数据
let input: cryptoFramework.DataBlob = { data: AesUtils.stringToUint8Array(message) };
// 当数据量较小时,可以在init完成后直接调用doFinal
// 当数据量较大时,可以多次调用update,即分段加解密。
let output: cryptoFramework.DataBlob = await cipher.doFinal(input)
// Logger.info(TAG, "aesEncrypt output.data is " + output.data);
let result = base64Helper.encodeToStringSync(output?.data)
// Logger.info(TAG, "aesEncrypt result is " + result);
return result;
}
/**
* aes解密
* @param message
* @param callback
*/
static async aesDecrypt(message: string, secretKey?: string): Promise<string> {
// Logger.debug(TAG, `aesDecrypt message: ${message}`);
// 组装convertKey所需的二进制密钥数据
let base64Helper = new util.Base64Helper();
let pubKey = base64Helper.decodeSync(secretKey ?? AES_ENCRYPT_KEY); // AES密钥
let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKey };
// 创建对称密钥生成器
let aesGenerator = cryptoFramework.createSymKeyGenerator(AES128);
// 转换/生成对称密钥对象
let symKey: cryptoFramework.SymKey = await aesGenerator.convertKey(pubKeyBlob)
// 生成加解密生成器
let cipher = cryptoFramework.createCipher(AES128_ECB_PKCS5);
// 初始化加密
await cipher.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, null)
// 封装加密所需数据
let newMessage = base64Helper.decodeSync(message);
let input: cryptoFramework.DataBlob = { data: newMessage };
// 当数据量较小时,可以在init完成后直接调用doFinal
// 当数据量较大时,可以多次调用update,即分段加解密。
let output: cryptoFramework.DataBlob = await cipher.doFinal(input)
// Logger.debug(TAG, "aesDecrypt is output.data " + output?.data);
let result = AesUtils.uint8ArrayToString(output?.data)
// Logger.debug(TAG, "aesDecrypt result is " + result);
return result
}
}
\ No newline at end of file
... ...
... ... @@ -25,11 +25,11 @@ export class CollectionUtils {
* @returns {boolean} true(empty)
*/
static isEmpty(collection?: any[]): boolean {
return !collection || collection.length === 0;
return!collection || collection.length === 0;
}
static isEmptyList<T>(list1?: LinkList<T>): boolean {
return !list1 || list1.length === 0;
return!list1 || list1.length === 0;
}
static isEmptyHashMap(obj?: HashMap<any, any>): boolean {
... ... @@ -65,6 +65,13 @@ export class CollectionUtils {
return collection.length > 0;
}
static getElement(collection?: any[], index?: number): any {
if (CollectionUtils.isEmpty(collection) || index === undefined) {
return null;
}
return index >= 0 && index < collection.length ? collection[index] : null;
}
static getListSize(collection?: any[]): number {
return CollectionUtils.isEmpty(collection) ? 0 : collection.length;
}
... ... @@ -179,5 +186,6 @@ export class CollectionUtils {
ss;
return collection.slice(start, end);
}
}
... ...
... ... @@ -466,6 +466,20 @@ export class DateTimeUtils {
static getLunar(_date?: string) {
return getLunar(_date)
}
/**
* 获取指定日期的时间戳
* @returns
*/
static getDateTimestamp(date: string): number {
if (StringUtils.isEmpty(date))
return 0
try {
return new Date(date).getTime()
} catch (e) {
return 0
}
}
}
// const dateTimeUtils = new DateTimeUtils()
\ No newline at end of file
... ...
import { ToastUtils } from './ToastUtils'
export namespace ErrorToastUtils {
export enum ErrorType {
NET_CORE_NO_NETWORK, //当前无网络,请重试
NET_CORE_WEAK_NETWORK, //当前无网络,请重试
NET_CORE_PAGE_ERROR_NETWORK, //网络出小差了,请检查网络后重试
NET_CORE_LOAD_ERROR_NETWORK, //加载失败,请重试
NET_CORE_ENTER_ERROR_NETWORK, //很抱歉,当前内容无法加载,请点击重试
LIVE_CORE_NO_NETWORK, //网络出小差了,请检查下网络
}
export class ErrorToast {
static showToast(type: ErrorType) {
switch (type) {
case ErrorType.NET_CORE_NO_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_no_network'))
break
case ErrorType.NET_CORE_WEAK_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_no_network'))
break
case ErrorType.NET_CORE_PAGE_ERROR_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_page_error_network'))
break
case ErrorType.NET_CORE_LOAD_ERROR_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_load_fail_network'))
break
case ErrorType.NET_CORE_ENTER_ERROR_NETWORK:
ToastUtils.shortToast($r('app.string.net_core_enter_fail_network'))
break
case ErrorType.LIVE_CORE_NO_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_no_network'))
break
}
}
}
}
... ...
... ... @@ -39,6 +39,10 @@ export class LazyDataSource<T> extends BasicDataSource<T> {
return this.getData(this.totalCount() - 1);
}
public size(): number {
return this.dataArray.length
}
// 获取所有数据
public getDataArray(): T[] {
return this.dataArray;
... ... @@ -276,4 +280,10 @@ export class LazyDataSource<T> extends BasicDataSource<T> {
public sort(comparator: (firstValue: T, secondValue: T) => number): void {
this.dataArray.sort(comparator)
}
public updateItems(start: number, data: T[]): void {
// 从数组中的start位置开始删除dataArray.length个元素,并在同一位置插入((1个或多个))新元素。
this.dataArray.splice(start, this.dataArray.length, ...data);
this.notifyDataReload()
}
}
\ No newline at end of file
... ...
... ... @@ -22,6 +22,7 @@ export class Logger {
private static domain: number = 0xFF00;
private static prefix: string = 'SightApp';
private static format: string = `%{public}s, %{public}s`;
static isDebug: boolean = true;
/**
* constructor.
... ... @@ -35,26 +36,44 @@ export class Logger {
}
static debug(...args: string[]) {
if(!Logger.isDebug){
return
}
hilog.debug(Logger.domain, Logger.prefix, Logger.format, args);
}
static info(...args: string[]) {
if(!Logger.isDebug){
return
}
hilog.info(Logger.domain, Logger.prefix, Logger.format, args);
}
static warn(...args: string[]) {
if(!Logger.isDebug){
return
}
hilog.warn(Logger.domain, Logger.prefix, Logger.format, args);
}
static error(...args: string[]) {
if(!Logger.isDebug){
return
}
hilog.error(Logger.domain, Logger.prefix, Logger.format, args);
}
static fatal(...args: string[]) {
if(!Logger.isDebug){
return
}
hilog.fatal(Logger.domain, Logger.prefix, Logger.format, args);
}
static isLoggable(level: LogLevel) {
if(!Logger.isDebug){
return
}
hilog.isLoggable(Logger.domain, Logger.prefix, level);
}
}
... ...
... ... @@ -8,7 +8,7 @@ export class NumberFormatterUtils {
*/
static formatNumberWithWan(inputNumber: number | String): string {
const num = typeof inputNumber === 'number' ? inputNumber : Number(inputNumber);
if (isNaN(num) || num < 10000) {
if (Number.isNaN(num) || num < 10000) {
return num.toString();
} else {
const wanUnit = num / 10000;
... ...
// import { abilityAccessCtrl, bundleManager, common, Permissions, Want } from '@kit.AbilityKit'
// import { BusinessError } from '@kit.BasicServicesKit'
// import { AppUtils } from './AppUtils'
// import { Logger } from './Logger'
//
// /**
// * 权限工具类
// * */
// export class PermissionUtils {
// //相机权限
// static CAMERA: Permissions = 'ohos.permission.CAMERA'
// //文件权限
// static READ_MEDIA: Permissions = 'ohos.permission.READ_MEDIA'
// static WRITE_MEDIA: Permissions = 'ohos.permission.WRITE_MEDIA'
// private static tokenId: number = 0
//
// /**检查权限是否授权*/
// static async checkPermissions(permission: Permissions): Promise<boolean> {
// let hasPermissions = false;
// let grantStatus: abilityAccessCtrl.GrantStatus = await PermissionUtils.checkAccessToken(permission);
//
// if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
// // 已经授权,可以继续访问目标操作
// hasPermissions = true;
// } else {
// hasPermissions = false;
// // 申请日历权限
// }
// return hasPermissions;
// }
//
// /**动态申请权限*/
// static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): Promise<boolean> {
//
// return new Promise((resolve, fail) => {
// let context = getContext(component) as common.UIAbilityContext;
// let atManager = abilityAccessCtrl.createAtManager();
// atManager.requestPermissionsFromUser(context, permissions).then((data) => {
// let grantStatus: Array<number> = data.authResults;
// let length: number = grantStatus.length;
//
// for (let i = 0; i < length; i++) {
// if (grantStatus[i] === 0) {
// // 用户授权,可以继续访问目标操作
// resolve(true);
// } else {
// resolve(false)
// }
// }
// }).catch((err: Error) => {
// fail(err)
// })
// });
// }
//
// /**跳转设置页面*/
// static openPermissionsInSystemSettings(context: Object): void {
// let uiContext = getContext(context) as common.UIAbilityContext;
// let wantInfo: Want = {
// bundleName: 'com.huawei.hmos.settings',
// abilityName: 'com.huawei.hmos.settings.MainAbility',
// uri: 'application_info_entry',
// parameters: {
// pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面
// }
// }
// uiContext.startAbility(wantInfo)
// }
//
// private static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
// let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
// let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;
//
// // 获取应用程序的accessTokenID
// if (PermissionUtils.tokenId == 0) {
// try {
// let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
// let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
// PermissionUtils.tokenId = appInfo.accessTokenId;
// } catch (error) {
// const err: BusinessError = error as BusinessError;
// }
// }
// // 校验应用是否被授予权限
// try {
// grantStatus = await atManager.checkAccessToken(PermissionUtils.tokenId, permission);
// } catch (error) {
// const err: BusinessError = error as BusinessError;
// }
//
// return grantStatus;
// }
//
// }
\ No newline at end of file
... ...
... ... @@ -15,15 +15,17 @@ export class Size {
export class WindowModel {
private windowStage?: window.WindowStage;
static shared: WindowModel = new WindowModel()
static TAG = "WindowModel";
setWindowStage(windowStage: window.WindowStage) {
this.windowStage = windowStage;
}
getWindowStage(): window.WindowStage {
return this.windowStage as window.WindowStage
}
setMainWindowFullScreen(fullScreen: boolean) {
if (deviceInfo.deviceType != "phone") {
return
... ... @@ -65,10 +67,10 @@ export class WindowModel {
windowClass.setWindowKeepScreenOn(isKeepScreenOn, (err: BusinessError) => {
const errCode: number = err.code;
if (errCode) {
console.error(WindowModel.TAG +'设置屏幕常亮:' + isKeepScreenOn + ',失败: ' + JSON.stringify(err));
console.error(WindowModel.TAG + '设置屏幕常亮:' + isKeepScreenOn + ',失败: ' + JSON.stringify(err));
return;
}
console.info(WindowModel.TAG +'设置屏幕常亮:' + isKeepScreenOn + ",成功");
console.info(WindowModel.TAG + '设置屏幕常亮:' + isKeepScreenOn + ",成功");
})
})
}
... ...
... ... @@ -3,6 +3,30 @@
{
"name": "shared_desc",
"value": "全局工具包"
} ,
{
"name": "net_core_no_network",
"value": "当前无网络,请重试"
} ,
{
"name": "net_core_weak_network",
"value": "当前无网络,请重试"
} ,
{
"name": "net_core_page_error_network",
"value": "网络出小差了,请检查下网络"
},
{
"name": "net_core_load_fail_network",
"value": "加载失败,请重试"
},
{
"name": "net_core_enter_fail_network",
"value": "很抱歉,当前内容无法加载,请点击重试"
},
{
"name": "live_core_no_network",
"value": "网络出小差了,请检查下网络"
}
]
}
\ No newline at end of file
... ...
... ... @@ -98,9 +98,12 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
// console.log(error.request)
// console.log(error.response)
// 这里用来处理http常见错误,进行全局提示
let message = buildErrorMsg(error.response?.status);
// 错误消息可以使用全局弹框展示出来
console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
if(error!=null && error.response!=null ){
let message = buildErrorMsg(error.response.status);
// 错误消息可以使用全局弹框展示出来
console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
}
return Promise.reject(error);
}
);
... ...
... ... @@ -35,6 +35,10 @@ export class HttpUrlUtils {
*/
static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
/**
* 展现comp接口(推荐)
*/
static readonly COMP_REC_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
/**
* 详情页面详情接口
*/
static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
... ... @@ -100,10 +104,14 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_editUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/editUserDetail";
/**
* 资料编辑 更新普通用户名
* 资料编辑 更新普通用户名(用户名、身份证号、邮箱、手机号修改url)
*/
static readonly APPOINTMENT_editUserDetail1_PATH: string = "/api/rmrb-user-center/user/zh/c/completeUserInfo";
/**
* 资料编辑 地区拉取
*/
static readonly APPOINTMENT_userArea_PATH: string = "/api/rmrb-content-center/c/service/sys-area/treeselect";
/**
/**
* 个人中心 关注列表详情
*/
... ... @@ -127,7 +135,11 @@ export class HttpUrlUtils {
/**
* 我的收藏
*/
static readonly APPOINTMENT_MyCollectionList_PATH: string = "/api/rmrb-interact/content/zh/c/interact";
static readonly APPOINTMENT_MyCollectionList_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/interact";
/**
* 收藏/取消收藏 status :收藏状态 1添加收藏 0取消收藏
*/
static readonly APPOINTMENT_ExecuteCollcet_PATH: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 个人中心 我的评论列表
*/
... ... @@ -169,6 +181,40 @@ export class HttpUrlUtils {
*/
static readonly FOLLOW_OPERATION_PATH: string = "/api/rmrb-interact/interact/zh/c/attention/operation";
/**
* 首页 搜索提示
*/
static readonly SEARCH_HINT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hints";
/**
* 搜索主页 热词
*/
static readonly SEARCH_HOTS_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hots";
/**
* 搜索联想词
*/
static readonly RELATED_SEARCH_CONTENT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/suggestions/";
/**
* 直播详情
*/
static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
/**
* 直播详情-直播间列表
*/
static readonly LIVE_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/video/list";
/**
* 直播详情-大家聊列表
*/
static readonly LIVE_CHAT_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/chat/list";
/**
* 搜索结果 显示tab 数
*/
static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword=";
/**
* 早晚报列表
* 根据页面id获取页面楼层列表
* https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927
... ... @@ -179,7 +225,19 @@ export class HttpUrlUtils {
* */
static readonly MORNING_EVENING_PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo";
static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
/**
* 直播回顾
* */
static readonly LIVE_REVIEW_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/channel/live/reviewList"; //?pageNum=1&pageSize=20
/**
* 早晚报获取PAGEID
* */
static readonly DAILY_PAPER_TOPIC: string = "/api/rmrb-bff-display-zh/display/zh/c/dailyPaperTopic";
private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
/**
* 推荐列表
*/
static readonly RECOMMEND_LIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list";
public static set hostUrl(value: string) {
HttpUrlUtils._hostUrl = value;
... ... @@ -420,11 +478,17 @@ export class HttpUrlUtils {
return url;
}
static getAgreement() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-bff-display-zh/display/zh/c/agreement";
return url;
}
static getCheckVerifyByTokenCodeUrl() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCodeByToken";
return url;
}
/*优质评论页*/
static getQualityCommentUrl() {
let url = HttpUrlUtils._hostUrl + "api/rmrb-comment/comment/zh/c/highQuality"
... ... @@ -438,6 +502,17 @@ export class HttpUrlUtils {
}
//账户注销
static accountLogoutUrl() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/logoff";
return url;
}
//更换手机号绑定
static changeBindPhone() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/userPhoneChange";
return url;
}
static getAppointmentListDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH
... ... @@ -445,7 +520,12 @@ export class HttpUrlUtils {
}
static getMyCollectionListDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.APPOINTMENT_MyCollectionList_PATH
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_MyCollectionList_PATH
return url
}
static getExecuteCollcetUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH
return url
}
... ... @@ -524,6 +604,40 @@ export class HttpUrlUtils {
return url
}
static getSearchHintDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_HINT_DATA_PATH
return url
}
static getSearchHotsDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.SEARCH_HOTS_DATA_PATH
return url
}
static getRelatedSearchContentDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.RELATED_SEARCH_CONTENT_DATA_PATH
return url
}
static getLiveDetailsUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH
return url
}
static getLiveListUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_LIST_PATH
return url
}
static getLiveChatListUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_CHAT_LIST_PATH
return url
}
static getSearchResultCountDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH
return url
}
// static getYcgCommonHeaders(): HashMap<string, string> {
// let headers: HashMap<string, string> = new HashMap<string, string>()
... ...
import ArrayList from '@ohos.util.ArrayList';
import { Action } from 'wdBean'
import { WDRouterPage } from './WDRouterPage'
import { Action } from 'wdBean';
import { WDRouterPage } from './WDRouterPage';
interface HandleObject {
handle: (action: Action) => (WDRouterPage | undefined)
... ... @@ -49,11 +49,16 @@ export function registerRouter() {
// })
Action2Page.register("JUMP_DETAIL_PAGE", (action: Action) => {
// if (action.params?.detailPageType == 2 || action.params?.detailPageType == 6) {
// return WDRouterPage.detailPlayLivePage
// }
if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) {
if (action.params?.detailPageType == 2 || action.params?.detailPageType == 6) {
return WDRouterPage.detailPlayLivePage
} else if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) {
return WDRouterPage.detailVideoListPage
}else if(action.params?.detailPageType == 9){
//图集详情页
return WDRouterPage.multiPictureDetailPage
}else if(action.params?.detailPageType == 14 || action.params?.detailPageType == 15){
//动态详情页
return WDRouterPage.dynamicDetailPage
} else if (action.params?.detailPageType == 17) {
return WDRouterPage.multiPictureDetailPage
} else if (action.params?.detailPageType == 13) {
... ...
... ... @@ -9,7 +9,7 @@ export class WDRouterPage {
this.pagePath = pagePath
}
static getBundleInfo(){
static getBundleInfo() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${"phone"}/${"ets/pages/MainPage"}`
}
... ... @@ -35,6 +35,8 @@ export class WDRouterPage {
// 短视频详情页
static detailVideoListPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailVideoListPage");
static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage");
static VideoChannelDetail = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/VideoChannelDetail");
static LottieViewDemo = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/LottieViewDemo");
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
// 直播详情页
... ... @@ -43,6 +45,8 @@ export class WDRouterPage {
static multiPictureDetailPage = new WDRouterPage("phone", "ets/pages/detail/MultiPictureDetailPage");
// 音乐详情页
static audioDetail = new WDRouterPage("phone", "ets/pages/detail/AudioDetail");
// 动态详情页
static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
... ... @@ -68,22 +72,23 @@ export class WDRouterPage {
static aboutPage = new WDRouterPage("wdComponent", "ets/components/page/SettingAboutPage");
// 设置页
static settingPage = new WDRouterPage("wdComponent", "ets/components/page/SettingPage");
// 设置页
static logoutPage = new WDRouterPage("wdComponent", "ets/components/setting/LogoutPage");
// 设置密码页、设置手机号页等等 (需要传参)
static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage");
//其他普通用户 主页
static otherNormalUserHomePagePage = new WDRouterPage("wdComponent", "ets/pages/OtherNormalUserHomePage");
static guidePage = new WDRouterPage("wdLogin", "ets/pages/guide/GuidePages");
//隐私政策页面
static privacyPage = new WDRouterPage("phone", "ets/pages/launchPage/PrivacyPage");
//启动广告页面
static launchAdvertisingPage = new WDRouterPage("phone", "ets/pages/launchPage/LaunchAdvertisingPage");
//主页
static mainPage = new WDRouterPage("phone", "ets/pages/MainPage");
// static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
//播报页面
static broadcastPage = new WDRouterPage("phone", "ets/pages/broadcast/BroadcastPage");
//搜索主页
static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage");
}
... ...
import bundleManager from '@ohos.bundle.bundleManager'
export class WDRouterPage {
private moduleName: string
private pagePath: string
constructor(moduleName: string, pagePath: string) {
this.moduleName = moduleName
this.pagePath = pagePath
}
url() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${this.moduleName}/${this.pagePath}`
}
// 主页
static index = new WDRouterPage("phone", "ets/pages/Index");
// 关于页面
// static aboutPage = new WDRouterPage("entry", "ets/pages/about/AboutPage");
// web默认页面
static defaultWebPage = new WDRouterPage("phone", "ets/pages/web/DefaultWebPage");
// 电子报页面
static eNewspaper = new WDRouterPage("phone", "ets/pages/ENewspaper")
// 早晚报页面
static morningEveningPaperPage = new WDRouterPage("phone", "ets/pages/MorningEveningPaperPage")
// 图文详情页
static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage");
// 短视频详情页
static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage");
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
// 直播详情页
static detailPlayLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLivePage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
//我的 关注
static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage");
//资料编辑
static editUserInfoPage = new WDRouterPage("wdComponent", "ets/components/page/EditUserInfoPage");
//修改昵称
static editUserNikeNamePage = new WDRouterPage("wdComponent", "ets/components/page/EditUserNikeNamePage");
//修改简介
static editUserIntroductionPage = new WDRouterPage("wdComponent", "ets/components/page/EditUserIntroductionPage");
static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
}
import bundleManager from '@ohos.bundle.bundleManager'
export class WDRouterPage {
private moduleName: string
private pagePath: string
constructor(moduleName: string, pagePath: string) {
this.moduleName = moduleName
this.pagePath = pagePath
}
url() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${this.moduleName}/${this.pagePath}`
}
// 主页
static index = new WDRouterPage("phone", "ets/pages/Index");
// 关于页面
// static aboutPage = new WDRouterPage("entry", "ets/pages/about/AboutPage");
// web默认页面
static defaultWebPage = new WDRouterPage("phone", "ets/pages/web/DefaultWebPage");
// 电子报页面
static eNewspaper = new WDRouterPage("phone", "ets/pages/ENewspaper")
// 早晚报页面
static morningEveningPaperPage = new WDRouterPage("phone", "ets/pages/MorningEveningPaperPage")
// 图文详情页
static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage");
// 短视频详情页
static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage");
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
// 直播详情页
static detailPlayLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLivePage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
//我的 关注
static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage");
}
import bundleManager from '@ohos.bundle.bundleManager'
export class WDRouterPage {
private moduleName: string
private pagePath: string
constructor(moduleName: string, pagePath: string) {
this.moduleName = moduleName
this.pagePath = pagePath
}
url() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${this.moduleName}/${this.pagePath}`
}
// 主页
static index = new WDRouterPage("phone", "ets/pages/Index");
// 关于页面
// static aboutPage = new WDRouterPage("entry", "ets/pages/about/AboutPage");
// web默认页面
static defaultWebPage = new WDRouterPage("phone", "ets/pages/web/DefaultWebPage");
// 电子报页面
static eNewspaper = new WDRouterPage("phone", "ets/pages/ENewspaper")
// 早晚报页面
static morningEveningPaperPage = new WDRouterPage("phone", "ets/pages/MorningEveningPaperPage")
// 图文详情页
static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage");
// 短视频详情页
static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage");
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
// 直播详情页
static detailPlayLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLivePage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
//我的 关注
static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage");
//资料编辑
static editUserInfoPage = new WDRouterPage("wdComponent", "ets/components/page/EditUserInfoPage");
//修改昵称
static editUserNikeNamePage = new WDRouterPage("wdComponent", "ets/components/page/EditUserNikeNamePage");
//修改简介
static editUserIntroductionPage = new WDRouterPage("wdComponent", "ets/components/page/EditUserIntroductionPage");
}
import bundleManager from '@ohos.bundle.bundleManager'
export class WDRouterPage {
private moduleName: string
private pagePath: string
constructor(moduleName: string, pagePath: string) {
this.moduleName = moduleName
this.pagePath = pagePath
}
url() {
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT)
return `@bundle:${bundleInfo.name}/${this.moduleName}/${this.pagePath}`
}
// 主页
static index = new WDRouterPage("phone", "ets/pages/Index");
// 关于页面
// static aboutPage = new WDRouterPage("entry", "ets/pages/about/AboutPage");
// web默认页面
static defaultWebPage = new WDRouterPage("phone", "ets/pages/web/DefaultWebPage");
// 电子报页面
static eNewspaper = new WDRouterPage("phone", "ets/pages/ENewspaper")
// 早晚报页面
static morningEveningPaperPage = new WDRouterPage("phone", "ets/pages/MorningEveningPaperPage")
// 图文详情页
static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage");
// 短视频详情页
static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage");
// 点播详情页
static detailPlayVodPage = new WDRouterPage("wdDetailPlayVod", "ets/pages/DetailPlayVodPage");
// 直播详情页
static detailPlayLivePage = new WDRouterPage("wdDetailPlayLive", "ets/pages/DetailPlayLivePage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
//我的 关注
static followListPage = new WDRouterPage("wdComponent", "ets/components/page/FollowListPage");
static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
}
/**
* h5调用native,事件id枚举,
* h5主动调用app方法
*/
export class H5CallNativeType {
static JsCallTypeList: string[] = []
static jsCall_currentPageOperate = 'jsCall_currentPageOperate'
static jsCall_getAppPublicInfo = 'jsCall_getAppPublicInfo'
static jsCall_getArticleDetailBussinessData = 'jsCall_getArticleDetailBussinessData'
static jsCall_callAppService = 'jsCall_callAppService'
// TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。
static init() {
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_currentPageOperate)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppPublicInfo)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getArticleDetailBussinessData)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_callAppService)
}
}
... ...
import { Action } from 'wdBean';
import { Callback } from 'wdJsBridge';
import { Callback, BridgeWebViewControl } from 'wdJsBridge';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger, StringUtils, } from 'wdKit';
// import { AccountManagerUtils, ILoginService, Logger, ServiceManager, StringUtils, UserBean, UserInfo } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { H5CallNativeType } from './H5CallNativeType';
// import { wdMenc } from 'wdMenc';
const TAG = 'JsBridgeBiz'
/**
* h5调用native代码
* @param data
* @param call
*/
export function performJSCallNative(data: Action, call: Callback) {
// if (data.name == "GET_PROMOTION_SIGN") {
// wdMenc.getActivitySign(data.params?.intfId, (sign) => {
// if (sign) {
// call(JSON.stringify(sign));
// } else {
// call("")
// }
// })
// return
// }
//TODO 数据校验
switch (data.type) {
//获取用户信息
case "GET_USER_INFO":
//测试环境
// call(JSON.stringify(getTestUserBean()))
// let isLogin = AccountManagerUtils.isLoginSync()
// Logger.info("WebComponent", `GET_USER_INFO#:::refresh==` + isLogin);
//
// if (isLogin) {
// const loginService = ServiceManager.getService(ILoginService.name) as ILoginService.Service
// let userBean: UserBean = loginService.getUserBean()
// // userBean.userInfo = JSON.stringify(loginService.getUserInfo())
// call(JSON.stringify(userBean))
// } else {
// call("fail")
// }
export function performJSCallNative(data: Message, call: Callback) {
Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + data.data)
switch (data.handlerName) {
case H5CallNativeType.jsCall_currentPageOperate:
break;
case H5CallNativeType.jsCall_getAppPublicInfo:
// h5获取app配置信息
call(getAppPublicInfo())
break;
case H5CallNativeType.jsCall_getArticleDetailBussinessData:
break;
case H5CallNativeType.jsCall_callAppService:
break;
case "JUMP_DETAIL_PAGE":
WDRouterRule.jumpWithAction(data)
case 'changeNativeMessage':
call("this is change Web Message")
break;
case "JUMP_INNER_NEW_PAGE":
WDRouterRule.jumpWithAction(data)
break
case "GET_DEVICE_DATA":
break
//用户登陆
case "USER_LOGIN":
WDRouterRule.jumpWithAction(data)
//支付完成回调
case "REGISTER_H5_WEBVIEW_CREATE_ORDER_RESULT":
break
//打开H5页面
case "JUMP_H5_BY_WEB_VIEW":
WDRouterRule.jumpWithAction(data)
break
case "USER_LOGOUT":
// const loginService = ServiceManager.getService(ILoginService.name) as ILoginService.Service
// loginService.logout()
break
default:
call("this is def value")
}
}
// /**
// *
// * @returns 模拟测试环境的user信息
// */
// function getTestUserBean(): UserBean {
// const loginService = ServiceManager.getService(ILoginService.name) as ILoginService.Service
// //正是环境
// let userBean: UserBean = loginService.getUserBean()
// userBean.userId = "930855275"
// userBean.userToken = "nlps6FADECE38F5AAD2116F2"
// // userBean.clientId = "f1bf515c-4006-4606-a752-2b4cdd9343d0"
// // userBean.carrierCode = "CM"
// userBean.mobile = "NTTrcDO4ADN1cTM5MTM"
// userBean.uname = '139****0887'
// userBean.picture = "http://36.155.98.104:23380/publish/voms2/uic_service/picture/userImage/543/626/5181.jpg"
// // userBean.ssotoken = "STnid0000011700463753943SKPUlfNxEDJsrauGjCwUldiDfrd0mUuM"
// // userBean.clientProvinceCode = "210"
// // userBean.clientCityId = "0210"
// // userBean.sign = "617DAC548595B7C9EBB13043735F1BE0"
// // userBean.blurMobile = "177****9217"
// let userinfo: UserInfo = ({
// userId: "930855275",
// userNum: "NzDrsyN4gDM0UzNxkzMxYDO",
// mobile: "NTTrcDO4ADN1cTM5MTM",
// areaId: "210",
// cityId: "0210",
// carrierCode: "CM",
// passId: "602201990200225921",
// userToken: "nlps6FADECE38F5AAD2116F2",
// expiredOn: "1705647754000",
// blurMobile: "139****0887",
// encrypted: true
// })
// // userBean.userInfo = JSON.stringify(userinfo);
// return userBean
// }
//
// /**
// *
// * @returns 用户信息
// */
// function getUserBean(): UserBean {
// const loginService = ServiceManager.getService(ILoginService.name) as ILoginService.Service
// //正是环境
// let userBean: UserBean = loginService.getUserBean()
// userBean.userId = "1437725487"
// userBean.userToken = "nlps08468E117C554CA08A43"
// // userBean.clientId = "27fb3129-5a54-45bc-8af1-7dc8f1155501"
// // userBean.carrierCode = "CT"
// userBean.mobile = "OTTrcTMykTO4ATM3cTM"
// userBean.uname = '小可爱啊'
// userBean.picture = "http://img.cmvideo.cn:8080/publish/voms2/uic_service/picture/userImage/1437/725/487/20211224174128beax.png"
// // userBean.ssotoken = "STnid0000011700461738301N5rjsHdbvyzMpyzwvHrFRJsj7oNT1Juf"
// // userBean.clientProvinceCode = "100"
// // userBean.clientCityId = "0100"
// // userBean.sign = "4ABFB8442EE914B57CCD9F1DE587D96D"
// // userBean.blurMobile = "177****9217"
// let userinfo: UserInfo = ({
// userId: "1437725487",
// userNum: "MzDrsyNxITO5gDMxczNxYDO",
// mobile: "OTTrcTMykTO4ATM3cTM",
// areaId: "100",
// cityId: "0100",
// carrierCode: "CT",
// passId: "467464726359024540",
// userToken: "nlps08468E117C554CA08A43",
// expiredOn: "1705645738000",
// blurMobile: "177****9217",
// encrypted: true
// })
// // userBean.userInfo = JSON.stringify(userinfo);
// return userBean
// }
class AppInfo {
plat: string = ''
system: string = ''
// TODO 完善
}
/**
* 获取App公共信息
*/
function getAppPublicInfo(): string {
let info = new AppInfo()
info.plat = 'Phone'
// 直接用Android,后续适配再新增鸿蒙
info.system = 'Android'
let result = JSON.stringify(info)
return result;
}
... ...
/**
* native调用h5,事件id枚举
* app主动调用h5方法
*/
export const enum NativeCallH5Type {
jsCall_receiveAppData = 'jsCall_receiveAppData',
// TODO 业务自行新增类型,自行调用,例:
// TODO this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,xxxx)
}
... ...
... ... @@ -5,6 +5,7 @@ import { Logger } from 'wdKit';
import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { performJSCallNative } from './JsBridgeBiz';
import { setDefaultNativeWebSettings } from './WebComponentUtil';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
const TAG = 'WdWebComponent';
... ... @@ -12,7 +13,7 @@ const TAG = 'WdWebComponent';
export struct WdWebComponent {
private webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
//TODO 默认网页
webUrl: string = ConfigConstants.DETAIL_URL
webUrl: string | Resource = ConfigConstants.DETAIL_URL
/**
* 对外暴露webview的回调,能力
*/
... ... @@ -30,7 +31,7 @@ export struct WdWebComponent {
/**
* 默认【CallNative】逻辑处理
*/
private defaultPerformJSCallNative: (data: Action, f: Callback) => void = (data: Action, f: Callback) => {
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
performJSCallNative(data, f)
}
/**
... ... @@ -41,7 +42,7 @@ export struct WdWebComponent {
defaultRegisterHandler(): void {
this.webviewControl.registerHandler("CallNative", {
handle: (data: Action, f: Callback) => {
handle: (data: Message, f: Callback) => {
this.defaultPerformJSCallNative(data, f)
}
});
... ... @@ -88,7 +89,7 @@ export struct WdWebComponent {
// },500)
// })
// this.onPageBegin(event?.url)
this.webviewControl?.setCustomUserAgent('Mozilla/5.0 (Linux; Android 12; HarmonyOS; OXF-AN00; HMSCore 6.13.0.302) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 HuaweiBrowser/14.0.6.300 Mobile Safari/537.36')
// this.webviewControl?.setCustomUserAgent('Mozilla/5.0 (Linux; Android 12; HarmonyOS; OXF-AN00; HMSCore 6.13.0.302) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 HuaweiBrowser/14.0.6.300 Mobile Safari/537.36')
})
.onLoadIntercept((event) => {
let url: string = event.data.getRequestUrl().toString()
... ...
import router from '@ohos.router';
import { BridgeUtil, BridgeWebViewControl } from 'wdJsBridge';
import { ResourceManager } from 'wdJsBridge/src/main/ets/utils/ResourceManager';
import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { Logger } from 'wdKit/Index';
import { setDefaultNativeWebSettings } from './WebComponentUtil';
import { Action } from 'wdBean';
import { performJSCallNative } from './JsBridgeBiz';
import { H5CallNativeType } from './H5CallNativeType';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
const TAG = 'WdWebLocalComponent';
... ... @@ -26,12 +31,34 @@ export struct WdWebLocalComponent {
.visibility(this.backVisibility ? Visibility.Visible : Visibility.None)
Web({ src: this.webResource, controller: this.webviewControl })
.layoutMode(WebLayoutMode.FIT_CONTENT)
.domStorageAccess(true)
.databaseAccess(true)
.javaScriptAccess(true)
// .imageAccess(true)
// .onlineImageAccess(true)
// .fileAccess(true)
.onPageBegin((event) => {
})
// setDefaultNativeWebSettings(this.webviewControl, this.webResource).then(()=>{
// this.handleInfo && this.handleInfo.length > 1 ? this.handleInfo.forEach(value => {
// this.webviewControl.registerHandler(value[0], value[1])
// }) : this.defaultRegisterHandler()
// setTimeout(()=>{
// BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
// },500)
// })
// this.onPageBegin(event?.url)
// BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl);
this.onPageBegin(event?.url);
this.registerHandlers();
setTimeout(() => {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
}, 200)
})
.onPageEnd((event) => {
this.onPageEnd(event?.url)
})
.onLoadIntercept((event) => {
let url: string = event.data.getRequestUrl().toString()
url = url.replace("%(?![0-9a-fA-F]{2})", "%25")
... ... @@ -42,12 +69,50 @@ export struct WdWebLocalComponent {
return true
}
if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) {
Logger.debug(TAG, 'flushMessageQueue');
this.webviewControl.flushMessageQueue()
return true
}
return false
return this.onLoadIntercept(event.data.getRequestUrl().toString());
})
}
}
private registerHandlers(): void {
// TODO 待优化
H5CallNativeType.init();
// 注册h5调用js相关
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
let handle = (data: Message, f: Callback) => {
this.defaultPerformJSCallNative(data, f)
} ;
this.webviewControl.registerHandler(handleName, { handle: handle });
}
// // TODO test
// this.webviewControl.registerHandler('changeNativeMessage', {
// handle: (data: Message, f: Callback) => {
// this.defaultPerformJSCallNative(data, f)
// }
// });
}
/**
* 默认【CallNative】逻辑处理
*/
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
performJSCallNative(data, f)
}
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
}
onPageEnd: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageEnd');
}
onLoadIntercept: (url?: string) => boolean = () => {
Logger.debug(TAG, 'onPageBegin return false');
return false
}
}
... ...
This file is too large to display.
... ... @@ -5,6 +5,8 @@ export { BottomNavDTO } from './src/main/ets/bean/navigation/BottomNavDTO';
export { TopNavDTO } from './src/main/ets/bean/navigation/TopNavDTO';
export { PageInfoDTO } from './src/main/ets/bean/navigation/PageInfoDTO';
// entity
export { ItemDTO } from './src/main/ets/bean/ItemDTO';
... ... @@ -34,7 +36,8 @@ export {
postExecuteLikeParams,
postExecuteCollectRecordParams,
contentListParams,
postInteractAccentionOperateParams
postInteractAccentionOperateParams,
postRecommendListParams
} from './src/main/ets/bean/detail/MultiPictureDetailPageDTO';
export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
... ... @@ -49,6 +52,8 @@ export { GroupDTO } from './src/main/ets/bean/component/GroupDTO';
export { CompDTO } from './src/main/ets/bean/component/CompDTO';
export { LiveReviewDTO } from './src/main/ets/bean/component/LiveReviewDTO';
export { NewspaperListBean } from './src/main/ets/bean/newspaper/NewspaperListBean';
export { NewspaperListItemBean } from './src/main/ets/bean/newspaper/NewspaperListItemBean';
... ... @@ -77,6 +82,8 @@ export { ShareInfoDTO } from './src/main/ets/bean/detail/ShareInfoDTO';
export { VideoInfoDTO } from './src/main/ets/bean/detail/VideoInfoDTO';
export { AttentionRmhInfoDTO } from './src/main/ets/bean/detail/AttentionRmhInfoDTO';
export { H5ReceiveDetailBean } from './src/main/ets/bean/h5/H5ReceiveDetailBean';
export { H5ReceiveDataJsonBean } from './src/main/ets/bean/h5/H5ReceiveDataJsonBean';
... ... @@ -103,4 +110,13 @@ export { OperDataList } from './src/main/ets/bean/morningevening/OperDataList';
export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo';
export { slideShows } from './src/main/ets/bean/morningevening/slideShows';
\ No newline at end of file
export { slideShows } from './src/main/ets/bean/morningevening/slideShows';
export { LiveDetailsBean } from './src/main/ets/bean/live/LiveDetailsBean';
export { ArticleListDTO } from './src/main/ets/bean/component/ArticleListDTO';
export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO';
export { LiveRoomBean,LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoomBean';
... ...
/**
* http://192.168.1.3:3300/project/3856/interface/api/190567
* 接口名称:客户端 客态主页页面-获取作品-从发布库获取该创作者下 稿件列表
* 接口路径:GET/zh/c/article/articleList
* 人民号-动态tab下列表数据
*/
import { appStyleImagesDTO } from '../content/appStyleImagesDTO'
import {contentVideosDTO} from '../content/contentVideosDTO'
export interface ArticleListDTO {
listTitle: string;
mainPicCount: string;
videosCount: string;
voicesCount: string;
landscape: number;
sourceName: string;
finalStatus: string;
score: string;
shareUrl: string;
sortPosId: string;
id: string;
serialsId: string;
oldContentId: string;
type: string;
tenancy: string;
clientPubFlag: string;
grayScale: string;
title: string
publishType: string;
publishTime: string;
firstPublishTime: string;
onlineStatus: string;
auditingStatus: string;
zhOnlineStatus: string;
zhAuditingStatus: string;
selectedStatus: string;
qualityScore: string;
levelScore: number;
isOrg: string;
articlePayment: number;
appStyle: number;
appStyleImages: appStyleImagesDTO[];
description: string;
introduction: string;
deleted: string;
keyArticle: string;
updateTime: string;
createTime: string;
createUserId: string;
createUserName: string;
creatorId: number;
creatorName: string;
articleExistVote: string;
rmhPlatform: string;
objectPos: string;
objectPosPictures: string;
shareFlag: string;
firstPublish: string;
readNum: string;
readFlag: string;
creatorLevel: string;
creatorTag: string;
joinActivity: string;
userType: string;
content: object;
contentShare: [];
contentLinkData: string;
contentExt: [];
contentVideos: contentVideosDTO[];
contentPictures: [];
contentPayments: string;
contentPaymentStaffs: string;
contentTxt: [];
contentSource: object;
contentTags: string;
contentVoices: string;
contentAuthorLocals: string;
contentEpaperArticle: string;
contentStatistics: string;
topicExistHeadImage: string;
topicComps: string;
live: string;
statusInfo: string;
askInfo: string;
askAttachmentList: string;
askAnswerList: string;
askFeedbackList: string;
ttopicInteracts: string;
ttopic: string;
mlive: string;
vlives: string
}
\ No newline at end of file
... ...
... ... @@ -29,5 +29,4 @@ export interface CompDTO {
subType: string;
imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2
audioDataList: AudioDTO[];
isSelect: boolean;
}
\ No newline at end of file
... ...
import { ContentDTO } from '../content/ContentDTO';
export interface LiveReviewDTO {
hasNext: boolean;
pageNum: number;
pageSize: number;
totalCount: number;
list: ContentDTO[];
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ import { VideoInfoDTO } from '../detail/VideoInfoDTO';
import { InteractDataDTO } from './InteractDataDTO';
import { slideShows } from '../morningevening/slideShows';
import { VoiceInfoDTO } from '../detail/VoiceInfoDTO';
import { RmhInfoDTO } from '../detail/RmhInfoDTO'
export interface ContentDTO {
appStyle: string;
cityCode: string;
... ... @@ -59,10 +59,16 @@ export interface ContentDTO {
newsSummary: string; //appstyle:2 ,新闻详情
// 二次请求接口,返回的数据,这里组装到content里;TODO 后续优化
// 二次请求接口,返回的数据,这里组装到content里;
interactData:InteractDataDTO;
hasMore: number,
slideShows: slideShows[],
voiceInfo: VoiceInfoDTO
voiceInfo: VoiceInfoDTO,
tagWord: number,
isSelect: boolean;
rmhInfo: RmhInfoDTO; // 人民号信息
photoNum: number;
}
\ No newline at end of file
... ...
export interface appStyleImagesDTO {
url: string;
bucket: string;
landscape: number;
sort: number;
height: number;
weight: number;
size: number;
format: number;
fullUrl: string
}
\ No newline at end of file
... ...
export interface contentVideosDTO {
id: number;
contentId: number;
ossVideoId: string;
url: string;
fullUrl: string;
bucket: string;
duration: number;
clarity: number;
resolutionWidth: number;
resolutionHeight: number;
type: number;
original: number;
originalVideoId: string;
landscape: number;
size: number;
templateId: string;
deleted: number;
coverPictureId: string;
framePictureId: string;
createUser: string;
createTime: string;
updateUser: string;
updateTime: string;
bak1: string;
bak2: string;
bak3: string;
bak4: string;
videoType: number;
objectPosId: string;
}
\ No newline at end of file
... ...
export interface AttentionRmhInfoDTO {
attentionCreatorId: string;
attentionHeadPhotoUrl: string;
attentionNum: number;
attentionUserId: string;
attentionUserName: string;
attentionUserType: number;
authIcon: string;
authId: number;
authPersional: string;
authTitle: string;
banControl: number;
categoryAuth: string;
cnLiveCommentControl: number;
cnLiveGiftControl: number;
cnLiveLikeControl: number;
cnLiveShareControl: number;
cnShareControl: number;
collectNum: number;
commentNum: number;
createTime: number;
fansNum: number;
honoraryIcon: string;
honoraryTitle: string;
id: number;
introduction: string;
isAttention: number | null;
isComment: number;
isLike: number;
isVisiable: number;
likeNum: number;
liveCommentControl: number;
liveGiftControl: number;
liveLikeControl: number;
liveShareControl: number;
mainControl: number;
posterShareControl: number;
registTime: number;
shareControl: number;
shareNum: number;
status: number;
subjectType: string;
updateTime: number;
userId: string;
userType: number
}
... ...
... ... @@ -3,6 +3,7 @@ export interface FullColumnImgUrlDTO {
height: number;
landscape: number;
size: number | null;
url: string;
url: string; // 图片地址--列表显示
weight: number;
fullUrl: string; // 图片地址--预览地址使用;【人民号动态卡预览】
}
... ...
... ... @@ -177,4 +177,14 @@ export interface postInteractAccentionOperateParams {
// userType: number;
// userId: string;
status: number;
}
export interface postRecommendListParams {
imei: string;
userId ?: string;
contentId ?: string;
relId ?: string;
contentType ?: number;
recType: number;
channelId ? : string
}
\ No newline at end of file
... ...
... ... @@ -3,11 +3,11 @@ export interface RmhInfoDTO {
authTitle: string;
authTitle2: string;
banControl: number;
cnAttention: number;
cnIsAttention: number;
cnMainControl: number;
cnShareControl: number;
cnlsComment: number;
cnlsLike: number;
cnIsComment: number;
cnIsLike: number;
posterShareControl: number;
rmhDesc: string;
rmhHeadUrl: string;
... ...
... ... @@ -4,6 +4,7 @@ export interface VideoInfoDTO {
resolutionWidth: number;
videoDuration: number; // 视频时长
videoLandScape: number; // 1横屏 2竖屏
videoLandscape: number; // 1横屏 2竖屏
videoType: number;
videoUrl: string; //视频播放地址
firstFrameImageUri: string; // 首帧图;【视频内容,contentPictures中】
... ...
... ... @@ -10,7 +10,7 @@ export interface ResponseBean{
message: string;
// 响应结果
data:ContentDetailDTO;
data:ContentDetailDTO[];
// 请求响应时间戳(unix格式)
timestamp?: number;
... ...
export interface LiveDetailsBean {
/**
* {
"code": "0",
"data": [
{
"activityInfos": [],
"appstyle": 2,
"audioList": [],
"authorList": [
{
"authorName": "雷崔捷"
}
],
"bestNoticer": null,
"commentDisplay": 0,
"editorName": "",
"firstFrameImageUri": "",
"fullColumnImgUrls": [
{
"format": null,
"height": null,
"landscape": null,
"size": null,
"url": "https://rmrbcmsonline.peopleapp.com/upload/image/202404/rmrb_71671711971849.png",
"weight": null
}
],
"hasPopUp": null,
"isNewspaper": false,
"itemId": "",
"itemTypeCode": "",
"keyArticle": 0,
"likesStyle": null,
"liveInfo": {
"background": {
"imageUrl": "",
"name": ""
},
"backgroundStyle": null,
"cornerFlag": 0,
"cornerImgUrl": "",
"cornerLinkUrl": "",
"createUserId": "",
"createUserName": "",
"endTime": "2024-04-03 11:08:00",
"handAngleImageUri": "",
"handAngleLink": "",
"handAngleSwitch": false,
"likeEnable": 1,
"likesStyle": "thumb",
"liveExperience": 1,
"liveExperienceTime": 3,
"liveLandScape": "news",
"liveState": "end",
"liveStyle": 0,
"liveWay": 0,
"mlive": {
"barrageShowEnable": false,
"giftEnable": false,
"mliveId": 20000016257,
"roomId": "5381b934-cea8-4338-bd12-5bf70af43e0c"
},
"notice": "",
"openComment": 1,
"padImageUri": "",
"planStartTime": "2024-04-03 05:00:00",
"playbackSwitch": true,
"preCommentFlag": 1,
"previewType": 1,
"previewUrl": "",
"shareSwitch": "",
"startTime": "2024-04-03 05:03:23",
"tplId": 5,
"vlive": [
{
"coverImageUrl": "",
"definition": [],
"liveStreamManagerId": null,
"liveStreamType": 1,
"liveUrl": "https://plwbthird.live.weibo.com/alicdn/5018938748437049.m3u8",
"name": "线路1",
"replayUri": "http://mlive3.video.weibocdn.com/record/alicdn/5018726527666338/index.m3u8",
"serialNum": null,
"shiftEnable": false,
"showPad": false,
"type": "play",
"vliveId": 186728
}
],
"vrType": 0
},
"menuShow": 1,
"newIntroduction": "眼前有山河,心中有家国!每年清明节前夕,宁夏固原市第二中学和固原市弘文中学会组织入学新生,一天之内徒步54公里从学校往返任山河烈士陵园,用这种方式缅怀烈士们,这份坚定与执着已经延续了29年。",
"newLinkObject": null,
"newsBodyTitle": "",
"newsContent": "",
"newsContentBak": "",
"newsDownTitle": "",
"newsId": 20000016229,
"newsLinkUrl": "",
"newsShortTitle": "",
"newsSource": "41",
"newsSourceName": "",
"newsSummary": "",
"newsTags": "",
"newsTitle": "徒步54公里的思政课,坚守29年的薪火传承",
"newsType": 2,
"oldNewsId": "7218507",
"openAudio": 0,
"openComment": null,
"openLikes": null,
"photoList": [],
"popUps": [],
"preCommentFlag": null,
"publishTime": "2024-04-01 19:44:00",
"reLInfo": {
"channelId": 2061,
"relId": "500005272745",
"relObjectId": 2061,
"relType": "1"
},
"readFlag": 0,
"recommendShow": null,
"rmhInfo": null,
"rmhPlatform": 0,
"sceneId": "",
"serials": null,
"shareInfo": {
"shareCoverUrl": "https://rmrbcmsonline.peopleapp.com/upload/image/202404/202404011944259539.png?x-oss-process=image/resize,w_400",
"shareOpen": 1,
"sharePosterCoverUrl": "https://rmrbcmsonline.peopleapp.com/upload/image/202404/rmrb_71671711971849.png?x-oss-process=image/resize,m_fill,h_450,w_800,limit_0/quality,q_90",
"sharePosterOpen": 1,
"shareSummary": "人民日报,有品质的新闻",
"shareTitle": "徒步54公里的思政课,坚守29年的薪火传承",
"shareUrl": "https://people.pdnews.cn/column/20000016229-500005272745"
},
"specialColumnId": null,
"specialColumnName": "",
"subSceneId": "",
"timeline": null,
"topicInfo": null,
"traceId": "",
"traceInfo": "",
"userInfo": null,
"videoInfo": [],
"viewCount": 0,
"visitorComment": 1,
"voteInfo": null
}
],
"message": "Success",
"meta": null,
"requestId": "",
"success": true,
"timestamp": 1712807514322
}
*/
liveInfo: LiveInfo
fullColumnImgUrls: Array<FullColumnImgUrls>
vlive: Array<Vlive>
newsTitle: string
newIntroduction: string
}
export interface LiveInfo {
//直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
liveState: string
//2024-04-12 15:00:00 直播开始时间
planStartTime: string
}
export interface FullColumnImgUrls {
url: string
}
export interface Vlive {
//拉流直播 url
liveUrl: string
//直播回看地址,多路直播录制文件URL
replayUri: string
}
\ No newline at end of file
... ...
export interface LiveRoomBean {
pageNum: number
pageSize: number
totalCount: number
barrageResponses: Array<LiveRoomItemBean>
}
export interface LiveRoomItemBean {
text: string
senderUserAvatarUrl: string
senderUserName: string
pictureUrls: string[]
time: string
//1上墙0未上墙
isWall: number
//是否置顶 1置顶0不置顶
isTop: number
role: string
}
\ No newline at end of file
... ...
/**
* page接口返回的Page数据DTO
*/
export interface PageInfoDTO {
pageId: string; // 页面id
id: number; // 楼层id
name: string; // 名称
hasAdInfo: number;
hasPopUp: number;
baselineShow: number;
groups: GroupInfoDTO[];
channelInfo: ChannelInfoDTO;
}
export interface ChannelInfoDTO {
channelId: string;
channelLevel: string;
channelName: string;
channelStrategy: string;
channelStyle: string;
pageId: string;
}
export interface GroupInfoDTO {
blockDesc: string;
groupStrategy: number;
id: string;
showType: number;
sortValue: number;
}
\ No newline at end of file
... ...
... ... @@ -34,7 +34,8 @@ export { ENewspaperItemComponent } from "./src/main/ets/components/ENewspaperIte
export { ENewspaperListDialog } from "./src/main/ets/dialog/ENewspaperListDialog"
export { MorningEveningPaperComponent } from "./src/main/ets/components/MorningEveningPaper/MorningEveningPaperComponent"
export { MorningEveningPaperComponent
} from "./src/main/ets/components/MorningEveningPaper/MorningEveningPaperComponent"
export { ImageAndTextPageComponent } from "./src/main/ets/components/ImageAndTextPageComponent"
... ... @@ -58,3 +59,8 @@ export { AudioDetailComponent } from "./src/main/ets/components/AudioDetailCompo
export { BroadcastPageComponent } from "./src/main/ets/components/broadcast/BroadcastPageComponent"
export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/FirstTabTopSearchComponent"
export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasNoMoreDataUI"
export { LottieView } from './src/main/ets/lottie/LottieView'
... ...
... ... @@ -7,13 +7,16 @@
"main": "Index.ets",
"version": "1.0.0",
"dependencies": {
"@ohos/lottie": "2.0.0",
"wdConstant": "file:../../commons/wdConstant",
"wdPlayer": "file:../../features/wdPlayer",
"wdLogin": "file:../../features/wdLogin",
"wdKit": "file:../../commons/wdKit",
"wdWebComponent": "file:../../commons/wdWebComponent",
"wdBean": "file:../../features/wdBean",
"wdDetailPlayShortVideo": "file:../../features/wdDetailPlayShortVideo",
"wdRouter": "file:../../commons/wdRouter",
"wdNetwork": "file:../../commons/wdNetwork"
"wdNetwork": "file:../../commons/wdNetwork",
"wdJsBridge": "file:../../commons/wdJsBridge"
}
}
... ...
import { CommonConstants } from 'wdConstant';
import { Card3Component } from './cardview/Card3Component';
import { CommonConstants, CompStyle } from 'wdConstant';
import { ContentDTO } from 'wdBean';
import { Card2Component } from './cardview/Card2Component';
import { Card3Component } from './cardview/Card3Component';
import { Card4Component } from './cardview/Card4Component';
import { ContentDTO } from 'wdBean';
import { Card5Component } from './cardview/Card5Component';
import { Card6Component } from './cardview/Card6Component';
import { Card9Component } from './cardview/Card9Component';
import { Card10Component } from './cardview/Card10Component';
import { Card11Component } from './cardview/Card11Component';
import { Card17Component } from './cardview/Card17Component';
import { Card15Component } from './cardview/Card15Component';
import { Card19Component } from './cardview/Card19Component';
import { Card20Component } from './cardview/Card20Component';
/**
* card适配器,卡片样式汇总,依据ContentDTO#appStyle
... ... @@ -20,16 +27,31 @@ export struct CardParser {
@Builder
contentBuilder(contentDTO: ContentDTO) {
if (contentDTO.appStyle === '2') {
if (contentDTO.appStyle === CompStyle.Card_02) {
Card2Component({ contentDTO })
} else if (contentDTO.appStyle === '3') {
} else if (contentDTO.appStyle === CompStyle.Card_03) {
Card3Component({ contentDTO })
} else if (contentDTO.appStyle === "4") {
} else if (contentDTO.appStyle === CompStyle.Card_04) {
Card4Component({ contentDTO })
} else if (contentDTO.appStyle === "5") {
} else if (contentDTO.appStyle === CompStyle.Card_05) {
Card5Component({ contentDTO })
} else if (contentDTO.appStyle === "6") {
} else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle
.Card_13) {
Card6Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_09) {
Card9Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_10) {
Card10Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_11) {
Card11Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_15) {
Card15Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_17) {
Card17Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_19) {
Card19Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_20) {
Card20Component({ contentDTO })
}
else {
// todo:组件未实现 / Component Not Implemented
... ...
import { CompDTO, ContentDTO , slideShows} from 'wdBean';
import { CompDTO } from 'wdBean';
import { CommonConstants, CompStyle } from 'wdConstant';
import { BannerComponent } from './view/BannerComponent';
import { LabelComponent } from './view/LabelComponent';
import { TitleAbbrComponent } from './view/TitleAbbrComponent';
import { TitleAllComponent } from './view/TitleAllComponent';
import { SingleImageCardComponent } from './view/SingleImageCardComponent';
import { BigPicCardComponent } from './view/BigPicCardComponent';
import { TriPicCardComponent } from './view/TriPicCardComponent';
import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent';
import { HeadPictureCardComponent } from './view/HeadPictureCardComponent';
import { ZhGridLayoutComponent } from './view/ZhGridLayoutComponent';
import {
HorizontalStrokeCardThreeTwoRadioForMoreComponent
} from './view/HorizontalStrokeCardThreeTwoRadioForMoreComponent';
import {
HorizontalStrokeCardThreeTwoRadioForOneComponent
} from './view/HorizontalStrokeCardThreeTwoRadioForOneComponent';
import { AlbumCardComponent } from './view/AlbumCardComponent';
import { ZhSingleRow04 } from './view/ZhSingleRow04'
import { CompStyle_09 } from './view/CompStyle_09'
import { CompStyle_10 } from './view/CompStyle_10'
import { ZhSingleRow04 } from './compview/ZhSingleRow04';
import { ZhSingleColumn04 } from './compview/ZhSingleColumn04';
import { ZhSingleColumn05 } from './compview/ZhSingleColumn05';
import { ZhGridLayout03 } from './compview/ZhGridLayout03';
import { CardParser } from './CardParser';
import { LiveHorizontalReservationComponent } from './view/LiveHorizontalReservationComponent';
import { ZhGridLayout02 } from './compview/ZhGridLayout02';
import { Card5Component } from './cardview/Card5Component'
/**
* comp适配器.
... ... @@ -28,67 +25,7 @@ import { CompStyle_10 } from './view/CompStyle_10'
@Preview
@Component
export struct CompParser {
@State compDTO: CompDTO = {
compStyle: '17',
imageScale: 3,
operDataList: [
{
title: 'title0',
description: "description0",
coverUrl: 'https://uatjdcdnphoto.aikan.pdnews' +
'.cn/sjbj-20231208/image/display/d4496925a1264a749975ae9b01a4ef46.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg',
fullColumnImgUrls: [{
url: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20240104/image/display/c4a9b526e0994d1bbd3ac8450f5cfc6c.jpg?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
},{
url:'https://uatjdcdnphoto.aikan.pdnews' +
'.cn/sjbj-20231208/image/display/d4496925a1264a749975ae9b01a4ef46.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg',
},{
url: 'https://uatjdcdnphoto.aikan.pdnews' +
'.cn/sjbj-20231208/image/display/d4496925a1264a749975ae9b01a4ef46.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg',
}]
} as ContentDTO,
{
title: 'title1 title1 title1 title1 title1 title1 title1 title1 title1',
description: "description1",
coverUrl: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20240104/image/display/c4a9b526e0994d1bbd3ac8450f5cfc6c.jpg?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
title: 'title2',
description: "description2",
coverUrl: "https://cdnjdphoto.aikan.pdnews.cn/sjbj-20231206/image/live/bbe6d821e92b48919d90c7dadfd1f05a.jpg?x-oss-process=image/resize,l_850/auto-orient,1/quality,q_95/format,jpg",
} as ContentDTO,
{
title: 'title3',
description: "description3",
coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/sjbj-20231109/image/live/102e6eb9356b4ef19405b04c1f6ff875.png?x-oss-process=image/resize,l_850/auto-orient,1/quality,q_95/format,jpg'
} as ContentDTO,
{
title: 'title4',
description: "description4",
coverUrl: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20231218/image/display/62bdbbb35dbd45689e00790c81f04c4b.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
title: 'title5',
description: "description5",
coverUrl: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20231218/image/display/f79bbaa5a33b4bd88176071c4f797ff6.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
title: 'title6',
description: "description6",
coverUrl: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20231218/image/display/2c1d917009584ce2bb4a35cbb3a860a0.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO,
{
title: 'title7',
description: "description7",
coverUrl: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20231222/image/display/117dc516ca5c42d5843c0d32050c9fc6.jpeg?x-oss-process=image/resize,w_240/quality,q_90/format,jpg",
} as ContentDTO,
{
title: 'title8',
description: "description8",
coverUrl: "https://uatjdcdnphoto.aikan.pdnews.cn/sjbj-20231228/image/display/90a2db4077d44a1f887f068fc659d977.jpeg?x-oss-process=image/resize,w_550/quality,q_90/format,jpg",
} as ContentDTO
]
} as CompDTO
@State compDTO: CompDTO = {} as CompDTO
compIndex: number = 0;
build() {
... ... @@ -99,19 +36,8 @@ export struct CompParser {
componentBuilder(compDTO: CompDTO, compIndex: number) {
if (compDTO.compStyle === CompStyle.Label_03) {
LabelComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Title_Abbr_01) {
TitleAbbrComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Title_All_01) {
TitleAllComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Carousel_Layout_01) {
} else if (compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
BannerComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Single_ImageCard_03
|| compDTO.compStyle === CompStyle.Single_ImageCard_01) {
SingleImageCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === "2") {
BigPicCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === "4") {
TriPicCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2) {
LiveHorizontalCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 3) {
... ... @@ -120,19 +46,23 @@ export struct CompParser {
} else {
HorizontalStrokeCardThreeTwoRadioForOneComponent({ compDTO: compDTO })
}
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02
|| compDTO.compStyle === '5') {
HeadPictureCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.ZhGrid_Layout_03) {
ZhGridLayoutComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Album_Card_01) {
AlbumCardComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) {
LiveHorizontalReservationComponent({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) {
ZhGridLayout02({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
ZhGridLayout03({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_04) {
ZhSingleRow04({ compDTO: compDTO})
} else if (compDTO.compStyle === CompStyle.CompStyle_09) {
CompStyle_09({ compDTO: compDTO})
} else if (compDTO.compStyle === CompStyle.CompStyle_10) {
CompStyle_10({ compDTO: compDTO})
ZhSingleRow04({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) {
//头图卡 和comStyle 2相同,
Card5Component({ contentDTO: compDTO.operDataList[0] })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_04) {
ZhSingleColumn04({ compDTO: compDTO })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_05) {
ZhSingleColumn05({ compDTO: compDTO })
} else if (!Number.isNaN(Number(compDTO.compStyle))) {
CardParser({ contentDTO: compDTO.operDataList[0] });
}
else {
// todo:组件未实现 / Component Not Implemented
... ...
import { Action, ContentDetailDTO } from 'wdBean';
import { Logger, NumberFormatterUtils } from 'wdKit';
import {
Action,
ContentDetailDTO,
ContentDTO,
postRecommendListParams,
postExecuteLikeParams,
batchLikeAndCollectResult,
batchLikeAndCollectParams,
InteractDataDTO,
contentListParams,
} from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';
import router from '@ohos.router';
import { RecommendList } from '../components/view/RecommendList'
import { CommonConstants } from 'wdConstant'
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { PageRepository } from '../repository/PageRepository';
const TAG = 'ImageAndTextPageComponent'
export interface OperationItem {
icon: Resource;
icon_check?: Resource;
text: string | Resource;
num?: number; // 个数
}
@Component
export struct ImageAndTextPageComponent {
scroller: Scroller = new Scroller();
action: Action = {} as Action
@State detailData: ContentDetailDTO = {} as ContentDetailDTO
@State contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO []
@State recommendList: ContentDTO[] = []
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State interactData: InteractDataDTO = {} as InteractDataDTO
build() {
RelativeContainer() {
RelativeContainer() {
Text(this.detailData?.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.font_size_13'))
.id('date')
.alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End },
center:{anchor: "__container__", align:VerticalAlign.Center}})
Column() {
// 发布时间
Row() {
Image($r('app.media.icon_ren_min_ri_bao'))
.width(70)
.height(28)
.alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center } })
Text(this.contentDetailData[0]?.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.font_size_13'))
.height('100%')
.align(Alignment.End)
}
.width(CommonConstants.FULL_WIDTH)
.height(32)
.width('100%')
.id('image_text_detail_top')
.alignRules({ top: { anchor: "__container__", align: VerticalAlign.Top } })
.visibility(Visibility.None)
Image($r('app.media.line'))
.width('100%')
.height(6)
.objectFit(ImageFit.Contain)
.id('image_text_detail_top_line')
.alignRules({ top: { anchor: "image_text_detail_top", align: VerticalAlign.Bottom } })
.margin({ top: 10 })
.visibility(Visibility.Hidden)
RelativeContainer() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.id('back')
.alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.onClick((event: ClickEvent) => {
router.back()
})
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
.id('forward')
.alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "back", align: VerticalAlign.Center } })
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('listen')
.alignRules({ right: { anchor: "forward", align: HorizontalAlign.Start },
center: { anchor: "back", align: VerticalAlign.Center } })
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('star')
.alignRules({ right: { anchor: "listen", align: HorizontalAlign.Start },
center: { anchor: "back", align: VerticalAlign.Center } })
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
.alignRules({ right: { anchor: "star", align: HorizontalAlign.Start },
center: { anchor: "back", align: VerticalAlign.Center } })
.padding({ left: 15, right: 15, })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
Row() {
Image($r('app.media.line'))
.width('100%')
.height(6)
.objectFit(ImageFit.Cover)
.margin({ top: 10 })
}
.width('100%')
.height(56)
.id('image_text_detail_bottom')
.alignRules({ bottom: { anchor: "__container__", align: VerticalAlign.Bottom } })
.padding({ left: 15, right: 15, })
.backgroundColor(Color.White)
Column() {
ImageAndTextWebComponent({ detailData: this.detailData, action: this.action })
}
.width('100%')
.alignRules({ top: { anchor: "image_text_detail_top_line", align: VerticalAlign.Bottom },
bottom: { anchor: "image_text_detail_bottom", align: VerticalAlign.Top } })
.id('image_text_detail_content')
Stack({ alignContent: Alignment.Bottom }) {
List() {
//详情展示区
ListItem() {
Column() {
ImageAndTextWebComponent({
contentDetailData: this.contentDetailData,
action: this.action,
})
}.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
}
.width('100%')
.height('100%')
.padding({ left: 16, right: 16 })
if (this.contentDetailData[0]?.openLikes === 1) {
ListItem() {
// 点赞
Row() {
Row() {
if (this.newsStatusOfUser?.likeStatus === '1') {
Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active')))
.width(24)
.height(24)
.margin({ right: 5 })
} else {
Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle')))
.width(24)
.height(24)
.margin({ right: 5 })
}
Text(`${this.interactData?.likeNum || 0}`)
.fontSize(16)
.fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999')
.fontWeight(500)
}.alignItems(VerticalAlign.Center)
.onClick(() => {
this.toggleLikeStatus()
})
}.width(CommonConstants.FULL_WIDTH).height(80)
.justifyContent(FlexAlign.Center)
}
.border({
width: { bottom: 5 },
color: '#f5f5f5',
})
}
// 相关推荐区
ListItem() {
RecommendList({ recommendList: this.recommendList })
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: 56 })
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
//底部交互区
Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
router.back()
})
Row() {
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
}
}
.width(CommonConstants.FULL_WIDTH)
.height(56)
.padding({ left: 15, right: 15, bottom: 50, top: 20 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
.backgroundColor(Color.White)
}
async aboutToAppear() {
private async getDetail() {
let contentId: string = ''
let relId: string = ''
let relType: string = ''
... ... @@ -122,14 +187,106 @@ export struct ImageAndTextPageComponent {
}
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans && detailBeans.length > 0) {
this.detailData = detailBeans[0];
this.contentDetailData = detailBeans;
if (this.contentDetailData[0]?.recommendShow === 1) {
this.getRecommend()
}
if (this.contentDetailData[0]?.openLikes === 1) {
this.getInteractDataStatus()
this.queryContentInteractCount()
}
}
}
}
private async getRecommend() {
let params: postRecommendListParams = {
imei: "8272c108-4fa2-34ce-80b9-bc425a7c2a7e",
userId: HttpUrlUtils.getUserId(),
contentId: String(this.contentDetailData[0]?.newsId),
recType: 1,
contentType: this.contentDetailData[0]?.newsType,
relId: this.contentDetailData[0]?.reLInfo?.relId,
channelId: String(this.contentDetailData[0]?.reLInfo?.channelId)
}
let recommendList = await DetailViewModel.postRecommendList(params)
if (recommendList && recommendList.length > 0) {
this.recommendList = recommendList;
}
}
// 已登录->查询用户对作品点赞、收藏状态
private async getInteractDataStatus() {
try {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData[0]?.newsId + '',
contentType: this.contentDetailData[0]?.newsType + '',
}
]
}
console.error(TAG, JSON.stringify(this.contentDetailData))
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))
this.newsStatusOfUser = data[0];
Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
}
}
aboutToDisappear() {
/**
* 点赞、取消点赞
*/
toggleLikeStatus() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params: postExecuteLikeParams = {
status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
contentId: this.contentDetailData[0]?.newsId + '',
contentType: this.contentDetailData[0]?.newsType + '',
}
PageRepository.postExecuteLike(params).then(res => {
console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus == '1' ? '0' : '1'
this.queryContentInteractCount()
}
})
}
/**
* 查询点赞、收藏数量
*/
queryContentInteractCount() {
console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData))
const params: contentListParams = {
contentList: [{
contentId: this.contentDetailData[0]?.newsId + '',
contentType: this.contentDetailData[0]?.newsType,
}]
}
PageRepository.getContentInteract(params).then(res => {
if (res.data) {
this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum)
this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
}
console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
console.log(TAG, 'this.interactData', JSON.stringify(this.interactData))
})
}
aboutToAppear() {
this.getDetail()
}
aboutToDisappear() {
}
}
\ No newline at end of file
... ...
... ... @@ -8,82 +8,96 @@ import {
} from 'wdBean';
import { Logger } from 'wdKit';
import { WdWebComponent, WdWebLocalComponent } from 'wdWebComponent';
import { BridgeWebViewControl } from '../../../../../../commons/wdWebComponent/oh_modules/wdJsBridge/Index';
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
import { BridgeWebViewControl } from 'wdJsBridge/Index';
@Component
export struct ImageAndTextWebComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
action: Action = {} as Action
@State reload: number = 0;
@Prop @Watch('onDetailDataUpdated') detailData: ContentDetailDTO = {} as ContentDetailDTO
@Prop @Watch('onDetailDataUpdated') contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO []
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
onDetailDataUpdated() {
// if (this.action) {
// let contentId: string = ''
// let contentType: string = ''
// let topicId: string = ''
// let channelId: string = ''
// let compId: string = ''
// let sourcePage: string = '5'
// if (this.action.params) {
// if (this.action.params.contentID) {
// contentId = this.action.params?.contentID
// }
// if (this.action.params.extra) {
// if (this.action.params.extra.contentType) {
// contentType = this.action.params.extra.contentType
// }
// if (this.action.params.extra.topicId) {
// topicId = this.action.params.extra.topicId
// }
// if (this.action.params.extra.channelId) {
// channelId = this.action.params.extra.channelId
// }
// if (this.action.params.extra.compId) {
// compId = this.action.params.extra.compId
// }
// if (this.action.params.extra.sourcePage) {
// sourcePage = this.action.params.extra.sourcePage
// }
// }
//
// }
//
// let h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
// let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = { creatorId: '', isLogin: '0' } as H5ReceiveDataExtraBean
// let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = {
// contentId: contentId,
// contentType: contentType
// } as H5ReceiveDataJsonBean
// h5ReceiveDataJsonBean.topicId = topicId
// h5ReceiveDataJsonBean.channelId = channelId
// h5ReceiveDataJsonBean.compId = compId
// h5ReceiveDataJsonBean.sourcePage = sourcePage
// h5ReceiveDataJsonBean.netError = '0'
// let response: ResponseBean = {} as ResponseBean
// response.data = this.detailData
// response.code = 0
// response.success = true
// h5ReceiveDataJsonBean.responseMap = response
// h5ReceiveAppData.dataJson = h5ReceiveDataJsonBean
// h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean
// this.webviewControl.callHandle("jsCall_receiveAppData", JSON.stringify(h5ReceiveAppData), (data: string) => {
// Logger.info("from js data = " + data);
// })
if (this.action) {
let contentId: string = ''
let contentType: string = ''
let topicId: string = ''
let channelId: string = ''
let compId: string = ''
let sourcePage: string = '5'
if (this.action.params) {
if (this.action.params.contentID) {
contentId = this.action.params?.contentID
}
if (this.action.params.extra) {
if (this.action.params.extra.contentType) {
contentType = this.action.params.extra.contentType
}
if (this.action.params.extra.topicId) {
topicId = this.action.params.extra.topicId
}
if (this.action.params.extra.channelId) {
channelId = this.action.params.extra.channelId
}
if (this.action.params.extra.compId) {
compId = this.action.params.extra.compId
}
if (this.action.params.extra.sourcePage) {
sourcePage = this.action.params.extra.sourcePage
}
}
// }
}
let h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
// TODO 对接user信息、登录情况
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = { creatorId: '', isLogin: '0' } as H5ReceiveDataExtraBean
let h5ReceiveDataJsonBean: H5ReceiveDataJsonBean = {
contentId: contentId,
contentType: contentType
} as H5ReceiveDataJsonBean
h5ReceiveDataJsonBean.topicId = topicId
h5ReceiveDataJsonBean.channelId = channelId
h5ReceiveDataJsonBean.compId = compId
h5ReceiveDataJsonBean.sourcePage = sourcePage
h5ReceiveDataJsonBean.netError = '0'
let response: ResponseBean = {} as ResponseBean
response.data = this.contentDetailData
response.code = 200
response.success = true
h5ReceiveDataJsonBean.responseMap = response
h5ReceiveAppData.dataJson = h5ReceiveDataJsonBean
h5ReceiveAppData.dataExt = h5ReceiveDataExtraBean
// TODO 暂延时1s,考虑业务流程再优化
setTimeout(() => {
this.sendContentData2H5(h5ReceiveAppData);
}, 2000)
}
}
build() {
Column() {
if (this.detailData && this.detailData.shareInfo && this.detailData.shareInfo.shareUrl){
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.detailData?.shareInfo?.shareUrl,
backVisibility: false,
})
}
WdWebLocalComponent({
webviewControl: this.webviewControl,
webResource: $rawfile('apph5/index.html'),
backVisibility: false,
})
// WdWebLocalComponent({
// webviewControl: this.webviewControl,
// webResource: "http://pd-people-uat.pdnews.cn/articletopic/35398-10000015965",
// backVisibility: false,
// })
}
}
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData');
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
// Logger.debug('ImageAndTextWebComponent', "from js data = " + data);
})
}
}
\ No newline at end of file
... ...
// import { FrontLinkObject, MorningEveningPaperDTO, PageInfoBean } from 'wdBean';
import { CompList, PageInfoBean } from 'wdBean';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import { DateTimeUtils, Logger, SPHelper } from 'wdKit/Index';
import { PaperReaderSimpleDialog } from '../../dialog/PaperReaderDialog';
import { MorningEveningViewModel } from '../../viewmodel/MorningEveningViewModel';
// import { AudioBarView } from './AudioBarView';
... ... @@ -21,6 +21,7 @@ export struct MorningEveningPaperComponent {
// @State compInfoBean: CompInfoBean = {} as CompInfoBean
@State compListItem: CompList = {} as CompList
@State audioPlayUrl: string = ""
// @Consume dailyPaperTopicPageId: number
// @Provide compListItem: CompList = {} as CompList
// @State morningEveningPaperDTO: MorningEveningPaperDTO = {
// name: "新闻夜读",
... ... @@ -92,13 +93,14 @@ export struct MorningEveningPaperComponent {
}
async aboutToAppear() {
console.info(TAG, `aboutToAppear`)
let dailyPaperTopicPageId = await SPHelper.default.getSync('dailyPaperTopicPageId', "") as String
console.info(TAG, `aboutToAppear = ` + dailyPaperTopicPageId)
const currentTime = new Date().getTime()
Logger.info(TAG, "currentTime = " + currentTime)
Logger.info(TAG, `currentTime = ${currentTime}`)
try {
let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("25091")
// let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("" + this.dailyPaperTopicPageId)
let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("" + dailyPaperTopicPageId) //"25091"
this.pageInfoBean = pageInfoBean;
this.title = this.pageInfoBean?.topicInfo?.title
let dateTime = DateTimeUtils.parseDate(this.pageInfoBean?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN);
... ...
... ... @@ -27,27 +27,29 @@ export struct MultiPictureDetailPageComponent {
private screenWidth: number = 0
private picWidth: number = 0
@State picHeight: number = 0
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State titleHeight: number = 0
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
private swiperController: SwiperController = new SwiperController()
@State swiperIndex: number = 0;
@Provide followStatus: string = '0' // 关注状态
private scroller: Scroller = new Scroller()
//watch监听页码回调
onCurrentPageNumUpdated(): void {
Logger.info(TAG, `currentPageNum:${this.currentPageNum}`, )
Logger.info(TAG, `currentPageNum:${this.currentPageNum}`,)
let _swiperIndex = Number.parseInt(this.currentPageNum)
Logger.info(TAG, `_swiperIndex:${_swiperIndex}`)
this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex
}
async aboutToAppear() {
//获取宽高尺寸
this.screenWidth = this.displayTool.width
// this.picWidth = this.screenWidth - vp2px(52)
this.picWidth = this.screenWidth
this.picHeight = this.picWidth * 566 / 378
this.picHeight = this.picWidth * 578 / 375
this.titleHeight = this.screenWidth * 178 / 375
//注册字体
font.registerFont({
familyName: 'BebasNeue_Regular',
... ... @@ -69,12 +71,12 @@ export struct MultiPictureDetailPageComponent {
if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) {
Swiper(this.swiperController) {
ForEach(this.contentDetailData.photoList, (item: PhotoListBean) => {
MultiPictureDetailItemComponent({ MultiPictureDetailItem: item })
MultiPictureDetailItemComponent({ MultiPictureDetailItem: item })
})
}
.index(this.swiperIndex)
.width('100%')
.height(px2vp(this.picHeight))
.height(px2vp(this.picHeight) + 32)
.vertical(false)
.autoPlay(false)
.cachedCount(3)
... ... @@ -82,16 +84,17 @@ export struct MultiPictureDetailPageComponent {
.displayCount(1)
.id('e_swiper_content')
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.onChange((index: number) => {
this.swiperIndex = index
})
if(this.contentDetailData.rmhPlatform == 1) {
if (this.contentDetailData.rmhPlatform == 1) {
Row() {
Row(){
Row({space: 8}) {
Row() {
Row({ space: 8 }) {
Image(this.contentDetailData?.rmhInfo?.rmhHeadUrl)
.borderRadius('50%')
.alt($r('app.media.picture_loading'))
... ... @@ -102,6 +105,7 @@ export struct MultiPictureDetailPageComponent {
}
.width('13%')
.height('100%')
Row() {
Flex({
direction: FlexDirection.Column,
... ... @@ -121,7 +125,7 @@ export struct MultiPictureDetailPageComponent {
.fontWeight(400)
.lineHeight(14)
.textOverflow({ overflow: TextOverflow.Clip })
.margin (0)
.margin(0)
}
}
.width('81%')
... ... @@ -133,10 +137,11 @@ export struct MultiPictureDetailPageComponent {
top: 0,
bottom: 0,
left: 16,
right:0
right: 0
})
if(this.followStatus == '0') {
Row(){
if (this.followStatus == '0') {
Row() {
Button('+关注', { type: ButtonType.Normal, stateEffect: true })
.borderRadius(4)
.backgroundColor('#ED2800')
... ... @@ -149,7 +154,7 @@ export struct MultiPictureDetailPageComponent {
top: 10,
bottom: 10,
left: 16,
right:16
right: 16
})
.fontSize(12)
.fontColor(Color.White)
... ... @@ -166,50 +171,72 @@ export struct MultiPictureDetailPageComponent {
})
.id('e_attention')
}
Row() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Start
}) {
Text() {
Span(`${this.swiperIndex + 1}`).fontSize(24).fontFamily('PingFang SC-Medium').fontWeight(500).lineHeight(28)
Span(`/${this.contentDetailData.photoList.length}`).fontSize(14).fontFamily('PingFang SC-Medium').fontWeight(500).lineHeight(19)
}.fontColor(Color.White).margin(4)
Scroll(this.scroller) {
Row() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Start
}) {
Text() {
Span(`${this.swiperIndex + 1}`)
.fontSize(24)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(28)
Span(`/${this.contentDetailData.photoList.length}`)
.fontSize(14)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(19)
}.fontColor(Color.White).margin(4)
Text(`${this.contentDetailData.newsTitle}`).fontColor(Color.White).fontSize(16).fontFamily('PingFang SC-Semibold')
.fontWeight(600).lineHeight(24)
.margin ({
top: 4,
left: 0,
bottom: 4,
right: 0
})
Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`).fontColor(Color.White)
.fontSize(14).fontFamily('PingFang SC-Regular').fontWeight(400).lineHeight(22)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin ({
top: 4,
left: 0,
bottom: 4,
right: 18
})
.maxLines(3)
Text(`${this.contentDetailData.newsTitle}`)
.fontColor(Color.White)
.fontSize(16)
.fontFamily('PingFang SC-Semibold')
.fontWeight(600)
.lineHeight(24)
.margin({
top: 4,
left: 0,
bottom: 4,
right: 0
})
Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`)
.fontColor(Color.White)
.fontSize(14)
.fontFamily('PingFang SC-Regular')
.fontWeight(400)
.lineHeight(22)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({
top: 4,
left: 0,
bottom: 4,
right: 18
})
.maxLines(16)
}
}
.width('100%')
.margin({
top: 8,
left: 18,
bottom: 24,
right: 18
})
}
.scrollable(ScrollDirection.Vertical)
.scrollBarWidth(0)
.height(px2vp(this.titleHeight))
}
.width('100%')
.height(178)
.margin ({
top: 8,
left: 18,
bottom: 8,
right: 18
})
.id('e_swiper_titles')
.alignRules({
bottom: { anchor: "e_swiper_content", align: VerticalAlign.Bottom },
middle: { anchor: "e_swiper_content", align: HorizontalAlign.Center }
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.height(px2vp(this.titleHeight) + 64)
OperRowListView({
contentDetailData: this.contentDetailData,
... ... @@ -218,8 +245,15 @@ export struct MultiPictureDetailPageComponent {
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.width('100%').height(56).margin(16)
.border({ width: {top: 0.5}, color: '#FFFFFF' })
.width('100%')
.height(56)
.margin({
top: 16,
left: 16,
right: 16,
bottom: 0
})
.border({ width: { top: 0.5 }, color: '#FFFFFF' })
.id('e_oper_row')
}
}
... ... @@ -227,6 +261,9 @@ export struct MultiPictureDetailPageComponent {
.height('100%')
.backgroundColor(Color.Black)
.id('e_picture_container')
// 设置顶部绘制延伸到状态栏
// 设置底部绘制延伸到导航条
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
}
private async getContentDetailData() {
... ... @@ -271,6 +308,7 @@ export struct MultiPictureDetailPageComponent {
}
}
/**
* 关注号主
*/
... ...
... ... @@ -14,7 +14,6 @@ import { CommonConstants } from 'wdConstant/Index';
const TAG = 'BroadcastPageComponent';
@Entry
@Component
export struct BroadcastPageComponent {
@State params:Params = router.getParams() as Params;
... ... @@ -130,10 +129,9 @@ export struct BroadcastPageComponent {
}
}
.layoutWeight(1)
// @ts-ignore
.onScrollFrameBegin((offset, state) => {
console.log('ccc',String(offset), state)
})
// .onScrollFrameBegin((offset, state) => {
// console.log('ccc',String(offset), state)
// })
.onReachStart(() => {
console.log('onReachStart----->',)
})
... ...
... ... @@ -4,7 +4,6 @@ import { CommonConstants } from 'wdConstant/Index';
/**
* 今日推荐顶部标题--fixed标题
*/
@Entry
@Component
export struct RecommendHeader {
build() {
... ...
... ... @@ -4,7 +4,6 @@ import { ProcessUtils } from '../../utils/ProcessUtils';
/**
* 播报--今日推荐列表
*/
@Entry
@Component
export struct RecommendLists {
@Prop recommendCompInfoBean: CompInfoBean = {} as CompInfoBean // 推荐-组件信息
... ...
... ... @@ -3,7 +3,6 @@ import { DateTimeUtils } from 'wdKit';
/**
* 播报标题描述
*/
@Entry
@Component
export struct RecommendTitle {
build() {
... ...
... ... @@ -5,7 +5,6 @@ import { ProcessUtils } from '../../utils/ProcessUtils';
/**
* 精选栏目
*/
@Entry
@Component
export struct SelectedColumns {
@Prop columnsCompInfoBean: CompInfoBean = {} as CompInfoBean // 精选栏目组件信息
... ...
import { ContentDTO } from 'wdBean/Index'
import { DateTimeUtils } from 'wdKit/Index'
/**
* 这里是样式卡中,右下角显示的音视频信息
* 目前已知:
* 音频: 音频图标+时长
* 视频:点播图标+时长;直播图标+'直播中'
*/
@Component
export struct CardMediaInfo {
@State contentDTO: ContentDTO = {} as ContentDTO // 如果有duraion,代表点播,显示时长;如果不传或者传0,显示直播中
// objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,
// 14动态图文,15动态视频16问政;100人民号,101标签
build() {
Row() {
if(this.contentDTO.objectType === '1' || this.contentDTO.objectType === '15' ) {
// 点播、动态视频
Row(){
Image($r('app.media.videoTypeIcon'))
.mediaLogo()
Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000))
.mediaText()
}
.backgroundColor('#4d000000')
.borderRadius($r('app.float.button_border_radius'))
} else if(this.contentDTO.objectType === '2') {
// liveInfo.liveState 直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
// 显示直播信息
Row(){
if(this.contentDTO.liveInfo.liveState === 'running') {
Image($r('app.media.icon_live'))
.mediaLogo()
Text('直播中')
.mediaText()
} else if(this.contentDTO.liveInfo.liveState === 'end'){
Image($r('app.media.videoTypeIcon'))
.mediaLogo()
Text('回看')
.mediaText()
}
}
.backgroundColor('#4d000000')
.borderRadius($r('app.float.button_border_radius'))
} else if(this.contentDTO.objectType === '9') {
// 显示组图;图片数量
Row(){
Image($r('app.media.album_card_shape'))
.mediaLogo()
Text(`${this.contentDTO.photoNum}`)
.mediaText()
.width(20)
}
.backgroundColor('#4d000000')
.borderRadius($r('app.float.button_border_radius'))
} else if(this.contentDTO.objectType === '13') {
// 显示音频信息
Row(){
Image($r('app.media.broadcast_listen'))
.height(14)
.borderRadius($r('app.float.button_border_radius'))
Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000))
.mediaText()
}
}
}
.margin(6)
}
@Styles mediaLogo() {
.width(22)
.height(18)
.borderRadius($r('app.float.button_border_radius'))
}
}
@Extend(Text) function mediaText() {
.fontColor($r('app.color.color_fff'))
.fontSize($r('app.float.font_size_12'))
.width(40)
.height(18)
.textAlign(TextAlign.Center)
.margin({ left: -3 })
}
\ No newline at end of file
... ...
/**
* 这里是人民号动态中的顶部信息:人民号logo,名字,描述,关注等
*/
import { RmhInfoDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
@Component
export struct RmhTitle {
@Prop rmhInfo: RmhInfoDTO
build() {
Flex() {
Stack() {
Image(this.rmhInfo.rmhHeadUrl)
.width(36)
.height(36).borderRadius(50)
Image(this.rmhInfo.authIcon)
.width(14)
.height(14)
.borderRadius(50)
}
.margin({ right: 8 })
.alignContent(Alignment.BottomEnd)
.flexShrink(0)
Column() {
Text(this.rmhInfo.rmhName)
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.alignSelf(ItemAlign.Start)
Text(this.rmhInfo.rmhDesc)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
Blank()
if (this.rmhInfo.cnIsAttention) {
Row() {
Image($r('app.media.rmh_follow'))
.width(16)
.height(16)
Text('关注')
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_ED2800'))
}
.flexShrink(0)
.alignSelf(ItemAlign.Center)
.onClick(() => {
// TODO 调用关注接口
})
}
}
.width(CommonConstants.FULL_WIDTH)
.margin({ bottom: 10 })
}
}
\ No newline at end of file
... ...
import { AttentionRmhInfoDTO } from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
/**
* AttentionListComponent 人民号-关注-我的关注
* 没有compstyle
*/
const TAG = '人民号-关注-我的关注'
@Entry
@Component
export struct AttentionListComponent {
@State attentionList: AttentionRmhInfoDTO[] = [] as AttentionRmhInfoDTO[]
build() {
Row({ space: 4 }) {
List() {
ListItem() {
Column() {
Image($r('app.media.attention_mine'))
.width(48)
.height(48)
.padding(12)
.backgroundColor($r('app.color.color_F5F5F5'))
.borderRadius(50)
.margin({ bottom: 8 })
Text('我的关注')
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_666666'))
}
.width(78)
.height(74)
.onClick(() => {
// 跳转到关注列表-我的
WDRouterRule.jumpWithPage(WDRouterPage.followListPage)
})
}
ForEach(this.attentionList, (item: AttentionRmhInfoDTO, index: number) => {
ListItem() {
Column() {
Stack() {
Image(item.attentionHeadPhotoUrl)
.width(48)
.height(48)
.borderRadius(50)
Image(item.authIcon)
.width(14)
.height(14)
.borderRadius(50)
}
.margin({ bottom: 8 })
.alignContent(Alignment.BottomEnd)
Text(item.attentionUserName)
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_666666'))
.textOverflowStyle(1)
}
.margin({
right: index === this.attentionList.length - 1 ? $r('app.float.card_comp_pagePadding_lf') : 0,
})
.padding({ left: 2, right: 2 })
}
.width(78)
.height(74)
.onClick(() => {
//TODO 跳转到对应的人民号主页
})
})
}
.listDirection(Axis.Horizontal)
.height(74)
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
}
}
@Extend(Text)
function textOverflowStyle(maxLine: number) {
.maxLines(maxLine)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
... ...
import { ContentDTO, slideShows } from 'wdBean';
import { CommonConstants } from 'wdConstant'
import { DateTimeUtils } from 'wdKit';
import { ProcessUtils } from '../../utils/ProcessUtils';
/**
* 大专题卡--CompStyle: 10
*/
const TAG: string = 'Card10Component';
@Component
export struct Card10Component {
@State contentDTO: ContentDTO = {} as ContentDTO;
build() {
Column() {
// 顶部标题,最多两行
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_17'))
.fontWeight(600)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ bottom: 19 })
}
// 大图
Stack() {
Image(this.contentDTO && this.contentDTO.coverUrl)
.width('100%')
.borderRadius({
topLeft: $r('app.float.image_border_radius'),
topRight: $r('app.float.image_border_radius')
})
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
Text('专题')
.fontSize($r('app.float.font_size_12'))
.padding({ left: 8, right: 8, top: 3, bottom: 3 })
.backgroundColor(Color.Red)
.fontColor(Color.White)
.borderRadius($r('app.float.button_border_radius'))
.margin({ left: 5, bottom: 5 })
}.alignContent(Alignment.BottomStart)
// 专题列表--后端返回三个,
Column() {
ForEach(this.contentDTO.slideShows, (item: slideShows, index: number) => {
this.timelineItem(item, index)
})
}
// 底部-查看更多。根据接口返回的isMore判断是否显示查看更多
if (this.contentDTO.hasMore == 1) {
Row() {
Text("查看更多")
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_222222"))
.margin({ right: 1 })
Image($r("app.media.more"))
.width(14)
.height(14)
}
.backgroundColor($r('app.color.color_F5F5F5'))
.width(CommonConstants.FULL_WIDTH)
.height(40)
.borderRadius($r('app.float.button_border_radius'))
.justifyContent(FlexAlign.Center)
.margin({ top: 5 })
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
}
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
}
@Builder
timelineItem(item: slideShows, index: number) {
Row() {
Column() {
Text(item.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Row() {
// 展示发稿人
if (item.source) {
Text(item.source)
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_B0B0B0'))
.textOverflow({ overflow: TextOverflow.Ellipsis })
.maxLines(1)
.width(item.source.length > 10 ? '60%' : '')
Image($r('app.media.point'))
.width(16)
.height(16)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(String(item.publishTime))))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
}
.margin({ top: 12 })
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
// 右侧图片
if (item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
Image(item.fullColumnImgUrls[0].url)
.width(117)
.height(78)
.objectFit(ImageFit.Cover)
.borderRadius($r('app.float.image_border_radius'))
.margin({ left: 12 })
}
}
.padding({ top: 10, bottom: 10 })
.onClick((event: ClickEvent) => {
const str: string = JSON.stringify(this.contentDTO);
const data: ContentDTO = JSON.parse(str)
data.objectId = item.newsId
data.relId = item.relId
data.objectType = String(item.objectType)
ProcessUtils.processPage(data)
})
}
}
\ No newline at end of file
... ...
//缩略标题
import { CommonConstants } from 'wdConstant'
import { ContentDTO } from 'wdBean'
import { DateTimeUtils } from 'wdKit'
import { ProcessUtils } from '../../utils/ProcessUtils';
const TAG = 'Card11Component';
/**
* 无图卡(标题省略) Card_11 = '11
*/
@Component
export struct Card11Component {
@State contentDTO: ContentDTO = {} as ContentDTO;
build() {
Column() {
Text(this.contentDTO.newsTitle)
.fontSize($r("app.float.font_size_16"))
.fontColor($r("app.color.color_222222"))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.width(CommonConstants.FULL_WIDTH)
Row() {
if (this.contentDTO.source) {
Text(this.contentDTO.source)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ left: 6 })
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"))
.margin({ right: 6 })
// TODO '评论取哪个字段'
// Text(`1806评`)
// .fontSize($r("app.float.font_size_12"))
// .fontColor($r("app.color.color_B0B0B0"))
}.width(CommonConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
}.width(CommonConstants.FULL_WIDTH)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.backgroundColor($r("app.color.white"))
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
}
}
\ No newline at end of file
... ...
import { ContentDTO } from 'wdBean';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { RmhTitle } from '../cardCommon/RmhTitle'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CommonConstants } from 'wdConstant/Index';
const TAG: string = 'Card15Component';
/**
* 大图卡人民号:
* compstyle:15
* 卡片结构:上下结构
* 卡片宽度:充满父窗口
* 卡片高度,仅包含横板图片:图片高度由图片的宽度及宽高比决定,图片宽度占父窗口'100%',宽高比为16:9:
*/
@Component
export struct Card15Component {
@State contentDTO: ContentDTO = {
// appStyle: '15',
// coverType: 1,
// objectType: '9',
// coverUrl: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/img/2024/0413/VL20Z09ISBEKXZU_963672030241091584.jpeg?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
// fullColumnImgUrls: [
// {
// landscape: 2,
// size: 1,
// url: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/img/2024/0413/VL20Z09ISBEKXZU_963672030241091584.jpeg?x-oss-process=image/resize,m_fill,h_450,w_800/quality,q_90',
// weight: 1170
// }
// ],
// newsTitle: '押解画面公开!被湖北民警从柬埔寨押解回国被湖北民警从柬埔寨押解回国的130名涉赌诈嫌疑人是他们被湖北民警从柬埔寨押解回国的130名涉赌诈嫌疑人是他们的130名涉赌诈嫌疑人是他们',
// publishTime: '1712993333000',
// rmhInfo: {
// authIcon: '',
// authTitle: '',
// authTitle2: '',
// banControl: 0,
// cnIsAttention: 1,
// rmhDesc: '中共武汉市委机关报长江日报官方人民号',
// rmhHeadUrl: 'https://uatjdcdnphoto.aikan.pdnews.cn/vod/content/202302/202302Sa121448724/TUw.png?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg',
// rmhId: '4255270',
// rmhName: '长江日报',
// userId: '513696944662469',
// userType: '3'
// },
// videoInfo: {
// firstFrameImageUri: '',
// videoDuration: 12,
// // videoLandscape: 2,
// videoUrl: 'https://rmrbcmsonline.peopleapp.com/rb_recsys/video/2024/0413/VL20Z09ISBEKXZU_963672027208609792.mp4'
// },
// photoNum: '9',
// voiceInfo: {
// voiceDuration: 12
// }
} as ContentDTO;
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
//新闻标题
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.width(CommonConstants.FULL_WIDTH)
.textOverflowStyle(2)
.margin({ bottom: 8 })
}
//大图
Stack() {
Image(this.contentDTO.coverUrl)
.borderRadius($r('app.float.image_border_radius'))
//播放状态+时长
CardMediaInfo({
contentDTO: this.contentDTO
})
}
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.alignContent(Alignment.BottomEnd)
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
}
}
@Extend(Text)
function textOverflowStyle(maxLine: number) {
.maxLines(maxLine)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
\ No newline at end of file
... ...
import { Action, CompDTO, ContentDTO, Params } from 'wdBean';
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit';
import { WDRouterRule } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
const TAG = 'Card17Component';
/**
* 图卡集---2
*/
@Component
export struct Card17Component {
@State compDTO: CompDTO = {} as CompDTO
@State contentDTO: ContentDTO = {} as ContentDTO;
build() {
Column({ space: 8 }) {
Text(this.contentDTO.newsTitle)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.lineHeight(25)
.maxLines(3)
.width(CommonConstants.FULL_WIDTH)
Stack({ alignContent: Alignment.BottomEnd }) {
// 三个图,
GridRow({ gutter: 2 }) {
GridCol({ span: { xs: 8 } }) {
Image(this.contentDTO.fullColumnImgUrls[0].url)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.borderRadius({
topLeft: $r('app.float.image_border_radius'),
bottomLeft: $r('app.float.image_border_radius'),
})
}
GridCol({ span: { xs: 4 } }) {
Image(this.contentDTO.fullColumnImgUrls[1].url)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.margin({ bottom: 1 })
.borderRadius({
topRight: $r('app.float.image_border_radius'),
})
}
}
GridRow({ gutter: 2 }) {
GridCol({ span: { xs: 8 } }) {
}
GridCol({ span: { xs: 4 } }) {
Image(this.contentDTO.fullColumnImgUrls[2].url)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.margin({ top: 1 })
.borderRadius({
bottomRight: $r('app.float.image_border_radius'),
})
}
}
CardMediaInfo({ contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
detailPageType: 17,
contentID: this.contentDTO.objectId,
extra: {
relType: this.contentDTO.relType,
relId: `${this.contentDTO.relId}`,
} as ExtraDTO
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
})
Row() {
if (this.contentDTO.source) {
Text(this.contentDTO.source)
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_B0B0B0'))
Image($r('app.media.point'))
.width(16)
.height(16)
}
if (this.contentDTO.publishTime && this.contentDTO.publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_B0B0B0'))
}
}
.width(CommonConstants.FULL_WIDTH)
.height(16)
.id('label')
}
.width(CommonConstants.FULL_WIDTH)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
}
}
\ No newline at end of file
... ...