Showing
2 changed files
with
26 additions
and
7 deletions
| @@ -112,6 +112,7 @@ export class ContentDTO implements BaseDTO { | @@ -112,6 +112,7 @@ export class ContentDTO implements BaseDTO { | ||
| 112 | sameContentList:ContentDTO[] = [] | 112 | sameContentList:ContentDTO[] = [] |
| 113 | sameContentListJson:string = "" | 113 | sameContentListJson:string = "" |
| 114 | sameContentListSize:number = 0 | 114 | sameContentListSize:number = 0 |
| 115 | + sameContentListId:string = "" | ||
| 115 | /* | 116 | /* |
| 116 | 本地辅助字段 | 117 | 本地辅助字段 |
| 117 | */ | 118 | */ |
| @@ -62,7 +62,6 @@ export struct SearchResultContentComponent { | @@ -62,7 +62,6 @@ export struct SearchResultContentComponent { | ||
| 62 | 62 | ||
| 63 | this.curPageNum = 1 | 63 | this.curPageNum = 1 |
| 64 | this.hasMore = true | 64 | this.hasMore = true |
| 65 | - this.isLoading = false | ||
| 66 | this.getNewSearchResultData() | 65 | this.getNewSearchResultData() |
| 67 | } | 66 | } |
| 68 | 67 | ||
| @@ -86,6 +85,10 @@ export struct SearchResultContentComponent { | @@ -86,6 +85,10 @@ export struct SearchResultContentComponent { | ||
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | getNewSearchResultData() { | 87 | getNewSearchResultData() { |
| 88 | + if (this.isLoading){ | ||
| 89 | + return | ||
| 90 | + } | ||
| 91 | + | ||
| 89 | this.isLoading = true | 92 | this.isLoading = true |
| 90 | if (this.hasMore) { | 93 | if (this.hasMore) { |
| 91 | SearcherAboutDataModel.getSearchResultListData("20", `${this.curPageNum}`, this.searchType, this.keywords, | 94 | SearcherAboutDataModel.getSearchResultListData("20", `${this.curPageNum}`, this.searchType, this.keywords, |
| @@ -178,6 +181,8 @@ export struct SearchResultContentComponent { | @@ -178,6 +181,8 @@ export struct SearchResultContentComponent { | ||
| 178 | this.isLoading = false | 181 | this.isLoading = false |
| 179 | this.count = this.count === -1 ? 0 : this.count | 182 | this.count = this.count === -1 ? 0 : this.count |
| 180 | }) | 183 | }) |
| 184 | + }else{ | ||
| 185 | + this.isLoading = false | ||
| 181 | } | 186 | } |
| 182 | } | 187 | } |
| 183 | 188 | ||
| @@ -236,12 +241,23 @@ export struct SearchResultContentComponent { | @@ -236,12 +241,23 @@ export struct SearchResultContentComponent { | ||
| 236 | // } | 241 | // } |
| 237 | let contentDTO = this.dataTransform(rem, value, photos); | 242 | let contentDTO = this.dataTransform(rem, value, photos); |
| 238 | if (value.data.type != "13") { | 243 | if (value.data.type != "13") { |
| 239 | - this.data.push(contentDTO) | ||
| 240 | - if (value.data.sameContentList != null && value.data.sameContentList.length > 0) { | ||
| 241 | - let contentDTO2 = new ContentDTO(); | ||
| 242 | - contentDTO2.sameContentListJson = JSON.stringify(value.data.sameContentList) | ||
| 243 | - contentDTO2.sameContentListSize = value.data.sameContentList.length | ||
| 244 | - this.data.push(contentDTO2) | 244 | + //避免 重复(偶现bug 暂时处理) |
| 245 | + let index = this.data.getDataArray().findIndex(obj => obj.objectId == contentDTO.objectId); | ||
| 246 | + if (index === -1) { | ||
| 247 | + this.data.push(contentDTO) | ||
| 248 | + | ||
| 249 | + if (value.data.sameContentList != null && value.data.sameContentList.length > 0) { | ||
| 250 | + let contentDTO2 = new ContentDTO(); | ||
| 251 | + contentDTO2.sameContentListId = contentDTO.objectId + value.data.sameContentList[0].id | ||
| 252 | + contentDTO2.sameContentListJson = JSON.stringify(value.data.sameContentList) | ||
| 253 | + contentDTO2.sameContentListSize = value.data.sameContentList.length | ||
| 254 | + | ||
| 255 | + let index = this.data.getDataArray().findIndex(obj => obj.sameContentListId == contentDTO2.sameContentListId) | ||
| 256 | + if (index === -1){ | ||
| 257 | + this.data.push(contentDTO2) | ||
| 258 | + } | ||
| 259 | + } | ||
| 260 | + | ||
| 245 | } | 261 | } |
| 246 | } | 262 | } |
| 247 | }) | 263 | }) |
| @@ -256,6 +272,7 @@ export struct SearchResultContentComponent { | @@ -256,6 +272,7 @@ export struct SearchResultContentComponent { | ||
| 256 | } | 272 | } |
| 257 | this.isLoading = false | 273 | this.isLoading = false |
| 258 | }).catch((err: Error) => { | 274 | }).catch((err: Error) => { |
| 275 | + this.isLoading = false | ||
| 259 | console.log(TAG, JSON.stringify(err)) | 276 | console.log(TAG, JSON.stringify(err)) |
| 260 | }) | 277 | }) |
| 261 | }).catch((err: Error) => { | 278 | }).catch((err: Error) => { |
| @@ -265,6 +282,7 @@ export struct SearchResultContentComponent { | @@ -265,6 +282,7 @@ export struct SearchResultContentComponent { | ||
| 265 | }) | 282 | }) |
| 266 | } else { | 283 | } else { |
| 267 | this.hasMore = false | 284 | this.hasMore = false |
| 285 | + this.isLoading = false | ||
| 268 | } | 286 | } |
| 269 | } | 287 | } |
| 270 | 288 |
-
Please register or login to post a comment