|
@@ -12,50 +12,108 @@
|
|
</div>
|
|
</div>
|
|
<list class="consume-wrap">
|
|
<list class="consume-wrap">
|
|
<block if="curTab === 0">
|
|
<block if="curTab === 0">
|
|
- <block for="consumeList">
|
|
|
|
|
|
+ <block for="{{chapter.list}}">
|
|
<list-item type="chapter" class="consume-item">
|
|
<list-item type="chapter" class="consume-item">
|
|
<div class="consume-info">
|
|
<div class="consume-info">
|
|
- <text class="name">爱妃在上</text>
|
|
|
|
- <text class="chapter">第339章:爱妃,好久不见</text>
|
|
|
|
- <text class="create">2019-08-28 14:11:11</text>
|
|
|
|
|
|
+ <text class="name">{{$item.book_name}}</text>
|
|
|
|
+ <text class="chapter">{{$item.chapter_name}}</text>
|
|
|
|
+ <text class="create">{{$item.created_at}}</text>
|
|
</div>
|
|
</div>
|
|
- <text class="consume-price">54 书币</text>
|
|
|
|
|
|
+ <text class="consume-price">{{$item.fee}}书币</text>
|
|
</list-item>
|
|
</list-item>
|
|
</block>
|
|
</block>
|
|
</block>
|
|
</block>
|
|
<block elif="curTab === 1">
|
|
<block elif="curTab === 1">
|
|
- <block for="consumeList">
|
|
|
|
|
|
+ <block for="{{book.list}}">
|
|
<list-item type="book" class="consume-item">
|
|
<list-item type="book" class="consume-item">
|
|
<div class="consume-info">
|
|
<div class="consume-info">
|
|
- <text class="name">爱妃在上</text>
|
|
|
|
- <text class="create">2019-08-28 14:11:11</text>
|
|
|
|
|
|
+ <text class="name">{{$item.book_name}}</text>
|
|
|
|
+ <text class="create">{{$item.created_at}}</text>
|
|
</div>
|
|
</div>
|
|
- <text class="consume-price">54 书币</text>
|
|
|
|
|
|
+ <text class="consume-price">{{$item.fee}}书币</text>
|
|
</list-item>
|
|
</list-item>
|
|
</block>
|
|
</block>
|
|
</block>
|
|
</block>
|
|
<list-item type="page" class="consume-wrap">
|
|
<list-item type="page" class="consume-wrap">
|
|
- <x-page current="{{1}}" total="{{2}}" @prev="prev" @next="next"></x-page>
|
|
|
|
|
|
+ <x-page current="{{currentPage.current}}" total="{{currentPage.total}}" @prev="prev" @next="next"></x-page>
|
|
</list-item>
|
|
</list-item>
|
|
</list>
|
|
</list>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import { chapterApi, bookApi } from "../../api/index";
|
|
export default {
|
|
export default {
|
|
private: {
|
|
private: {
|
|
curTab: 0,
|
|
curTab: 0,
|
|
tabs: ["章节", "整本"],
|
|
tabs: ["章节", "整本"],
|
|
- consumeList: [1, 2, 3, 4, 5, 5, 23, 523, 213, 1, 23, 3, 4, 2, 1],
|
|
|
|
|
|
+ chapter: {
|
|
|
|
+ list: [],
|
|
|
|
+ page: {
|
|
|
|
+ total: 0,
|
|
|
|
+ current: 1
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ book: {
|
|
|
|
+ list: [],
|
|
|
|
+ page: {
|
|
|
|
+ total: 0,
|
|
|
|
+ current: 1
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ currentPage: {
|
|
|
|
+ total: 0,
|
|
|
|
+ current: 1
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ onInit() {
|
|
|
|
+ this.getOrderChapter();
|
|
|
|
+ },
|
|
|
|
+ async getOrderChapter(page = 1, page_size = 10) {
|
|
|
|
+ let res = await chapterApi({ page: page, page_size });
|
|
|
|
+ let { list, meta } = res;
|
|
|
|
+ let pages = { total: meta.last_page, current: meta.current_page };
|
|
|
|
+ this.chapter = { ...this.chapter, list, page: pages };
|
|
|
|
+ this.currentPage = pages;
|
|
|
|
+ },
|
|
|
|
+ async getOrderBook(page = 1, page_size = 2) {
|
|
|
|
+ let res = await bookApi({ page: page, page_size });
|
|
|
|
+ let { list, meta } = res;
|
|
|
|
+ let pages = { total: meta.last_page, current: meta.current_page };
|
|
|
|
+ this.book = { ...this.book, list, page: pages };
|
|
|
|
+ this.currentPage = pages;
|
|
},
|
|
},
|
|
tabChange(index) {
|
|
tabChange(index) {
|
|
this.curTab = index;
|
|
this.curTab = index;
|
|
|
|
+ switch (index) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.getOrderChapter();
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ this.getOrderBook();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
prev() {
|
|
prev() {
|
|
- console.log("上一页");
|
|
|
|
|
|
+ switch (this.curTab) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.getOrderChapter(--this.currentPage.current);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ this.getOrderBook(--this.currentPage.current);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
next() {
|
|
next() {
|
|
- console.log("下一页");
|
|
|
|
|
|
+ switch (this.curTab) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.getOrderChapter(++this.currentPage.current);
|
|
|
|
+ break;
|
|
|
|
+ case 1:
|
|
|
|
+ this.getOrderBook(++this.currentPage.current);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|