陈剑华

Merge remote-tracking branch 'origin/main'

@@ -6,6 +6,7 @@ import { CommentCustomDialog } from './CommentCustomDialog'; @@ -6,6 +6,7 @@ import { CommentCustomDialog } from './CommentCustomDialog';
6 import { publishCommentModel } from '../model/PublishCommentModel'; 6 import { publishCommentModel } from '../model/PublishCommentModel';
7 import { HttpUtils } from 'wdNetwork/Index'; 7 import { HttpUtils } from 'wdNetwork/Index';
8 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; 8 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
  9 +import NoMoreLayout from '../../page/NoMoreLayout';
9 import { EmptyComponent } from '../../view/EmptyComponent'; 10 import { EmptyComponent } from '../../view/EmptyComponent';
10 11
11 const TAG = 'CommentComponent'; 12 const TAG = 'CommentComponent';
@@ -18,7 +19,7 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一 @@ -18,7 +19,7 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一
18 export struct CommentComponent { 19 export struct CommentComponent {
19 @State hasMore: boolean = true; 20 @State hasMore: boolean = true;
20 @State currentPage: number = 1; 21 @State currentPage: number = 1;
21 - // @State private browSingModel: commentListModel = new commentListModel() 22 + @State isComments: boolean = true
22 /*必传*/ 23 /*必传*/
23 @ObjectLink publishCommentModel: publishCommentModel 24 @ObjectLink publishCommentModel: publishCommentModel
24 listScroller: ListScroller = new ListScroller(); // scroller控制器 25 listScroller: ListScroller = new ListScroller(); // scroller控制器
@@ -27,6 +28,8 @@ export struct CommentComponent { @@ -27,6 +28,8 @@ export struct CommentComponent {
27 @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); 28 @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
28 @State dialogController: CustomDialogController | null = null; 29 @State dialogController: CustomDialogController | null = null;
29 30
  31 + // @State private browSingModel: commentListModel = new commentListModel()
  32 +
30 // 在自定义组件即将析构销毁时将dialogControlle置空 33 // 在自定义组件即将析构销毁时将dialogControlle置空
31 aboutToDisappear() { 34 aboutToDisappear() {
32 this.dialogController = null // 将dialogController置空 35 this.dialogController = null // 将dialogController置空
@@ -137,55 +140,60 @@ export struct CommentComponent { @@ -137,55 +140,60 @@ export struct CommentComponent {
137 List({ scroller: this.listScroller }) { 140 List({ scroller: this.listScroller }) {
138 ListItemGroup({ header: this.titleHeader() }) 141 ListItemGroup({ header: this.titleHeader() })
139 142
140 - LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {  
141 - if (item.hasMore) {  
142 - ListItemGroup({ header: this.CommentHeaderItem(item, index), footer: this.GroupFooterView(item, index) }) {  
143 - LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => {  
144 - ListItem() {  
145 - ChildCommentItem({  
146 - item: childItem,  
147 - dialogController: this.dialogController,  
148 - publishCommentModel: this.publishCommentModel  
149 - });  
150 - }  
151 - .onClick(() => {  
152 - console.log(TAG)  
153 - })  
154 - }, (childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()) 143 + if (!this.isComments) {
  144 + EmptyComponent({ emptyType: 17 })
  145 + .height(300)
  146 + } else {
  147 + LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
  148 + if (item.hasMore) {
  149 + ListItemGroup({
  150 + header: this.CommentHeaderItem(item, index),
  151 + footer: this.GroupFooterView(item, index)
  152 + }) {
  153 + LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => {
  154 + ListItem() {
  155 + ChildCommentItem({
  156 + item: childItem,
  157 + dialogController: this.dialogController,
  158 + publishCommentModel: this.publishCommentModel
  159 + });
  160 + }
  161 + .onClick(() => {
  162 + console.log(TAG)
  163 + })
  164 + }, (childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString())
  165 + }
  166 + } else {
  167 + ListItemGroup({ header: this.CommentHeaderItem(item, index) }) {
  168 + LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => {
  169 + ListItem() {
  170 + ChildCommentItem({
  171 + item: childItem,
  172 + dialogController: this.dialogController,
  173 + publishCommentModel: this.publishCommentModel
  174 + });
  175 + }
  176 + .onClick(() => {
  177 + console.log(TAG)
  178 + })
  179 + }, (childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString())
  180 + }
155 } 181 }
156 - } else {  
157 - ListItemGroup({ header: this.CommentHeaderItem(item, index) }) {  
158 - LazyForEach(item.childCommentsLazyDataSource, (childItem: commentItemModel, subIndex: number) => {  
159 - ListItem() {  
160 - ChildCommentItem({  
161 - item: childItem,  
162 - dialogController: this.dialogController,  
163 - publishCommentModel: this.publishCommentModel  
164 - });  
165 - }  
166 - .onClick(() => {  
167 - console.log(TAG)  
168 - })  
169 - }, (childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()) 182 + }, (item: commentItemModel, index: number) => JSON.stringify(item) + index.toString())
  183 +
  184 + // 加载更多
  185 + ListItem() {
  186 + if (this.hasMore === false) {
  187 + NoMoreLayout()
170 } 188 }
171 } 189 }
172 - }, (item: commentItemModel, index: number) => JSON.stringify(item) + index.toString())  
173 -  
174 - // 加载更多  
175 - ListItem() {  
176 - if (this.hasMore === false) {  
177 - // NoMoreLayout()  
178 - EmptyComponent({ emptyType: 17 })  
179 - .height(300)  
180 - }  
181 -  
182 } 190 }
  191 +
183 } 192 }
184 .onReachEnd(() => { 193 .onReachEnd(() => {
185 if (this.hasMore) { 194 if (this.hasMore) {
186 this.getData() 195 this.getData()
187 } 196 }
188 -  
189 }) 197 })
190 .enableScrollInteraction(false) 198 .enableScrollInteraction(false)
191 } 199 }
@@ -204,6 +212,10 @@ export struct CommentComponent { @@ -204,6 +212,10 @@ export struct CommentComponent {
204 this.publishCommentModel.totalCommentNumer = commentListModel.totalCommentNum + '' 212 this.publishCommentModel.totalCommentNumer = commentListModel.totalCommentNum + ''
205 } 213 }
206 214
  215 + if (commentListModel.list.length === 0) {
  216 + this.isComments = false
  217 + }
  218 +
207 if (commentListModel.hasNext === 0) { 219 if (commentListModel.hasNext === 0) {
208 this.hasMore = false; 220 this.hasMore = false;
209 } else { 221 } else {
@@ -226,7 +238,6 @@ export struct CommentComponent { @@ -226,7 +238,6 @@ export struct CommentComponent {
226 this.hasMore = false 238 this.hasMore = false
227 } 239 }
228 }) 240 })
229 -  
230 } 241 }
231 } 242 }
232 243