|
@@ -1,9 +1,25 @@
|
|
|
<template>
|
|
|
- <list id="catalog" class="catalog-wrap" @scrollbottom="loadCatalog" @scrolltop="loadPrev" v-if="list.length>0">
|
|
|
+ <list
|
|
|
+ id="catalog"
|
|
|
+ class="catalog-wrap"
|
|
|
+ @scrollbottom="loadCatalog"
|
|
|
+ @scrolltop="loadPrev"
|
|
|
+ v-if="list.length > 0"
|
|
|
+ >
|
|
|
<block for="list">
|
|
|
- <list-item type="catalog-item" class="catalog-item {{$idx == chapter_sequence_index ? 'checked' : ''}}" @click='jumpReader($item)'>
|
|
|
- <text class="catalog-name {{$idx == chapter_sequence_index ? 'catalog-name__check' : ''}}">{{$item.chapter_name}}</text>
|
|
|
- <image show='{{$item.chapter_is_vip}}' src="../../assets/imgs/book-vip.png"></image>
|
|
|
+ <list-item
|
|
|
+ type="catalog-item"
|
|
|
+ class="catalog-item {{$idx == chapter_sequence_index ? 'checked' : ''}}"
|
|
|
+ @click="jumpReader($item)"
|
|
|
+ >
|
|
|
+ <text
|
|
|
+ class="catalog-name {{$idx == chapter_sequence_index ? 'catalog-name__check' : ''}}"
|
|
|
+ >{{ $item.chapter_name }}</text
|
|
|
+ >
|
|
|
+ <image
|
|
|
+ show="{{$item.chapter_is_vip}}"
|
|
|
+ src="../../assets/imgs/book-vip.png"
|
|
|
+ ></image>
|
|
|
</list-item>
|
|
|
</block>
|
|
|
<list-item type="loading-text" class="loading-wrap" if="!end">
|
|
@@ -17,18 +33,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getCatalog } from "../../api";
|
|
|
-import router from '@system.router';
|
|
|
-import prompt from '@system.prompt';
|
|
|
+import { getCatalog } from '../../api'
|
|
|
+import router from '@system.router'
|
|
|
+import prompt from '@system.prompt'
|
|
|
|
|
|
-const PER_PAGE_NUM = 50;
|
|
|
+const PER_PAGE_NUM = 50
|
|
|
|
|
|
export default {
|
|
|
protected: {
|
|
|
- bid: "",
|
|
|
- chapter_id:'',
|
|
|
- chapter_sequence: "",
|
|
|
- fromReader:false,
|
|
|
+ bid: '',
|
|
|
+ chapter_id: '',
|
|
|
+ chapter_sequence: '',
|
|
|
+ fromReader: false
|
|
|
},
|
|
|
private: {
|
|
|
list: [],
|
|
@@ -36,7 +52,7 @@ export default {
|
|
|
chapter_sequence_index: 0,
|
|
|
startpage: 1,
|
|
|
loading: false,
|
|
|
- end: false,
|
|
|
+ end: false
|
|
|
},
|
|
|
onInit() {
|
|
|
// let page = 1
|
|
@@ -54,7 +70,6 @@ export default {
|
|
|
// setTimeout(() => {
|
|
|
// this.$element('catalog').scrollTo({ index: chapter_sequence_index })
|
|
|
// }, 500)
|
|
|
-
|
|
|
// })
|
|
|
},
|
|
|
onShow() {
|
|
@@ -62,34 +77,36 @@ export default {
|
|
|
var chapter_sequence_index = 0
|
|
|
if (this.chapter_sequence) {
|
|
|
var chapter_sequence = this.chapter_sequence
|
|
|
- chapter_sequence_index = chapter_sequence % PER_PAGE_NUM - 1
|
|
|
+ chapter_sequence_index = (chapter_sequence % PER_PAGE_NUM) - 1
|
|
|
this.chapter_sequence_index = chapter_sequence_index
|
|
|
page = Math.ceil(chapter_sequence / PER_PAGE_NUM)
|
|
|
}
|
|
|
- this.startpage = page;
|
|
|
-
|
|
|
- getCatalog({ bid: this.bid, page: page, page_size: PER_PAGE_NUM }).then(r => {
|
|
|
- this.list = r.list
|
|
|
- this.meta = r.meta
|
|
|
- setTimeout(() => {
|
|
|
- this.$element('catalog').scrollTo({ index: chapter_sequence_index })
|
|
|
- }, 500)
|
|
|
+ this.startpage = page
|
|
|
|
|
|
- })
|
|
|
+ getCatalog({ bid: this.bid, page: page, page_size: PER_PAGE_NUM }).then(
|
|
|
+ r => {
|
|
|
+ this.list = r.list
|
|
|
+ this.meta = r.meta
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$element('catalog').scrollTo({ index: chapter_sequence_index })
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ )
|
|
|
},
|
|
|
jumpReader(info) {
|
|
|
if (info.is_need_charge == 1) {
|
|
|
this.chapter_sequence = info.chapter_sequence
|
|
|
router.push({
|
|
|
- uri: "/views/Pay",
|
|
|
+ uri: '/views/Pay',
|
|
|
params: {
|
|
|
bid: info.bid,
|
|
|
+ fee: info.need_coin
|
|
|
}
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
router.replace({
|
|
|
- uri: "/views/Reader",
|
|
|
+ uri: '/views/Reader',
|
|
|
params: {
|
|
|
bid: info.bid,
|
|
|
chapter_id: info.chapter_id
|
|
@@ -97,17 +114,17 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
loadCatalog() {
|
|
|
- if (this.meta.last_page < (this.meta.current_page + 1)) {
|
|
|
- prompt.showToast({ message: '已经到底啦' });
|
|
|
- this.end = true;
|
|
|
- return;
|
|
|
+ if (this.meta.last_page < this.meta.current_page + 1) {
|
|
|
+ prompt.showToast({ message: '已经到底啦' })
|
|
|
+ this.end = true
|
|
|
+ return
|
|
|
}
|
|
|
let params = {
|
|
|
bid: this.bid,
|
|
|
page: this.meta.current_page + 1,
|
|
|
page_size: PER_PAGE_NUM
|
|
|
}
|
|
|
- this.initCatalog(params);
|
|
|
+ this.initCatalog(params)
|
|
|
// getCatalog({ bid: '5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY', page: this.meta.current_page + 1, page_size: PER_PAGE_NUM }).then(r => {
|
|
|
// console.log(...r.list)
|
|
|
// this.list.push(...r.list)
|
|
@@ -115,14 +132,15 @@ export default {
|
|
|
// })
|
|
|
},
|
|
|
loadPrev() {
|
|
|
- console.log("get prev catalog");
|
|
|
- if ((this.startpage - 1) < 1) return prompt.showToast({ message: '已经到顶啦' });
|
|
|
+ console.log('get prev catalog')
|
|
|
+ if (this.startpage - 1 < 1)
|
|
|
+ return prompt.showToast({ message: '已经到顶啦' })
|
|
|
let params = {
|
|
|
bid: this.bid,
|
|
|
page: this.startpage - 1,
|
|
|
page_size: PER_PAGE_NUM
|
|
|
}
|
|
|
- this.initCatalog(params, true);
|
|
|
+ this.initCatalog(params, true)
|
|
|
// getCatalog({ bid: '5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY', page: this.startpage - 1, page_size: PER_PAGE_NUM }).then(r => {
|
|
|
// console.log(...r.list)
|
|
|
// this.list.unshift(...r.list)
|
|
@@ -130,34 +148,34 @@ export default {
|
|
|
// })
|
|
|
},
|
|
|
initCatalog(params, isLoadPrev = false) {
|
|
|
- this.end = false;
|
|
|
+ this.end = false
|
|
|
getCatalog(params).then(r => {
|
|
|
if (isLoadPrev) {
|
|
|
this.list.unshift(...r.list)
|
|
|
this.startpage = r.meta.current_page
|
|
|
} else {
|
|
|
this.list.push(...r.list)
|
|
|
- this.meta = r.meta;
|
|
|
+ this.meta = r.meta
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
onBackPress() {
|
|
|
- if(this.fromReader){
|
|
|
+ if (this.fromReader) {
|
|
|
router.replace({
|
|
|
- uri: "/views/Reader",
|
|
|
- params: {
|
|
|
- bid: this.bid,
|
|
|
- chapter_id: this.chapter_id
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- router.back();
|
|
|
+ uri: '/views/Reader',
|
|
|
+ params: {
|
|
|
+ bid: this.bid,
|
|
|
+ chapter_id: this.chapter_id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ router.back()
|
|
|
}
|
|
|
- return true;
|
|
|
+ return true
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|
|
|
-@import "../../assets/less/catalog.less";
|
|
|
+@import '../../assets/less/catalog.less';
|
|
|
</style>
|