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