|
@@ -17,7 +17,7 @@
|
|
|
|
|
|
<script>
|
|
|
import router from "@system.router";
|
|
|
-import { getChapters, getIsonshelf, postUserShelfBooks } from "../../api";
|
|
|
+import { getChapters, getIsonshelf, postUserShelfBooks, chapterOrders } from "../../api";
|
|
|
|
|
|
export default {
|
|
|
protected: {
|
|
@@ -29,10 +29,7 @@ export default {
|
|
|
content: []
|
|
|
},
|
|
|
onInit() {
|
|
|
- getChapters({ bid: this.bid, chapter_id: this.chapter_id }).then(r => {
|
|
|
- this.content = r.chapter_content.trim().split(/\n/)
|
|
|
- this.bookinfo = r
|
|
|
- })
|
|
|
+ this.getChapters(this.bid, this.chapter_id)
|
|
|
this.addShelf()
|
|
|
},
|
|
|
addShelf() {
|
|
@@ -41,6 +38,33 @@ export default {
|
|
|
r.is_on ? '' : postUserShelfBooks({ bid: this.bid })
|
|
|
})
|
|
|
},
|
|
|
+ getChapters(bid, chapter_id) {
|
|
|
+ getChapters({ bid: bid, chapter_id: chapter_id }).then(r => {
|
|
|
+ this.content = r.chapter_content.trim().split(/\n/)
|
|
|
+ this.bookinfo = r
|
|
|
+ this.$element('list').scrollTo({ index: 0 })
|
|
|
+ }).catch(e => {
|
|
|
+ if (e.data.code == '10016' || e.data.code == '10019') {
|
|
|
+ chapterOrders({ bid: bid, chapter_id: chapter_id }).then(r => {
|
|
|
+ console.log(r)
|
|
|
+ this.content = r.chapter_content.trim().split(/\n/)
|
|
|
+ this.bookinfo = r
|
|
|
+ this.$element('list').scrollTo({ index: 0 })
|
|
|
+ }).catch(f => {
|
|
|
+ if (f.data.code == '10014' || f.data.code == '10015') {
|
|
|
+ router.push({
|
|
|
+ uri: "/views/Pay",
|
|
|
+ params: {
|
|
|
+ code: f.data.code,
|
|
|
+ fee: e.data.data.fee,
|
|
|
+ bid: this.bid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
toCatalog() {
|
|
|
router.push({
|
|
|
uri: "/views/Catalog",
|
|
@@ -52,19 +76,11 @@ export default {
|
|
|
},
|
|
|
getPrevChapter() {
|
|
|
console.log("get prev chapter");
|
|
|
- getChapters({ bid: this.bookinfo.bid, chapter_id: this.bookinfo.prev_cid }).then(r => {
|
|
|
- this.content = r.chapter_content.trim().split(/\n/)
|
|
|
- this.bookinfo = r
|
|
|
- this.$element('list').scrollTo({ index: 0 })
|
|
|
- })
|
|
|
+ this.getChapters(this.bookinfo.bid, this.bookinfo.prev_cid)
|
|
|
},
|
|
|
getNextChapter() {
|
|
|
console.log("get next chapter");
|
|
|
- getChapters({ bid: this.bookinfo.bid, chapter_id: this.bookinfo.next_cid }).then(r => {
|
|
|
- this.content = r.chapter_content.trim().split(/\n/)
|
|
|
- this.bookinfo = r
|
|
|
- this.$element('list').scrollTo({ index: 0 })
|
|
|
- })
|
|
|
+ this.getChapters(this.bookinfo.bid, this.bookinfo.next_cid)
|
|
|
}
|
|
|
}
|
|
|
</script>
|