Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
张善主
2024-04-15 14:25:25 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
9a516bc157ca0c8912928e6aeb7aa25e64e0275d
9a516bc1
2 parents
21d5b5c1
3a649b71
Merge remote-tracking branch 'origin/main'
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
191 additions
and
172 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/CollectionUtils.ts
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdBean/Index.ets
sight_harmony/features/wdBean/src/main/ets/bean/component/CompDTO.ets
sight_harmony/features/wdBean/src/main/ets/bean/content/ContentDTO.ets
sight_harmony/features/wdBean/src/main/ets/bean/navigation/PageInfoDTO.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/BrowsingHistoryPage.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/MyCollectionListPage.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/BigPicCardComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/areaPickerDialog/AreaPickerDialog.ets
sight_harmony/features/wdComponent/src/main/ets/model/MyCollectionModel.ets
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
sight_harmony/features/wdComponent/src/main/ets/utils/PullDownRefresh.ets
sight_harmony/features/wdComponent/src/main/ets/utils/PullUpLoadMore.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/MyCollectionViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
sight_harmony/commons/wdKit/src/main/ets/utils/CollectionUtils.ts
View file @
9a516bc
...
...
@@ -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
;
}
...
...
@@ -180,12 +187,5 @@ export class CollectionUtils {
return
collection
.
slice
(
start
,
end
);
}
static
getElement
(
collection
?:
any
[],
index
?:
number
):
any
{
if
(
CollectionUtils
.
isEmpty
(
collection
)
||
index
===
undefined
)
{
return
null
;
}
return
index
>=
0
&&
index
<
collection
.
length
?
collection
[
index
]
:
null
;
}
}
...
...
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
9a516bc
...
...
@@ -37,7 +37,7 @@ export class HttpUrlUtils {
/**
* 展现comp接口(推荐)
*/
static readonly COMP_REC_PATH: string = "api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
static readonly COMP_REC_PATH: string = "
/
api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
/**
* 详情页面详情接口
*/
...
...
@@ -135,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";
/**
* 个人中心 我的评论列表
*/
...
...
@@ -502,7 +506,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
}
...
...
sight_harmony/features/wdBean/Index.ets
View file @
9a516bc
...
...
@@ -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';
...
...
sight_harmony/features/wdBean/src/main/ets/bean/component/CompDTO.ets
View file @
9a516bc
...
...
@@ -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
...
...
sight_harmony/features/wdBean/src/main/ets/bean/content/ContentDTO.ets
View file @
9a516bc
...
...
@@ -62,11 +62,13 @@ export interface ContentDTO {
// 二次请求接口,返回的数据,这里组装到content里;
interactData:InteractDataDTO;
hasMore: number;
slideShows: slideShows[];
voiceInfo: VoiceInfoDTO;
tagWord: number;
hasMore: number,
slideShows: slideShows[],
voiceInfo: VoiceInfoDTO,
tagWord: number,
isSelect: boolean;
rmhInfo: RmhInfoDTO; // 人民号信息
photoNum: number;
}
\ No newline at end of file
...
...
sight_harmony/features/wdBean/src/main/ets/bean/navigation/PageInfoDTO.ets
0 → 100644
View file @
9a516bc
/**
* 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
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/BrowsingHistoryPage.ets
View file @
9a516bc
...
...
@@ -6,13 +6,14 @@ import { EmptyComponent } from '../view/EmptyComponent'
import { ErrorComponent } from '../view/ErrorComponent'
import RefreshLayout from './RefreshLayout'
import { RefreshLayoutBean } from './RefreshLayoutBean';
import { CompDTO } from 'wdBean'
import { CompDTO
, ContentDTO
} from 'wdBean'
import LoadMoreLayout from './LoadMoreLayout'
import NoMoreLayout from './NoMoreLayout'
import { CompParser } from '../CompParser'
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CustomSelectUI } from '../view/CustomSelectUI';
import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
import { BigPicCardComponent } from '../view/BigPicCardComponent';
@Entry
@Component
...
...
@@ -20,8 +21,8 @@ struct BrowsingHistoryPage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State allDatas :CompDTO[] = [];
@State selectDatas :CompDTO[] = [];
@State allDatas :ContentDTO[] = [];
@State selectDatas :ContentDTO[] = [];
@Provide deleteNum :number = 0;
@Provide isAllSelect:boolean = false
aboutToAppear(){
...
...
@@ -72,7 +73,7 @@ struct BrowsingHistoryPage {
})
}
ForEach(this.allDatas, (compDTO: Co
mp
DTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: Co
ntent
DTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
...
...
@@ -94,7 +95,7 @@ struct BrowsingHistoryPage {
}
@Builder
newCompParser(compDTO: Co
mp
DTO, compIndex: number){
newCompParser(compDTO: Co
ntent
DTO, compIndex: number){
Row(){
if (this.isEditState){
CustomSelectUI({
...
...
@@ -106,7 +107,7 @@ struct BrowsingHistoryPage {
.margin({left:16})
}
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex
})
BigPicCardComponent({contentDTO:compDTO
})
}
}
}
...
...
@@ -118,11 +119,11 @@ struct BrowsingHistoryPage {
async getData() {
this.browSingModel.currentPage = 1
MyCollectionViewModel.newFetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => {
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
MyCollectionViewModel.fetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => {
if (collectionItem && collectionItem.list && collectionItem.list.length > 0) {
this.browSingModel.viewType = ViewType.LOADED;
this.allDatas.push(...pageDto.compList)
if (pageDto.compList.length === this.browSingModel.pageSize) {
this.allDatas.push(...collectionItem.list)
if (collectionItem.list.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
} else {
...
...
@@ -136,7 +137,7 @@ struct BrowsingHistoryPage {
//数据处理
//单个选择
addCompDTO(isOn:boolean , compDTO: Co
mp
DTO){
addCompDTO(isOn:boolean , compDTO: Co
ntent
DTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
...
...
@@ -150,7 +151,7 @@ struct BrowsingHistoryPage {
//全选
allSelectDatas(isOn:boolean){
let datas: Co
mp
DTO[] = [];
let datas: Co
ntent
DTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
View file @
9a516bc
...
...
@@ -42,7 +42,7 @@ struct EditUserInfoPage {
build() {
Row() {
Column() {
CustomTitleUI({titleName:'
资料编辑
'})
CustomTitleUI({titleName:'
编辑资料
'})
Image(this.headerImg)
.alt($r('app.media.default_head'))
.backgroundColor(Color.Gray)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/MyCollectionListPage.ets
View file @
9a516bc
...
...
@@ -6,13 +6,15 @@ import { EmptyComponent } from '../view/EmptyComponent'
import { ErrorComponent } from '../view/ErrorComponent'
import RefreshLayout from './RefreshLayout'
import { RefreshLayoutBean } from './RefreshLayoutBean';
import { CompDTO } from 'wdBean'
import { CompDTO
, ContentDTO
} from 'wdBean'
import LoadMoreLayout from './LoadMoreLayout'
import NoMoreLayout from './NoMoreLayout'
import { CompParser } from '../CompParser'
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CustomSelectUI } from '../view/CustomSelectUI';
import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
import { BigPicCardComponent } from '../view/BigPicCardComponent';
import { contentListItemParams } from '../../model/MyCollectionModel';
@Entry
@Component
...
...
@@ -20,8 +22,8 @@ struct MyCollectionListPage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State allDatas :CompDTO[] = [];
@State selectDatas :CompDTO[] = [];
@State allDatas :ContentDTO[] = [];
@State selectDatas :ContentDTO[] = [];
@Provide deleteNum :number = 0;
@Provide isAllSelect:boolean = false
aboutToAppear(){
...
...
@@ -72,7 +74,7 @@ struct MyCollectionListPage {
})
}
ForEach(this.allDatas, (compDTO: Co
mp
DTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: Co
ntent
DTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
...
...
@@ -94,7 +96,7 @@ struct MyCollectionListPage {
}
@Builder
newCompParser(compDTO: Co
mp
DTO, compIndex: number){
newCompParser(compDTO: Co
ntent
DTO, compIndex: number){
Row(){
if (this.isEditState){
CustomSelectUI({
...
...
@@ -106,7 +108,7 @@ struct MyCollectionListPage {
.margin({left:16})
}
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex
})
BigPicCardComponent({contentDTO:compDTO
})
}
}
}
...
...
@@ -118,11 +120,11 @@ struct MyCollectionListPage {
async getData() {
this.browSingModel.currentPage = 1
MyCollectionViewModel.newFetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => {
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
MyCollectionViewModel.fetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => {
if (collectionItem && collectionItem.list && collectionItem.list.length > 0) {
this.browSingModel.viewType = ViewType.LOADED;
this.allDatas.push(...pageDto.compList)
if (pageDto.compList.length === this.browSingModel.pageSize) {
this.allDatas.push(...collectionItem.list)
if (collectionItem.list.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
} else {
...
...
@@ -136,7 +138,7 @@ struct MyCollectionListPage {
//数据处理
//单个选择
addCompDTO(isOn:boolean , compDTO: Co
mp
DTO){
addCompDTO(isOn:boolean , compDTO: Co
ntent
DTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
...
...
@@ -150,7 +152,7 @@ struct MyCollectionListPage {
//全选
allSelectDatas(isOn:boolean){
let datas: Co
mp
DTO[] = [];
let datas: Co
ntent
DTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
...
...
@@ -169,13 +171,22 @@ struct MyCollectionListPage {
//删除
deleteDatas(){
let deleteDatas:contentListItemParams[] = [];
for (let index = 0; index < this.selectDatas.length; index++) {
const compDTO = this.allDatas[index];
this.allDatas.splice(this.selectDatas.indexOf(compDTO),1)
const compDTO = this.selectDatas[index];
this.allDatas.splice(this.allDatas.indexOf(compDTO),1)
deleteDatas.push({contentId:compDTO.objectId,contentType:compDTO.objectType,relType:compDTO.relType,contentRelId:compDTO.relId})
}
MyCollectionViewModel.executeCollcet({
delAll:this.isAllSelect === true?1:0,
status:0,
contentList:deleteDatas
})
//重置删除状态
this.isEditState = false
this.isAllSelect = false
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
View file @
9a516bc
import { Logger, DateTimeUtils, CollectionUtils } from 'wdKit';
import { CommonConstants, CompStyle, ViewType } from 'wdConstant';
import { DateTimeUtils, Logger } from 'wdKit';
import PageViewModel from '../../viewmodel/PageViewModel';
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
...
...
@@ -11,8 +12,10 @@ import NoMoreLayout from './NoMoreLayout';
import LoadMoreLayout from './LoadMoreLayout';
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CompParser } from '../CompParser';
import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { CompDTO, LiveReviewDTO, PageDTO } from 'wdBean';
import { CompDTO, LiveReviewDTO, PageDTO ,PageInfoDTO} from 'wdBean';
const TAG = 'PageComponent';
...
...
@@ -155,11 +158,14 @@ export struct PageComponent {
this.pageModel.viewType = ViewType.EMPTY;
return;
}
Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id);
let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0);
if (groupInfo != null) {
this.pageModel.isRecGroup = groupInfo.groupStrategy === 1;
this.pageModel.groupId = groupInfo.id;
}
// pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代
for (const group of pageInfo.groups) {
this.pageDto = await PageViewModel.getPageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId
, this.pageModel.currentPage, this.pageModel.pageSize,group.groupStrategy, getContext(this))
// for (const group of pageInfo.groups) {
this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this))
this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) {
this.pageDto.compList.forEach((comp) => {
...
...
@@ -184,42 +190,12 @@ export struct PageComponent {
// })
this.isFirstIn = false
Logger.debug(TAG, 'cj111');
} else {
Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
this.pageModel.viewType = ViewType.EMPTY;
}
// } else {
// Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
// this.pageModel.viewType = ViewType.EMPTY;
// }
}
// this.isFirstIn = false
// let groupInfo: Group = CollectionUtils.getElement(pageInfo.groups, 0);
// if (groupInfo != null) {
// this.pageModel.groupStrategy = groupInfo.groupStrategy;
// this.pageModel.isRecGroup = groupInfo.groupStrategy === 1;
// this.pageModel.groupId = "" + groupInfo.id;
// }
// let pageDto = await PageViewModel.getPageData(this.pageModel.pageId, this.pageModel.pageId, this.pageModel.channelId
// , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this))
// this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
// this.pageModel.viewType = ViewType.LOADED;
// this.pageModel.compList.push(...pageDto.compList)
// if (pageDto.compList.length === this.pageModel.pageSize) {
// this.pageModel.currentPage++;
// this.pageModel.hasMore = true;
// } else {
// this.pageModel.hasMore = false;
// }
// // 二次请求,批查互动数据
// PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// this.pageModel.compList.replaceAll(...data)
// this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
// } else {
// Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
// this.pageModel.viewType = ViewType.EMPTY;
// }
}
async getPreviewData() {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/BigPicCardComponent.ets
View file @
9a516bc
...
...
@@ -19,8 +19,10 @@ export struct BigPicCardComponent {
aboutToAppear() {
// 取第一个数据
this.contentDTO = this.compDTO.operDataList[0];
this.contentDTO.appStyle = "2";
if (this.compDTO.operDataList) {
this.contentDTO = this.compDTO.operDataList[0];
this.contentDTO.appStyle = "2";
}
}
build() {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/areaPickerDialog/AreaPickerDialog.ets
View file @
9a516bc
import { Logger } from 'wdKit';
import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel';
import EditInfoViewModel from '../../../viewmodel/EditInfoViewModel';
import { FirstLevelComponent } from './FirstLevelComponent';
import { SecondLevelComponent } from './SecondLevelComponent';
import { ThirdLevelComponent } from './ThirdLevelComponent';
@CustomDialog
export struct AreaPickerDialog {
@Provide currentFirst: AreaListManageModel = new AreaListManageModel('','','',[])
@Provide currentSecondBean: AreaListManageModel = new AreaListManageModel('','','',[])
...
...
sight_harmony/features/wdComponent/src/main/ets/model/MyCollectionModel.ets
View file @
9a516bc
import { ContentDTO } from 'wdBean/Index';
// {
// "hasNext": 0,
...
...
@@ -22,24 +23,38 @@ export class MyCollectionModel{
}
}
@Observed
export class MyCollectionItem{
export class MyCollectionItem{
pageNum:number = 0
pageSize:number = 0
totalCount:number = 0
hasNext:number = 0
list:MyCollectionModel[] = []
list:ContentDTO[] = []
constructor(list?:ContentDTO[],pageNum?: number,pageSize?: number,totalCount?: number,hasNext?:number) {
}
}
export interface MyCollectionListModel{
data: MyCollectionItem
code: number
message: string
success: string
timestamp: number
}
export class MyCollectionListModel{
list:MyCollectionModel[] = []
pageNum: number = 0
pageSize: number = 20
totalCount: number = 0
constructor(list?:MyCollectionModel[],pageNum?: number,pageSize?: number,totalCount?: number) {
}
export interface contentListItemParams{
contentId?:string;
contentType?:string;
relType?:string;
contentRelId?:string;
}
export interface collcetRecordParams {
delAll?: number;
status?: number;
contentList?: contentListItemParams[];
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
View file @
9a516bc
...
...
@@ -6,7 +6,6 @@ import {
CompInfoBean,
ContentDetailDTO,
ContentDTO,
contentListParams,
InteractDataDTO,
LiveReviewDTO,
MorningEveningPaperDTO,
...
...
@@ -18,6 +17,8 @@ import {
postBatchAttentionStatusParams,
postBatchAttentionStatusResult,
postExecuteCollectRecordParams,
contentListParams,
PageInfoDTO,
postExecuteLikeParams,
postInteractAccentionOperateParams,
postRecommendListParams
...
...
@@ -185,9 +186,15 @@ export class PageRepository {
let url = PageRepository.getPageUrl(pageId)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers)
}
static fetchPageData(pageId: string) {
let url = PageRepository.getPageInfoUrl(pageId)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers)
};
static fetch
Page
Data(pageId: string, groupId: string, channelId: string,groupStrategy:number, currentPage: number, pageSize: number) {
static fetch
Comp
Data(pageId: string, groupId: string, channelId: string,groupStrategy:number, currentPage: number, pageSize: number) {
let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId,groupStrategy, currentPage, pageSize)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/PullDownRefresh.ets
View file @
9a516bc
...
...
@@ -71,8 +71,7 @@ export function touchUpPullRefresh(pageModel: PageModel) {
pageModel.currentPage = 1;
setTimeout(() => {
let self: PageModel = pageModel;
PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize,self.groupStrategy, getContext())
PageViewModel.getPageData(self, getContext())
.then((data: PageDTO) => {
self.timestamp = DateTimeUtils.getTimeStamp().toString()
if (data == null || data.compList == null || data.compList.length == 0) {
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/PullUpLoadMore.ets
View file @
9a516bc
...
...
@@ -28,7 +28,7 @@ export function touchUpLoadMore(model: PageModel) {
self.isLoading = true;
setTimeout(() => {
closeLoadMore(model);
PageViewModel.getPageData(self
.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize,self.groupStrategy
, getContext())
PageViewModel.getPageData(self, getContext())
.then((data: PageDTO) => {
self.timestamp = DateTimeUtils.getTimeStamp().toString()
if (data == null || data.compList == null || data.compList.length == 0) {
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/MyCollectionViewModel.ets
View file @
9a516bc
import { MyCollectionListModel } from '../model/MyCollectionModel';
import {
collcetRecordParams, MyCollectionItem,
MyCollectionListModel } from '../model/MyCollectionModel';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger, ResourcesUtils } from 'wdKit';
import { PageDTO } from 'wdBean';
import promptAction from '@ohos.promptAction';
const TAG = "MyCollectionViewModel"
class MyCollectionViewModel {
private static instance:MyCollectionViewModel
/**
* 单例模式
* @returns
...
...
@@ -20,84 +20,48 @@ class MyCollectionViewModel {
return MyCollectionViewModel.instance;
}
BaseGetRequest(type:number,tagId:string,pageNum:string){
let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${1}&pageSize=${20}&pageNum=${pageNum}`
if (tagId.length > 0) {
url = url + `&tagId=${tagId}`
}
//Type 1 收藏 2 浏览历史
//tagId 收藏界面 标签筛选
BaseGetRequest(type:number,tagId:string,pageNum:number){
let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${2}&pageSize=${20}&pageNum=${pageNum.toString()}`
// if (tagId.length > 0) {
// url = url + `&tagId=${tagId}`
// }
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
return WDHttp.get<
ResponseDTO<MyCollectionListModel>
>(url, headers)
return WDHttp.get<
MyCollectionListModel
>(url, headers)
}
async getAppointmentListDataLocal(context: Context): Promise<MyCollectionListModel> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<MyCollectionListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MyCollectionListModel>>(context,'browsingHistory_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return new MyCollectionListModel()
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
//Type 1 收藏 2 浏览历史
//tagId 收藏界面 标签筛选
fetchMyCollectList(type:number,tagId:string,pageNum:string,context: Context):Promise<MyCollectionListModel>{
return new Promise<MyCollectionListModel>((success,error) => {
this.BaseGetRequest(type,tagId,pageNum).then((navResDTO: ResponseDTO<MyCollectionListModel>) => {
fetchMyCollectList(type:number,tagId:string,pageNum:number,context: Context):Promise<MyCollectionItem>{
return new Promise((success,error) => {
this.BaseGetRequest(type,tagId,pageNum).then((navResDTO: MyCollectionListModel) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getAppointmentListDataLocal(context))
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
let listData = navResDTO.data as MyCollectionListModel
success(listData)
Logger.info(TAG, "fetchMyCollectList then,navResDTO.timeStamp:" + navResDTO.timestamp);
success(navResDTO.data)
}).catch((err: Error) => {
Logger.error(TAG, `fetch
AppointmentListDataApi
catch, error.name : ${err.name}, error.message:${err.message}`);
Logger.error(TAG, `fetch
MyCollectList
catch, error.name : ${err.name}, error.message:${err.message}`);
error("page data invalid");
})
})
}
newBaseGetRequest(type:number,tagId:string,pageNum:number){
let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${1}&pageSize=${20}&pageNum=${pageNum.toString()}`
if (tagId.length > 0) {
url = url + `&tagId=${tagId}`
}
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
}
newFetchMyCollectList(type:number,tagId:string,pageNum:number,context: Context):Promise<PageDTO>{
return new Promise<PageDTO>((success,error) => {
success(this.newGetAppointmentListDataLocal(type,context))
return
this.newBaseGetRequest(type,tagId,pageNum).then((navResDTO: ResponseDTO<PageDTO>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.newGetAppointmentListDataLocal(type,context))
return
//收藏/取消收藏 status :收藏状态 1添加收藏 0取消收藏
executeCollcet(params: collcetRecordParams):Promise<ResponseDTO>{
return new Promise(() => {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
WDHttp.post<ResponseDTO>(HttpUrlUtils.getExecuteCollcetUrl(),params,headers).then((navResDTO: ResponseDTO) => {
if (navResDTO.code == 0) {
promptAction.showToast({ message: '删除成功' })
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
let listData = navResDTO.data as PageDTO
success(listData)
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
error("page data invalid");
})
.catch((error: Error) => {
Logger.info(TAG,'executeCollcet','ResponseDTO')
})
})
}
async newGetAppointmentListDataLocal(type:number, context: Context): Promise<PageDTO> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<PageDTO> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<PageDTO>>(context,type == 1?'MyCollection_list_data.json':'browsingHistory_list_data.json');
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return {} as PageDTO
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
}
const collectionViewModel = MyCollectionViewModel.getInstance();
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageModel.ets
View file @
9a516bc
...
...
@@ -8,6 +8,7 @@ export default class PageModel {
pageId: string = "";
groupId: string = "";
channelId: string = "";
isRecGroup: boolean = false;
compList: LazyDataSource<CompDTO> = new LazyDataSource();
// 页面状态,刷新、加载更多等
currentPage: number = 1;
...
...
@@ -35,5 +36,4 @@ export default class PageModel {
// keyGenerator相关字符串,用于刷新list布局
timestamp: String = '1';
groupStrategy: number = 0;
isRecGroup: boolean = false;
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageViewModel.ets
View file @
9a516bc
...
...
@@ -7,13 +7,16 @@ import {
MorningEveningPaperDTO,
NavigationBodyDTO,
PageDTO,
PageInfoBean
PageInfoBean,
PageInfoDTO
} from 'wdBean';
import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit';
import { ResponseDTO, } from 'wdNetwork';
import { PageRepository } from '../repository/PageRepository';
import { BaseViewModel } from './BaseViewModel';
import PageModel from './PageModel';
const TAG = 'PageViewModel';
/**
...
...
@@ -140,14 +143,14 @@ export class PageViewModel extends BaseViewModel {
return compRes.data
}
async getPageData(pageId: string, groupId: string, channelId: string, currentPage: number
, pageSize: number,groupStrategy:number, context: Context): Promise<PageDTO> {
Logger.debug(TAG, 'getPageData pageId: ' + pageId);
if (mock_switch) {
return this.getPageData1(currentPage, context);
}
async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> {
Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId);
return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.isRecGroup==true?1:0,pageModel.currentPage, pageModel.pageSize))
}
private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> {
return new Promise<PageDTO>((success, error) => {
PageRepository.fetchPageData(pageId, groupId, channelId,groupStrategy, currentPage, pageSize)
getData
.then((resDTO: ResponseDTO<PageDTO>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getNavData then resDTO is empty');
...
...
Please
register
or
login
to post a comment