浏览代码

done except wx pay

Zhengxiaowei 5 年之前
父节点
当前提交
691e7e265a
共有 3 个文件被更改,包括 12 次插入7 次删除
  1. 1 1
      src/manifest.json
  2. 10 4
      src/views/Detail/index.ux
  3. 1 2
      src/views/Index/index.ux

+ 1 - 1
src/manifest.json

@@ -57,7 +57,7 @@
     "logLevel": "debug"
   },
   "router": {
-    "entry": "views/Pay",
+    "entry": "views/Index",
     "pages": {
       "views/Index": {
         "component": "index"

+ 10 - 4
src/views/Detail/index.ux

@@ -13,7 +13,7 @@
           </div>
           <text class="words">字数:{{bookWordsFormat(book.book_word_count)}}</text>
           <div class="user-operator">
-            <text class="add" @click="addShelf">加入书架</text>
+            <text class="add" @click="addShelf">{{book.is_on_user_shelf ? '已加入' : '加入书架'}}</text>
             <text class="read" @click="toRead">立即阅读</text>
           </div>
         </div>
@@ -57,8 +57,9 @@
 </template>
 
 <script>
-import { getBooksInfo, getShortCatalog, getSimilarBooks } from "../../api";
+import { getBooksInfo, getShortCatalog, getSimilarBooks, postUserShelfBooks } from "../../api";
 import router from '@system.router';
+import prompt from '@system.prompt';
 
 export default {
   protected: {
@@ -79,7 +80,12 @@ export default {
     this.showLongText = !this.showLongText;
     this.substrInfoText();
   },
-  addShelf() { },
+  async addShelf() {
+    if (!this.book.is_on_user_shelf) {
+      let ret = await postUserShelfBooks({ bid: this.bid });
+      if (ret) this.book.is_on_user_shelf = 1, prompt.showToast({ message: "添加成功" });
+    }
+  },
   toRead(cid) {
     let chapter_id = this.book.first_cid;
     if (cid) chapter_id = cid;
@@ -110,7 +116,7 @@ export default {
   },
   onInit() {
     console.log("book bid", this.bid);
-    this.getBooksInfo("5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY");
+    this.getBooksInfo(this.bid);
   },
 }
 </script>

+ 1 - 2
src/views/Index/index.ux

@@ -79,7 +79,7 @@ export default {
         index: 3
       }
     ],
-    current: 1,
+    current: 0,
     showPopup: false,
     showSignPop: false,
     showShortPop:false
@@ -90,7 +90,6 @@ export default {
     if(this.$app.$def.data.backClickCount === 0){
       this.showShortPop=true;
     }
-
   },
   onBackPress() {
     // 退出逻辑