Pārlūkot izejas kodu

章节购买,书架跳转阅读器

gdy96 5 gadi atpakaļ
vecāks
revīzija
b401ba3659

+ 7 - 0
src/api/index.js

@@ -119,3 +119,10 @@ export const userBind = params => {
 export const userSign = () => {
   return fly.get(`/sign`);
 };
+
+//用户签到
+export const chapterOrders = params => {
+  return fly.get(
+    `/books/${params.bid}/balance/chapterOrders/${params.chapter_id}`
+  );
+};

+ 14 - 0
src/components/book/book.ux

@@ -29,6 +29,10 @@ export default {
       type: Boolean,
       default: false
     },
+    read: {
+      type: Boolean,
+      default: false
+    },
     similar: {
       type: Boolean,
       default: false
@@ -64,6 +68,16 @@ export default {
   getBooks(book) {
     if (this.prevent) return;
     console.log("click_book", book);
+    if (this.read) {
+      router.push({
+        uri: "/views/Reader",
+        params: {
+          bid: book.bid,
+          chapter_id: book.last_cid
+        }
+      })
+      return
+    }
     if (this.similar) {
       router.replace({
         uri: "/views/Detail",

+ 1 - 1
src/views/Catalog/index.ux

@@ -30,7 +30,7 @@ export default {
   },
   onInit() {
     let page = 1
-    var chapter_sequence_index = 1
+    var chapter_sequence_index = 0
     if (this.chapter_sequence) {
       var chapter_sequence = this.chapter_sequence
       chapter_sequence_index = chapter_sequence % 15 - 1

+ 31 - 15
src/views/Reader/index.ux

@@ -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>

+ 2 - 2
src/views/Shelf/index.ux

@@ -19,7 +19,7 @@
         <block for="mockList">
           <div class="book-item__wrap {{(($idx + 1)%3 === 0) ? 'm0' : ''}}">
             <stack>
-              <x-book book='{{$item}}'></x-book>
+              <x-book book='{{$item}}' read='{{true}}'></x-book>
               <div class="book-del__wrap" show="{{isDelMode}}" @click='deleteBook($item)'>
                 <image src="https://yueduyun.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/img/delete.png"></image>
                 <text>删除</text>
@@ -38,7 +38,7 @@
         <block for="mockList">
           <list-item type="recent-item" class="recent-item">
             <stack>
-              <x-book multi="{{true}}" book='{{$item}}' width="{{150}}">
+              <x-book multi="{{true}}" book='{{$item}}' read='{{true}}' width="{{150}}">
                 <div class="book-info__wrap">
                   <text class="name">{{$item.book_name}}</text>
                   <text class="lastest">最新 {{$item.last_chapter}}</text>