123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <import name="short-page" src="../../components/short/index.ux"></import>
- <import name="wechat-page" src="../../components/wechat/index.ux"></import>
- <template>
- <div id="reader-content">
- <div class="reader-wrap" id='list'>
- <div type='title' class="reader-title">
- <text class="title">{{bookinfo.chapter_name}}</text>
- <!-- <text class="add-shelf" @click="addShelf">加入书架</text> -->
- </div>
- <div type='content' class="reader-content">
- <text class="chapter-text" for='content'>{{$item}}</text>
- </div>
- <div type='button' class="reader-operator">
- <text class="operator prev" @click="getPrevChapter">上一章</text>
- <text class="operator catalog" @click="toCatalog">目录</text>
- <text class="operator next" @click="getNextChapter">下一章</text>
- </div>
- </div>
- <short-page if="{{showShortPop}}"></short-page>
- <!-- <wechat-page></wechat-page> -->
- </div>
- </template>
- <script>
- import router from "@system.router";
- import it from "../../helper/interface.js";
- import { getChapters, getIsonshelf, postUserShelfBooks, chapterOrders } from "../../api";
- export default {
- protected: {
- bid: '',
- chapter_id: ''
- },
- private: {
- bookinfo: {},
- content: [],
- showShortPop: false
- },
- onInit() {
- this.getChapters(this.bid, this.chapter_id)
- this.addShelf()
- if (this.$app.$def.data.backClickCount === 0) {
- this.showShortPop = true;
- }
- },
- onShow() {
- it.getShortCut((value) => {
- this.showShortPop = !value;
- })
- },
- addShelf() {
- console.log("add shelf");
- getIsonshelf({ bid: this.bid }).then(r => {
- 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 => {
- console.log('e code')
- console.log(e.data)
- console.log(e.data.code == '10016' || e.data.code == '10019')
- if (e.data.code == '10016' || e.data.code == '10019' || e.data.code == '10017') {
- chapterOrders({ 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(f => {
- console.log('f code')
- console.log(f.data)
- 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
- }
- })
- }
- })
- } else if (e.data.code == '10014' || e.data.code == '10015') {
- router.push({
- uri: "/views/Pay",
- params: {
- code: e.data.code,
- fee: e.data.data.fee,
- bid: this.bid
- }
- })
- }
- })
- },
- toCatalog() {
- router.push({
- uri: "/views/Catalog",
- params: {
- chapter_sequence: this.bookinfo.chapter_sequence,
- bid: this.bid
- }
- })
- },
- getPrevChapter() {
- console.log("get prev chapter");
- // this.getChapters(this.bookinfo.bid, this.bookinfo.prev_cid)
- router.replace({
- uri: "/views/Reader",
- params: {
- bid: this.bookinfo.bid,
- chapter_id: this.bookinfo.prev_cid
- }
- })
- },
- getNextChapter() {
- console.log("get next chapter");
- if (this.bookinfo.next_cid == 0) {
- router.push({
- uri: "/views/Raderover",
- params: {
- bid: this.bid
- }
- })
- return
- }
- // this.getChapters(this.bookinfo.bid, this.bookinfo.next_cid)
- router.replace({
- uri: "/views/Reader",
- params: {
- bid: this.bookinfo.bid,
- chapter_id: this.bookinfo.next_cid
- }
- })
- }
- }
- </script>
- <style lang="less">
- @import "../../assets/less/reader.less";
- </style>
|