first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
<template>
<div class="bookinfo">
<!-- background: url('infoData.imgurl'); -->
<div class="info-title">
<div class="title-background" :style="{ background: 'url('+infoData.imgurl+')' }"></div>
<div class="title-top">
<img :src="infoData.imgurl"/>
<div class="title-top-right">
<h3>{{ infoData.title }}</h3>
<p><span class="author">{{ infoData.author }}</span> | {{ infoData.type }}</p>
</div>
</div>
</div>
<div class="info-message">
<ul>
<li>
<h3 class="readNum">{{ infoData.readNum }}</h3>
<p class="readP">阅读次数</p>
</li>
<li>
<h3 class="readNum">{{ infoData.wordNum }}</h3>
<p class="readP">已更字数</p>
</li>
</ul>
</div>
<div class="info-desc">
<h4>简介</h4>
<p class="descCont">{{ infoData.desc }}</p>
</div>
<!-- 章节目录 -->
<view class="chapter">
<h4 class="chapterTitle">章节目录</h4>
<ul class="chapterList">
<li class="chapterTxt" v-for="(item,index) in infoData.zjList" :key="index">{{ item.text }}</li>
</ul>
</view>
<!-- 推荐 -->
<view class="recommend">
<view class="recommendTitle">喜欢过 {{ infoData.title }} 的人还喜欢 ...</view>
<ul class="recommendUl">
<li class="recommendList" v-for="(items,index) in GET_HOTLIST.list"
:key="index" @click="$utils.enterInfo(items.id)">
<image :src="items.imgUrl" mode="aspectFit"></image>
<view class="bookMsg">
<p class="bookName">{{items.title}}</p>
<p class="bookType">{{items.class}}</p>
</view>
</li>
</ul>
</view>
<view class="action">
<view class="action-read" @click="startRead()">
开始阅读
</view>
<view :class="[ isdouleClick ? 'red action-like' : 'blak action-like']" @click="isdouleClick ? addLike() : '' ">
加入收藏
</view>
</view>
</div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
data() {
return {
isdouleClick: true,
bookid: null,
infoData: {}
}
},
onLoad(option) {
this.bookid = option.id
this.checkBook()
},
onReady () {
this.getIndexData();
},
methods: {
async startRead() {
uni.navigateTo({
url: `/pages/bookinfo/read?bookid=${this.bookid}&chapterId=${this.infoData.zjList[0].zid}`
});
},
async checkBook() {
let data = await this.$http.checkBook({
data: {
bookid: this.bookid,
id: (JSON.parse(localStorage.getItem("LoginStatus"))).id
}
});
if(data != "没有收藏本书") {
this.isdouleClick = false
}
},
async addLike () {
if(this.$utils.checkLogin()) {
let data = await this.$http.addLike({
data: {
bookid: this.bookid,
id: (JSON.parse(localStorage.getItem("LoginStatus"))).id
}
});
this.isdouleClick = false
} else {
uni.navigateTo({
url: '/pages/my/login'
});
}
},
async getIndexData() {
let data = await this.$http.getBookInfo({
data: {
bookid: this.bookid
}
});
this.infoData = data;
uni.setNavigationBarTitle({
title: data.title
});
}
},
computed: {
...mapGetters([
'GET_HOTLIST'
])
}
}
</script>
<style lang="less">
.red{
background: red;
}
.blak {
background: #8d8d8d !important;
}
@import "./../../common/less/page/bookinfo.less";
</style>

View File

@@ -0,0 +1,133 @@
<template>
<view class="read">
<scroll-view style="height: 100%;" scroll-y="true" @scroll="scroll">
<rich-text :nodes="nodes"></rich-text>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
bookid: null,
chapterId: null,
nodes: [],
history: localStorage.getItem("history") == null ? [] : JSON.parse(localStorage.getItem("history")),
currentIndex: null
}
},
onLoad(data) {
this.chapterId = data.chapterId;
this.bookid = data.bookid;
var status = true;
if(this.history.length != 0){
this.history.forEach((val,index) => {
// 如果该书已经被阅读过,那么status true,没有阅读 false
if (val.bookid == data.bookid) {
this.currentIndex = index
status = true
} else {
status = false
}
})
if (status) {
this.chapterId = this.history[this.currentIndex].chapterId;
this.bookid = data.bookid;
} else {
this.history.push({
bookid: data.bookid,
chapterId: data.chapterId
})
localStorage.setItem("history", JSON.stringify(this.history))
}
}
this.getReadList();
},
onReachBottom() {
this.getReadList();
},
methods: {
scroll(e) {
console.log(e)
},
async getReadList () {
if(this.history.length == 0){
this.history.push({
bookid: this.bookid,
chapterId: this.chapterId
})
localStorage.setItem("history", JSON.stringify(this.history))
} else {
this.history.forEach((val,index) => {
// 如果该书已经被阅读过,那么status true,没有阅读 false
if (val.bookid == this.bookid) {
this.currentIndex = index
status = true
} else {
status = false
}
});
if (status) {
this.history[this.currentIndex].chapterId = this.chapterId;
localStorage.setItem("history", JSON.stringify(this.history))
} else {
this.history.push({
bookid: this.bookid,
chapterId: this.chapterId
})
localStorage.setItem("history", JSON.stringify(this.history))
}
};
let data = (await this.$http.startRead({
data: {
bookid: this.bookid,
chapterId: this.chapterId
}
})).result;
uni.setNavigationBarTitle({
title: `${data.bookName} | ${data.chapterName}`
});
data.content = JSON.parse((JSON.stringify(data.content.split("</p>"))).replace(/<p>/g, ""));
data.content.unshift(data.chapterName+data.chapterNum)
data.content.forEach((val) => {
this.nodes.push({
name: 'p',
attrs: {
style: 'margin-bottom:10px;'
},
children: [{
type: 'text',
text: val
}]
})
})
this.chapterId = data.nextChapterId
}
}
}
</script>
<style scoped lang="less">
.read {
font-size: 17px;
background: rgb(230, 224, 208);
padding: 8px;
uni-rich-text {
text-indent: 10px;
}
}
</style>