Showing
2 changed files
with
58 additions
and
40 deletions
| @@ -23,51 +23,60 @@ export struct MoreComponent { | @@ -23,51 +23,60 @@ export struct MoreComponent { | ||
| 23 | 23 | ||
| 24 | build() { | 24 | build() { |
| 25 | if (this.showDetail) { | 25 | if (this.showDetail) { |
| 26 | - ForEach(this.contentDTO.sameContentList, (item: ContentDTO, index: number) => { | ||
| 27 | - if (item.appStyle !== "9") { | ||
| 28 | - CardParser({compDTO:new CompDTO, contentDTO: item }) | ||
| 29 | - .padding({left: 10, right: 10}) | ||
| 30 | - } else { | ||
| 31 | - Column(){ | ||
| 32 | - Card9Component({ compDTO: new CompDTO, contentDTO:item, pageId: "", pageName: "" }) | ||
| 33 | - | ||
| 34 | - Divider() | ||
| 35 | - .width('100%') | ||
| 36 | - .color($r('app.color.color_F5F5F5')) | ||
| 37 | - .strokeWidth(4) | 26 | + Column(){ |
| 27 | + ForEach(this.contentDTO.sameContentList, (item: ContentDTO, index: number) => { | ||
| 28 | + if (item.appStyle !== "9") { | ||
| 29 | + CardParser({compDTO:new CompDTO, contentDTO: item ,isNeedDivider:index === this.contentDTO.sameContentList.length -1 ? false:true}) | ||
| 30 | + .padding({left: 6, right: 6}) | ||
| 31 | + } else { | ||
| 32 | + Column(){ | ||
| 33 | + Card9Component({ compDTO: new CompDTO, contentDTO:item, pageId: "", pageName: "" }) | ||
| 34 | + | ||
| 35 | + if(index != this.contentDTO.sameContentList.length -1){ | ||
| 36 | + Divider() | ||
| 37 | + .width('100%') | ||
| 38 | + .color($r('app.color.color_F5F5F5')) | ||
| 39 | + .strokeWidth(4) | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + .padding({left: 6, right: 6}) | ||
| 38 | } | 43 | } |
| 39 | - .padding({left: 10, right: 10}) | ||
| 40 | - } | ||
| 41 | - }) | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - } else { | ||
| 45 | - Column() { | ||
| 46 | - | ||
| 47 | - Row() { | ||
| 48 | - Text('点击展开更多相似') | ||
| 49 | - .fontSize(16) | ||
| 50 | - Text(`(${this.contentDTO.sameContentListSize})`) | ||
| 51 | - .fontSize(16) | ||
| 52 | - Image($r('app.media.comment_unfold')) | ||
| 53 | - .width(16) | ||
| 54 | - .height(16) | ||
| 55 | - } | ||
| 56 | - .justifyContent(FlexAlign.Center) | ||
| 57 | - .width('100%') | ||
| 58 | - .height(48) | ||
| 59 | - .backgroundColor(0xffffff) | ||
| 60 | - .onClick(() => { | ||
| 61 | - this.showDetail = true; | ||
| 62 | }) | 44 | }) |
| 63 | 45 | ||
| 64 | Divider() | 46 | Divider() |
| 65 | - .width('100%') | 47 | + .width('100%' ) |
| 66 | .color($r('app.color.color_F5F5F5')) | 48 | .color($r('app.color.color_F5F5F5')) |
| 67 | .strokeWidth(5) | 49 | .strokeWidth(5) |
| 50 | + } | ||
| 68 | 51 | ||
| 52 | + } else { | ||
| 53 | + Column(){ | ||
| 54 | + Column() { | ||
| 55 | + | ||
| 56 | + Row() { | ||
| 57 | + Text('点击展开更多相似') | ||
| 58 | + .fontSize(16) | ||
| 59 | + Text(`(${this.contentDTO.sameContentListSize})`) | ||
| 60 | + .fontSize(16) | ||
| 61 | + Image($r('app.media.comment_unfold')) | ||
| 62 | + .width(16) | ||
| 63 | + .height(16) | ||
| 64 | + } | ||
| 65 | + .justifyContent(FlexAlign.Center) | ||
| 66 | + .width('100%') | ||
| 67 | + .height(48) | ||
| 68 | + .backgroundColor(0xffffff) | ||
| 69 | + .onClick(() => { | ||
| 70 | + this.showDetail = true; | ||
| 71 | + }) | ||
| 72 | + } | ||
| 73 | + .padding({left: 10 + 6 , right: 10 + 6}) | ||
| 69 | } | 74 | } |
| 70 | - .padding({left: 10, right: 10}) | 75 | + |
| 76 | + Divider() | ||
| 77 | + .width('100%' ) | ||
| 78 | + .color($r('app.color.color_F5F5F5')) | ||
| 79 | + .strokeWidth(5) | ||
| 71 | } | 80 | } |
| 72 | 81 | ||
| 73 | 82 | ||
| @@ -75,6 +84,11 @@ export struct MoreComponent { | @@ -75,6 +84,11 @@ export struct MoreComponent { | ||
| 75 | } | 84 | } |
| 76 | 85 | ||
| 77 | dealSearchSameList() { | 86 | dealSearchSameList() { |
| 87 | + //来回返回,会重新触发 dealSearchSameList,如果已经获取过 sameList 不再重新获取 | ||
| 88 | + if(this.contentDTO.sameContentList.length > 0){ | ||
| 89 | + return | ||
| 90 | + } | ||
| 91 | + | ||
| 78 | let resultData : SearchDescription[] = JSON.parse(this.contentDTO.sameContentListJson) as SearchDescription[] | 92 | let resultData : SearchDescription[] = JSON.parse(this.contentDTO.sameContentListJson) as SearchDescription[] |
| 79 | 93 | ||
| 80 | let data: contentListParams = { | 94 | let data: contentListParams = { |
| @@ -283,13 +283,13 @@ export struct SearchResultContentComponent { | @@ -283,13 +283,13 @@ export struct SearchResultContentComponent { | ||
| 283 | if (this.data_rmh.length === 1) { | 283 | if (this.data_rmh.length === 1) { |
| 284 | ListItem() { | 284 | ListItem() { |
| 285 | FollowChildComponent({ data: this.bean, type: 1 ,searchText: decodeURI(this.keywords)}) | 285 | FollowChildComponent({ data: this.bean, type: 1 ,searchText: decodeURI(this.keywords)}) |
| 286 | - }.padding({ left: 10, right: 10 }) | 286 | + }.padding({ left: 10 + 6 , right: 10 + 6}) |
| 287 | } else { | 287 | } else { |
| 288 | ListItem() { | 288 | ListItem() { |
| 289 | Column() { | 289 | Column() { |
| 290 | this.SearchListUI() | 290 | this.SearchListUI() |
| 291 | } | 291 | } |
| 292 | - } | 292 | + }.padding({left: 6, right: 6}) |
| 293 | } | 293 | } |
| 294 | } | 294 | } |
| 295 | LazyForEach(this.data, (item: ContentDTO, index: number) => { | 295 | LazyForEach(this.data, (item: ContentDTO, index: number) => { |
| @@ -297,6 +297,7 @@ export struct SearchResultContentComponent { | @@ -297,6 +297,7 @@ export struct SearchResultContentComponent { | ||
| 297 | Column() { | 297 | Column() { |
| 298 | if (this.searchType == "activity") { | 298 | if (this.searchType == "activity") { |
| 299 | ActivityItemComponent({ contentDTO: item }) | 299 | ActivityItemComponent({ contentDTO: item }) |
| 300 | + .padding({left: 6, right: 6}) | ||
| 300 | } else if (item.sameContentListSize > 0) { | 301 | } else if (item.sameContentListSize > 0) { |
| 301 | MoreComponent({ contentDTO: item }) | 302 | MoreComponent({ contentDTO: item }) |
| 302 | } else if (item.appStyle == "9") { | 303 | } else if (item.appStyle == "9") { |
| @@ -309,8 +310,10 @@ export struct SearchResultContentComponent { | @@ -309,8 +310,10 @@ export struct SearchResultContentComponent { | ||
| 309 | }) | 310 | }) |
| 310 | Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 }) | 311 | Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 }) |
| 311 | } | 312 | } |
| 313 | + .padding({left: 6, right: 6}) | ||
| 312 | } else { | 314 | } else { |
| 313 | CardParser({ compDTO: new CompDTO, contentDTO: item }) | 315 | CardParser({ compDTO: new CompDTO, contentDTO: item }) |
| 316 | + .padding({left: 6, right: 6}) | ||
| 314 | } | 317 | } |
| 315 | } | 318 | } |
| 316 | } | 319 | } |
| @@ -321,6 +324,7 @@ export struct SearchResultContentComponent { | @@ -321,6 +324,7 @@ export struct SearchResultContentComponent { | ||
| 321 | ListItem() { | 324 | ListItem() { |
| 322 | ListHasNoMoreDataUI() | 325 | ListHasNoMoreDataUI() |
| 323 | } | 326 | } |
| 327 | + .padding({left: 6, right: 6}) | ||
| 324 | } | 328 | } |
| 325 | } | 329 | } |
| 326 | .cachedCount(5) | 330 | .cachedCount(5) |
| @@ -338,7 +342,7 @@ export struct SearchResultContentComponent { | @@ -338,7 +342,7 @@ export struct SearchResultContentComponent { | ||
| 338 | .backgroundColor($r('app.color.white')) | 342 | .backgroundColor($r('app.color.white')) |
| 339 | .height('100%') | 343 | .height('100%') |
| 340 | .width('100%') | 344 | .width('100%') |
| 341 | - .padding({left: 6, right: 6}) | 345 | + |
| 342 | } | 346 | } |
| 343 | 347 | ||
| 344 | @Builder | 348 | @Builder |
-
Please register or login to post a comment