wangliang_wd

feat:优化编辑功能,我的收藏

Showing 19 changed files with 223 additions and 117 deletions
... ... @@ -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;
}
... ...
... ... @@ -35,6 +35,10 @@ export class HttpUrlUtils {
*/
static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
/**
* 推荐内容的展现comp接口
*/
static readonly HOTCOMP_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";
... ... @@ -131,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";
/**
* 个人中心 我的评论列表
*/
... ... @@ -447,7 +455,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
}
... ...
... ... @@ -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';
... ...
... ... @@ -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
... ...
... ... @@ -66,4 +66,5 @@ export interface ContentDTO {
slideShows: slideShows[],
voiceInfo: VoiceInfoDTO,
tagWord: number,
isSelect: boolean;
}
\ 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
... ...
... ... @@ -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: CompDTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
... ... @@ -94,7 +95,7 @@ struct BrowsingHistoryPage {
}
@Builder
newCompParser(compDTO: CompDTO, compIndex: number){
newCompParser(compDTO: ContentDTO, 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: CompDTO){
addCompDTO(isOn:boolean , compDTO: ContentDTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
... ... @@ -150,7 +151,7 @@ struct BrowsingHistoryPage {
//全选
allSelectDatas(isOn:boolean){
let datas: CompDTO[] = [];
let datas: ContentDTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
... ...
... ... @@ -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)
... ...
... ... @@ -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: CompDTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
... ... @@ -94,7 +96,7 @@ struct MyCollectionListPage {
}
@Builder
newCompParser(compDTO: CompDTO, compIndex: number){
newCompParser(compDTO: ContentDTO, 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: CompDTO){
addCompDTO(isOn:boolean , compDTO: ContentDTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
... ... @@ -150,7 +152,7 @@ struct MyCollectionListPage {
//全选
allSelectDatas(isOn:boolean){
let datas: CompDTO[] = [];
let datas: ContentDTO[] = [];
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
... ...
import { CommonConstants, ViewType } from 'wdConstant';
import { Logger, DateTimeUtils } from 'wdKit';
import { Logger, DateTimeUtils, CollectionUtils } from 'wdKit';
import PageViewModel from '../../viewmodel/PageViewModel';
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
... ... @@ -11,7 +11,8 @@ import NoMoreLayout from './NoMoreLayout';
import LoadMoreLayout from './LoadMoreLayout';
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CompParser } from '../CompParser';
import { CompDTO } from 'wdBean';
import { CompDTO,PageInfoDTO } from 'wdBean';
import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
const TAG = 'PageComponent';
... ... @@ -118,8 +119,19 @@ export struct PageComponent {
this.pageModel.groupId = this.pageId;
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
let pageDto = await PageViewModel.getPageData(this.pageModel.pageId, this.pageModel.pageId, this.pageModel.channelId
, this.pageModel.currentPage, this.pageModel.pageSize, getContext(this))
let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId);
if (pageInfo == null) {
this.pageModel.viewType = ViewType.EMPTY;
return;
}
let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0);
if (groupInfo != null) {
this.pageModel.isRecGroup = groupInfo.groupStrategy === 1;
this.pageModel.groupId = groupInfo.id;
}
let pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this))
this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
this.pageModel.viewType = ViewType.LOADED;
... ...
... ... @@ -19,9 +19,11 @@ export struct BigPicCardComponent {
aboutToAppear() {
// 取第一个数据
if (this.compDTO.operDataList) {
this.contentDTO = this.compDTO.operDataList[0];
this.contentDTO.appStyle = "2";
}
}
build() {
this.cardBuild();
... ...
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('','','',[])
... ...
import { ContentDTO } from 'wdBean/Index';
// {
// "hasNext": 0,
... ... @@ -22,24 +23,38 @@ export class MyCollectionModel{
}
}
@Observed
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
... ...
... ... @@ -17,7 +17,8 @@ import {
postExecuteLikeParams,
postExecuteCollectRecordParams,
contentListParams,
postInteractAccentionOperateParams
postInteractAccentionOperateParams,
PageInfoDTO
} from 'wdBean';
const TAG = 'HttpRequest';
... ... @@ -59,6 +60,23 @@ export class PageRepository {
Logger.info(TAG, "getCompInfoUrl url = " + url)
return url;
}
static getRecCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.HOTCOMP_PATH;
// TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
url = url + "?channelStrategy=1&loadStrategy=first_load"
+ "&districtCode=" + HttpUrlUtils.getDistrictCode()
+ "&provinceCode=" + HttpUrlUtils.getProvinceCode()
+ "&cityCode=" + HttpUrlUtils.getCityCode()
+ "&refreshTime=" + DateTimeUtils.getTimeStamp()
+ "&pageId=" + pageId
+ "&groupId=" + groupId
+ "&channelId=" + channelId
+ "&pageSize=" + pageSize
+ "&pageNum=" + currentPage;
// Logger.debug("TAG", 'getCompInfoUrl url: '+url);
Logger.info(TAG, "getCompInfoUrl url = " + url)
return url;
}
static getDetailInfoUrl(relId: string, contentId: string, relType: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH;
... ... @@ -156,12 +174,24 @@ export class PageRepository {
return WDHttp.get<ResponseDTO<MorningEveningPaperDTO>>(url, headers)
};
static fetchPageData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
static fetchPageData(pageId: string) {
let url = PageRepository.getPageInfoUrl(pageId)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers)
};
static fetchCompData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
};
static fetchRecCompData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {
let url = PageRepository.getRecCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
};
static fetchDetailData(relId: string, contentId: string, relType: string) {
let url = PageRepository.getDetailInfoUrl(relId, contentId, relType)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
... ...
... ... @@ -72,7 +72,7 @@ export function touchUpPullRefresh(pageModel: PageModel) {
setTimeout(() => {
let self: PageModel = pageModel;
PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize, getContext())
PageViewModel.getPageData(self, getContext())
.then((data: PageDTO) => {
self.timestamp = DateTimeUtils.getTimeStamp().toString()
if (data == null || data.compList == null || data.compList.length == 0) {
... ...
... ... @@ -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, getContext())
PageViewModel.getPageData(self, getContext())
.then((data: PageDTO) => {
self.timestamp = DateTimeUtils.getTimeStamp().toString()
if (data == null || data.compList == null || data.compList.length == 0) {
... ...
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, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
Logger.error(TAG, `fetchMyCollectList 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}`
}
//收藏/取消收藏 status :收藏状态 1添加收藏 0取消收藏
executeCollcet(params: collcetRecordParams):Promise<ResponseDTO>{
return new Promise(() => {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
WDHttp.post<ResponseDTO>(HttpUrlUtils.getExecuteCollcetUrl(),params,headers).then((navResDTO: ResponseDTO) => {
if (navResDTO.code == 0) {
promptAction.showToast({ message: '删除成功' })
}
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
}
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();
... ...
... ... @@ -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;
... ...
import { NavigationBodyDTO, PageDTO,InteractDataDTO,ContentBean, InteractParam,CompDTO,
MorningEveningPaperDTO } from 'wdBean';
MorningEveningPaperDTO,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';
/**
... ... @@ -130,14 +131,18 @@ export class PageViewModel extends BaseViewModel {
return compRes.data
}
async getPageData(pageId: string, groupId: string, channelId: string, currentPage: number
, pageSize: 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);
if (pageModel.isRecGroup) {
return this.parseComp(PageRepository.fetchRecCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.currentPage, pageModel.pageSize))
} else {
return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.currentPage, pageModel.pageSize))
}
}
private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> {
return new Promise<PageDTO>((success, error) => {
PageRepository.fetchPageData(pageId, groupId, channelId, currentPage, pageSize)
getData
.then((resDTO: ResponseDTO<PageDTO>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getNavData then resDTO is empty');
... ... @@ -276,6 +281,20 @@ export class PageViewModel extends BaseViewModel {
})
return param;
}
async getPageInfo(pageId: string): Promise<PageInfoDTO> {
return new Promise<PageInfoDTO>((success, error) => {
PageRepository.fetchPageData(pageId).then((resDTO: ResponseDTO<PageInfoDTO>) => {
if (this.isRespondsInvalid(resDTO, 'getPageInfo')) {
error("getPageInfo data invalid");
return
}
Logger.info(TAG, "getPageInfo then,resDTO.timeStamp:" + resDTO.timestamp);
success(resDTO.data as PageInfoDTO);
});
});
}
}
... ...