|
|
@@ -36,28 +36,74 @@ export class BookSearchResultViewModel{
|
|
|
|
|
|
|
|
|
// 获取书单列表
|
|
|
- // todo 列表加载待完善
|
|
|
async getBookList(isReload: boolean = true) {
|
|
|
if(isReload) {
|
|
|
this.bookListQuery.reload()
|
|
|
} else {
|
|
|
- // this.bookListQuery.reachEnd()
|
|
|
+ if(!this.bookListQuery.reachEnd(this.bookList.length)) return
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
let ans = await bookListApi.searchBookList(this.bookListQuery)
|
|
|
|
|
|
- this.bookList = [...ans?.list ?? []]
|
|
|
-
|
|
|
- console.log(`书单列表数据 = ${JSON.stringify(ans)}`)
|
|
|
+ this.bookListQuery.setTotal(ans?.total)
|
|
|
+ if(isReload) {
|
|
|
+ this.bookList = [...ans?.list ?? []]
|
|
|
+ } else {
|
|
|
+ this.bookList = [...this.bookList, ...ans?.list ?? []]
|
|
|
+ }
|
|
|
} catch (e) {
|
|
|
+ if(!isReload){
|
|
|
+ this.bookListQuery.backPage()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取书籍列表
|
|
|
- async getBooks() {
|
|
|
- this.book = await bookListApi.searchBooks(this.booksQuery.clone())
|
|
|
- // this.book = ans.list ?? []
|
|
|
- console.log(`获取书籍列表 = ${JSON.stringify(this.bookList)}`)
|
|
|
+ async getBooks(isReload: boolean = true) {
|
|
|
+
|
|
|
+ if (isReload) {
|
|
|
+ this.booksQuery.reload()
|
|
|
+ } else {
|
|
|
+ if (!this.booksQuery.reachEnd(this.book.length)) return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ let ans = await bookListApi.searchBooks(this.booksQuery.clone())
|
|
|
+ this.booksQuery.setTotal(ans.total)
|
|
|
+ if (isReload) {
|
|
|
+ this.book = [...ans?.list ?? []]
|
|
|
+ } else {
|
|
|
+ this.book = [...this.book, ...ans?.list ?? []]
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ if (!isReload) {
|
|
|
+ this.booksQuery.backPage()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|