wangliang_wd

feat:优化我的收藏编辑状态逻辑,优化list刷新逻辑

Showing 24 changed files with 376 additions and 234 deletions
... ... @@ -73,6 +73,10 @@ export class CompDTO implements BaseDTO {
sceneId: string = '';
traceId: string = '';
traceInfo: string = '';
// 是否是我的收藏 编辑状态
isCollectionEditting:boolean = false;
isSelect: boolean = false;
/**
* 创建新的compbean对象
* @param old
... ...
... ... @@ -93,7 +93,6 @@ export class ContentDTO implements BaseDTO {
slideShows: slideShows[] = [];
voiceInfo: VoiceInfoDTO = {} as VoiceInfoDTO;
tagWord: number = -1;
isSelect: boolean = false;
rmhInfo: RmhInfoDTO = {} as RmhInfoDTO; // 人民号信息
photoNum: number = 0;
corner: string = '';
... ... @@ -148,6 +147,10 @@ export class ContentDTO implements BaseDTO {
// 号主页评论列表点击跳转到视频详情判断评论弹框是否展开
showComment?:boolean = false;
// 是否是我的收藏 编辑状态
isCollectionEditting:boolean = false;
isSelect: boolean = false;
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
content.liveType = old.liveType;
... ... @@ -218,6 +221,7 @@ export class ContentDTO implements BaseDTO {
content.bottomNavId = old.bottomNavId;
content.openType = old.openType;
content.extra = old.extra;
content.isCollectionEditting = old.isCollectionEditting
return content;
}
}
\ No newline at end of file
... ...
... ... @@ -72,7 +72,7 @@ export struct topicInfoView {
.margin({ left: 4, right: 7 })
}
.backgroundColor($r('app.color.color_99636363'))
.margin({ top: 8, left: 16, right: 16, bottom: 16 })
.margin({ top: 8, left: 16, right: 16, bottom: 4 })
.borderRadius(2)
.onClick(()=>{
let contentDTO :ContentDTO = new ContentDTO();
... ...
... ... @@ -243,6 +243,12 @@ export struct RmhTitle {
.height(36)
.margin({ bottom: 10 })
.onClick(()=>{
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
this.gotoPeopleShipHomePage()
})
}
... ...
... ... @@ -162,6 +162,12 @@ export struct Card10Component {
.borderRadius($r('app.float.button_border_radius'))
.justifyContent(FlexAlign.Center)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
ProcessUtils.processPage(this.contentDTO)
})
... ... @@ -292,6 +298,12 @@ export struct Card10ComponentTimelineItem {
}
.padding({ top: 10, bottom: 10 })
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
this.isRead = true
persistentStorage(this.slideItem.newsId);
... ...
... ... @@ -97,6 +97,12 @@ export struct Card11Component {
})
.backgroundColor($r("app.color.white"))
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -87,6 +87,12 @@ export struct Card12Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -108,6 +108,12 @@ export struct Card14Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -106,6 +106,11 @@ export struct Card15Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -139,6 +139,12 @@ export struct Card16Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -123,6 +123,12 @@ export struct Card17Component {
.width(CommonConstants.FULL_WIDTH)
.margin({ top: 8 })
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -97,6 +97,12 @@ export struct Card19Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -104,7 +104,7 @@ export struct Card20Component {
}.alignContent(Alignment.TopStart)
}
if (this.contentDTO.fullColumnImgUrls[0]) {
createImg({ contentDTO: this.contentDTO, loadImg: this.loadImg })
createImg({ compDTO:this.compDTO,contentDTO: this.contentDTO, loadImg: this.loadImg })
}
CarderInteraction({contentDTO: this.contentDTO})
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
... ... @@ -118,6 +118,12 @@ export struct Card20Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ... @@ -137,6 +143,7 @@ interface radiusType {
@Component
struct createImg {
@State compDTO: CompDTO = new CompDTO()
@Prop contentDTO: ContentDTO
@Prop loadImg: boolean = true;
... ... @@ -169,6 +176,12 @@ struct createImg {
.align(Alignment.BottomEnd)
}
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
ProcessUtils.gotoVod(this.contentDTO)
})
} else {
... ... @@ -191,6 +204,12 @@ struct createImg {
}
.align(Alignment.BottomEnd)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
ProcessUtils.gotoVod(this.contentDTO)
})
}
... ...
... ... @@ -97,6 +97,12 @@ export struct Card21Component {
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -135,6 +135,12 @@ export struct Card2Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -93,6 +93,12 @@ export struct Card3Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -131,6 +131,12 @@ export struct Card4Component {
.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.Start)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -149,6 +149,11 @@ export struct Card5Component {
.backgroundColor(0xffffff)
.width(CommonConstants.FULL_WIDTH)
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
... ... @@ -129,6 +129,11 @@ export struct Card6Component {
}
.onClick((event: ClickEvent) => {
///我的收藏 编辑状态点击
if (this.compDTO.isCollectionEditting) {
this.compDTO.isSelect = this.compDTO.isSelect?false:true
return;
}
InfomationCardClick.track(this.compDTO, this.contentDTO, this.pageId, this.pageName)
if (router.getState().name !== 'MyCollectionListPage') {
this.clicked = true;
... ...
import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI'
import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel';
import PageModel from '../../viewmodel/PageModel';
import { CommonConstants, ViewType } from 'wdConstant'
import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'
import { ErrorComponent } from '../view/ErrorComponent'
import RefreshLayout from './RefreshLayout'
import { RefreshLayoutBean } from './RefreshLayoutBean';
import { CompDTO, ContentDTO } from 'wdBean'
import NoMoreLayout from './NoMoreLayout'
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CustomSelectUI } from '../view/CustomSelectUI';
import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
import { BigPicCardComponent } from '../view/BigPicCardComponent';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
@Entry
@Component
struct BrowsingHistoryPage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State allDatas :ContentDTO[] = [];
@State selectDatas :ContentDTO[] = [];
@Provide deleteNum :number = 0;
@Provide isAllSelect:boolean = false
private scroller: Scroller = new Scroller();
aboutToAppear(){
this.getData()
}
build() {
Column(){
CustomTitleAndEditUI({titleName:'浏览历史',isDisplayButton:true,editCallback:()=>{
this.allSelectDatas(false)
this.isAllSelect = false
this.selectDatas = []
this.deleteNum = 0
}})
// if (this.browSingModel.viewType == ViewType.LOADING){
// this.LoadingLayout()
// }else if(this.browSingModel.viewType == ViewType.ERROR){
// ErrorComponent()
// }else if(this.browSingModel.viewType == ViewType.EMPTY){
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoHistory})
// }else {
// CustomPullToRefresh({
// alldata:this.allDatas,
// scroller:this.scroller,
// customList:()=>{
// this.ListLayout()
// },
// onRefresh:(resolve)=>{
// this.browSingModel.currentPage = 0
// this.getData(resolve)
// },
// onLoadMore:(resolve)=> {
// this.browSingModel.currentPage++
// this.getData()
// }
// })
// }
if (this.isEditState){
CustomBottomFuctionUI({
selectAllCallback:(isAllSelect)=>{
this.allSelectDatas(isAllSelect)
},
confirmCallback:()=>{
this.deleteDatas()
}
})
.position({y:'92%'})
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
@Builder ListLayout() {
List({scroller: this.scroller}) {
// 下拉刷新
ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
})
// 加载更多
ListItem() {
if (this.browSingModel.hasMore) {
// LoadMoreLayout({
// refreshBean: new RefreshLayoutBean(this.browSingModel.isVisiblePullUpLoad, this.browSingModel.pullUpLoadImage,
// this.browSingModel.pullUpLoadText, this.browSingModel.pullUpLoadHeight)
// })
} else {
NoMoreLayout()
}
}
}
.height(CommonConstants.FULL_PARENT)
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
}
@Builder
newCompParser(compDTO: ContentDTO, compIndex: number){
Row(){
if (this.isEditState){
CustomSelectUI({
isOn:compDTO.isSelect,
selectCallback:(isOn)=>{
this.addCompDTO(isOn,compDTO)
}
})
.margin({left:16})
}
Column() {
BigPicCardComponent({compDTO:new CompDTO,contentDTO:compDTO})
}
}
}
@Builder LoadingLayout() {
CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true,
$r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.browSingModel.pullDownRefreshHeight) })
}
async getData(resolve?: (value: string | PromiseLike<string>) => void){
MyCollectionViewModel.fetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => {
if(resolve) resolve('刷新成功')
if (collectionItem && collectionItem.list && collectionItem.list.length > 0) {
this.browSingModel.viewType = ViewType.LOADED;
this.allDatas.push(...collectionItem.list)
if (collectionItem.list.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
} else {
this.browSingModel.hasMore = false;
}
} else {
this.browSingModel.viewType = ViewType.EMPTY;
}
})
}
//数据处理
//单个选择
addCompDTO(isOn:boolean , compDTO: ContentDTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
}else {
this.selectDatas.splice(this.selectDatas.indexOf(compDTO),1)
}
this.deleteNum = this.selectDatas.length
this.isAllSelect = this.deleteNum === this.allDatas.length?true:false;
}
//全选
allSelectDatas(isOn:boolean){
let datas: ContentDTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
datas.push(compDTO)
}
this.selectDatas = []
this.allDatas = []
if (isOn === true) {
this.selectDatas.push(...datas)
}else {
this.selectDatas.splice(0,this.deleteNum)
}
this.allDatas.push(...datas)
this.deleteNum = this.selectDatas.length
}
//删除
deleteDatas(){
for (let index = 0; index < this.selectDatas.length; index++) {
const compDTO = this.allDatas[index];
this.allDatas.splice(this.selectDatas.indexOf(compDTO),1)
}
//重置删除状态
this.isEditState = false
this.isAllSelect = false
}
}
// import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI'
// import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel';
// import PageModel from '../../viewmodel/PageModel';
// import { CommonConstants, ViewType } from 'wdConstant'
// import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'
// import { ErrorComponent } from '../view/ErrorComponent'
// import RefreshLayout from './RefreshLayout'
// import { RefreshLayoutBean } from './RefreshLayoutBean';
// import { CompDTO, ContentDTO } from 'wdBean'
// import NoMoreLayout from './NoMoreLayout'
// import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
// import { CustomSelectUI } from '../view/CustomSelectUI';
// import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
// import { BigPicCardComponent } from '../view/BigPicCardComponent';
//
// import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
//
// @Entry
// @Component
// struct BrowsingHistoryPage {
// @State private browSingModel: PageModel = new PageModel()
// isloading : boolean = false
// @Provide isEditState:boolean = false
// @State allDatas :ContentDTO[] = [];
// @State selectDatas :ContentDTO[] = [];
// @Provide deleteNum :number = 0;
// @Provide isAllSelect:boolean = false
// private scroller: Scroller = new Scroller();
//
// aboutToAppear(){
// this.getData()
// }
//
// build() {
// Column(){
// CustomTitleAndEditUI({titleName:'浏览历史',isDisplayButton:true,editCallback:()=>{
// this.allSelectDatas(false)
// this.isAllSelect = false
// this.selectDatas = []
// this.deleteNum = 0
// }})
//
// // if (this.browSingModel.viewType == ViewType.LOADING){
// // this.LoadingLayout()
// // }else if(this.browSingModel.viewType == ViewType.ERROR){
// // ErrorComponent()
// // }else if(this.browSingModel.viewType == ViewType.EMPTY){
// EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoHistory})
// // }else {
// // CustomPullToRefresh({
// // alldata:this.allDatas,
// // scroller:this.scroller,
// // customList:()=>{
// // this.ListLayout()
// // },
// // onRefresh:(resolve)=>{
// // this.browSingModel.currentPage = 0
// // this.getData(resolve)
// // },
// // onLoadMore:(resolve)=> {
// // this.browSingModel.currentPage++
// // this.getData()
// // }
// // })
// // }
//
// if (this.isEditState){
// CustomBottomFuctionUI({
// selectAllCallback:(isAllSelect)=>{
// this.allSelectDatas(isAllSelect)
// },
// confirmCallback:()=>{
// this.deleteDatas()
// }
// })
// .position({y:'92%'})
// }
// }
// .width(CommonConstants.FULL_WIDTH)
// .height(CommonConstants.FULL_HEIGHT)
// }
//
// @Builder ListLayout() {
// List({scroller: this.scroller}) {
// // 下拉刷新
// ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => {
// ListItem() {
// this.newCompParser(compDTO,compIndex)
// }
// })
// // 加载更多
// ListItem() {
// if (this.browSingModel.hasMore) {
// // LoadMoreLayout({
// // refreshBean: new RefreshLayoutBean(this.browSingModel.isVisiblePullUpLoad, this.browSingModel.pullUpLoadImage,
// // this.browSingModel.pullUpLoadText, this.browSingModel.pullUpLoadHeight)
// // })
// } else {
// NoMoreLayout()
// }
// }
// }
// .height(CommonConstants.FULL_PARENT)
// .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
// }
//
// @Builder
// newCompParser(compDTO: ContentDTO, compIndex: number){
// Row(){
// if (this.isEditState){
// CustomSelectUI({
// data:compDTO,
// })
// .margin({left:16})
// }
// Column() {
// BigPicCardComponent({compDTO:new CompDTO,contentDTO:compDTO})
// }
// }
// }
//
// @Builder LoadingLayout() {
// CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true,
// $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.browSingModel.pullDownRefreshHeight) })
// }
//
// async getData(resolve?: (value: string | PromiseLike<string>) => void){
// MyCollectionViewModel.fetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => {
// if(resolve) resolve('刷新成功')
// if (collectionItem && collectionItem.list && collectionItem.list.length > 0) {
// this.browSingModel.viewType = ViewType.LOADED;
// this.allDatas.push(...collectionItem.list)
// if (collectionItem.list.length === this.browSingModel.pageSize) {
// this.browSingModel.currentPage++;
// this.browSingModel.hasMore = true;
// } else {
// this.browSingModel.hasMore = false;
// }
// } else {
// this.browSingModel.viewType = ViewType.EMPTY;
// }
// })
// }
//
// //数据处理
// //单个选择
// addCompDTO(isOn:boolean , compDTO: ContentDTO){
// compDTO.isSelect = isOn;
// if (isOn === true){
// this.selectDatas.push(compDTO)
// }else {
// this.selectDatas.splice(this.selectDatas.indexOf(compDTO),1)
// }
// this.deleteNum = this.selectDatas.length
//
// this.isAllSelect = this.deleteNum === this.allDatas.length?true:false;
// }
//
// //全选
// allSelectDatas(isOn:boolean){
// let datas: ContentDTO[] = [];
// for (let index = 0; index < this.allDatas.length; index++) {
// const compDTO = this.allDatas[index];
// compDTO.isSelect = isOn
// datas.push(compDTO)
// }
// this.selectDatas = []
// this.allDatas = []
// if (isOn === true) {
// this.selectDatas.push(...datas)
// }else {
// this.selectDatas.splice(0,this.deleteNum)
// }
// this.allDatas.push(...datas)
// this.deleteNum = this.selectDatas.length
// }
//
// //删除
// deleteDatas(){
// for (let index = 0; index < this.selectDatas.length; index++) {
// const compDTO = this.allDatas[index];
// this.allDatas.splice(this.selectDatas.indexOf(compDTO),1)
// }
//
// //重置删除状态
// this.isEditState = false
// this.isAllSelect = false
// }
// }
... ...
... ... @@ -12,7 +12,7 @@ import { BigPicCardComponent } from '../view/BigPicCardComponent';
import { contentListItemParams, MyCollectionItem } from '../../model/MyCollectionModel';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import { MyCustomDialog } from '../reusable/MyCustomDialog'
import { NetworkUtil } from 'wdKit/Index';
import { DateTimeUtils, NetworkUtil } from 'wdKit/Index';
import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils'
import { TrackConstants, TrackingButton, TrackingContent, TrackParamConvert } from 'wdTracking/Index';
... ... @@ -27,8 +27,8 @@ struct MyCollectionListPage {
isloading : boolean = false
@Provide isEditState:boolean = false
@State isDisplayButton:boolean = false
@State allDatas :ContentDTO[] = [];
@State selectDatas :ContentDTO[] = [];
@State allDatas :CompDTO[] = [];
@State selectDatas :CompDTO[] = [];
@Provide deleteNum :number = 0;
@Provide isAllSelect:boolean = false
... ... @@ -75,6 +75,9 @@ struct MyCollectionListPage {
Column(){
CustomTitleAndEditUI({titleName:'我的收藏',isDisplayButton:this.isDisplayButton,editCallback:()=>{
this.allSelectDatas(false)
this.allDatas.forEach((item) =>{
item.isCollectionEditting = this.isEditState
})
this.isAllSelect = false
this.selectDatas = []
this.deleteNum = 0
... ... @@ -120,7 +123,7 @@ struct MyCollectionListPage {
}
.backgroundColor(Color.White)
.alignContent(Alignment.Top)
.position({y:'92%'})
.position({y:'94%'})
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
... ... @@ -134,14 +137,14 @@ struct MyCollectionListPage {
@Builder ListLayout() {
List({scroller: this.scroller}) {
ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
})
}, (item: string) => DateTimeUtils.getTimeStamp().toString())
// 加载更多
ListItem() {
if (this.browSingModel.hasMore === false) NoMoreLayout()
if (this.browSingModel.hasMore === false) NoMoreLayout().height(this.isEditState?120:80)
//Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 0, right: 0 });
}
}
... ... @@ -155,26 +158,22 @@ struct MyCollectionListPage {
}
@Builder
newCompParser(compDTO: ContentDTO, compIndex: number){
newCompParser(compDTO: CompDTO, compIndex: number){
Row(){
if (this.isEditState){
CustomSelectUI({
isOn:compDTO.isSelect,
selectCallback:(isOn)=>{
this.addCompDTO(isOn,compDTO)
}
data:compDTO,
selectCallback:((item)=>{
this.addCompDTO(compDTO.isSelect,compDTO)
})
}).margin({right: 16})
}
Column() {
BigPicCardComponent({compDTO:new CompDTO,contentDTO:compDTO,pageId:TrackConstants.PageName.My_Collect,pageName:TrackConstants.PageName.My_Collect})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 });
}
BigPicCardComponent({compDTO:compDTO,contentDTO:compDTO.operDataList[0],pageId:TrackConstants.PageName.My_Collect,pageName:TrackConstants.PageName.My_Collect})
}.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => {
if (isVisible && !this.isEditState) {
TrackingContent.common(TrackConstants.EventType.Show, TrackConstants.PageName.My_Collect,TrackConstants.PageName.My_Collect, TrackParamConvert.program(compDTO))
TrackingContent.common(TrackConstants.EventType.Show, TrackConstants.PageName.My_Collect,TrackConstants.PageName.My_Collect, TrackParamConvert.program(compDTO.operDataList[0]))
}
})
}
... ... @@ -212,8 +211,7 @@ struct MyCollectionListPage {
//数据处理
//单个选择
addCompDTO(isOn:boolean , compDTO: ContentDTO){
compDTO.isSelect = isOn;
addCompDTO(isOn:boolean , compDTO: CompDTO){
if (isOn === true){
this.selectDatas.push(compDTO)
}else {
... ... @@ -226,20 +224,18 @@ struct MyCollectionListPage {
//全选
allSelectDatas(isOn:boolean){
let datas: ContentDTO[] = [];
let datas: CompDTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
datas.push(compDTO)
}
this.selectDatas = []
this.allDatas = []
if (isOn === true) {
this.selectDatas.push(...datas)
}else {
this.selectDatas.splice(0,this.deleteNum)
}
this.allDatas.push(...datas)
this.deleteNum = this.selectDatas.length
}
... ... @@ -265,6 +261,9 @@ struct MyCollectionListPage {
updataUIState(){
this.isEditState = false
this.isAllSelect = false
this.allDatas.forEach((item) =>{
item.isCollectionEditting = false
})
if (this.allDatas.length === 0) {
this.browSingModel.viewType = ViewType.EMPTY;
... ... @@ -290,22 +289,44 @@ struct MyCollectionListPage {
if (this.currentPage === 1) {
this.allDatas = []
this.isAllSelect = false
this.selectDatas = []
this.deleteNum = 0
}
for (let index = 0; index < item.list.length; index++) {
const compDTO = item.list[index];
compDTO.isCollection = true ///用于时间展示
compDTO.interactData = this.commentList[index]
const contentDTO = item.list[index];
contentDTO.isCollection = true ///用于时间展示
contentDTO.interactData = this.commentList[index]
let compDTO = new CompDTO()
compDTO.operDataList.push(ContentDTO.clone(contentDTO))
compDTO.objectId = contentDTO.objectId
compDTO.objectType = contentDTO.objectType
compDTO.relType = contentDTO.relType
compDTO.relId = contentDTO.relId
compDTO.isCollectionEditting = this.isEditState
this.allDatas.push(compDTO)
}
} catch (exception) {
if (this.currentPage === 1) {
this.allDatas = []
this.isAllSelect = false
this.selectDatas = []
this.deleteNum = 0
}
for (let index = 0; index < item.list.length; index++) {
const compDTO = item.list[index];
compDTO.isCollection = true ///用于时间展示
const contentDTO = item.list[index];
contentDTO.isCollection = true ///用于时间展示
let compDTO = new CompDTO()
compDTO.operDataList.push(ContentDTO.clone(contentDTO))
compDTO.objectId = contentDTO.objectId
compDTO.objectType = contentDTO.objectType
compDTO.relType = contentDTO.relType
compDTO.relId = contentDTO.relId
compDTO.isCollectionEditting = this.isEditState
this.allDatas.push(compDTO)
}
}
... ...
import { CompDTO, ContentDTO } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { CardParser } from '../CardParser';
import { router } from '@kit.ArkUI';
const TAG: string = 'BigPicCardComponent';
... ... @@ -20,8 +21,8 @@ export struct BigPicCardComponent {
contentDTO: ContentDTO = new ContentDTO();
aboutToAppear() {
// 取第一个数据
if (this.compDTO.operDataList.length > 0) {
// 取第一个数据 ///我的收藏特殊处理
if (this.compDTO.operDataList.length > 0 && router.getState().name !== 'MyCollectionListPage') {
this.contentDTO = this.compDTO.operDataList[0];
this.contentDTO.appStyle = "2";
}
... ...
... ... @@ -48,7 +48,7 @@ export struct CustomBottomFuctionUI {
this.confirmCallback()
})
}
.height('8%')
.height('6%')
.width('100%')
.backgroundColor(Color.White)
}
... ...
import { CompDTO } from 'wdBean'
@Component
export struct CustomSelectUI {
@State isOn: boolean = false
selectCallback: (isOn: boolean) => void = () => {
@ObjectLink @Watch('selectChage') data:CompDTO
selectCallback: (item:CompDTO) => void = () => {
}
build() {
Button(){
Image(this.isOn?$r("app.media.MyCollection_selected_icon"):$r("app.media.MyCollection_unselected_icon"))
}
Image(this.data.isSelect?$r("app.media.MyCollection_selected_icon"):$r("app.media.MyCollection_unselected_icon"))
}.onClick(()=>{
this.data.isSelect = this.data.isSelect?false:true
})
.backgroundColor(Color.White)
.type(ButtonType.Normal)
.width(20)
.height(20)
.onClick(() => {
this.isOn = !this.isOn;
this.selectCallback(this.isOn)
})
}
selectChage(){
this.selectCallback(this.data)
}
}
\ No newline at end of file
... ...