106 lines
2.4 KiB
Vue
106 lines
2.4 KiB
Vue
<template lang="jade">
|
|
.read
|
|
p(v-html="readList.content" @click="ShowSetting = !ShowSetting")
|
|
|
|
infinite-loading(@infinite="infiniteHandler")
|
|
|
|
yd-popup(v-model='ShowSetting', position="bottom", height="30%")
|
|
yd-button(type='danger', style='margin: 30px;', @click.native='ShowSetting = !ShowSetting') Close Left Popup
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import { mapMutations, mapActions,mapGetters } from "vuex";
|
|
import InfiniteLoading from 'vue-infinite-loading';
|
|
export default {
|
|
data () {
|
|
return {
|
|
readList: [],
|
|
ShowSetting: false,
|
|
bookId: this.$route.query.id,
|
|
isLoad: true
|
|
}
|
|
},
|
|
created () {
|
|
this.Read();
|
|
},
|
|
methods: {
|
|
...mapMutations({
|
|
HiddenNavbar: 'SET_HiddenNavbar',
|
|
HiddenTabbar: 'SET_HiddenTabbar',
|
|
HiddenContent: 'SET_isContent'
|
|
}),
|
|
async Read () {
|
|
this.readList = (await this.$http.get({
|
|
url: '/read',
|
|
params: {
|
|
id: this.bookId
|
|
}
|
|
})).data;
|
|
|
|
|
|
this.readList.content = `<br/> <h2>${this.readList.title}</h2> <br/> ${this.readList.content}`
|
|
|
|
|
|
|
|
this.isLoad = false
|
|
|
|
|
|
document.title = this.readList.title
|
|
|
|
|
|
},
|
|
infiniteHandler() {
|
|
if(this.isLoad) {
|
|
console.log('为true')
|
|
}else {
|
|
console.log('为false')
|
|
let blist = this.getBookList
|
|
|
|
for (let i = 0; i<blist.length; i++) {
|
|
if(this.$route.query.id == blist[i].chapterUrl) {
|
|
this.bookId = blist[i + 1].chapterUrl
|
|
this.Read()
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
$state.loaded();
|
|
}
|
|
},
|
|
beforeRouteEnter (to, from, next) {
|
|
document.querySelector('body').setAttribute('style', 'background-color: #eee7e6;')
|
|
next(vm => {
|
|
vm.HiddenNavbar(false)
|
|
vm.HiddenTabbar(false)
|
|
vm.HiddenContent(false)
|
|
})
|
|
},
|
|
beforeRouteLeave (to, from, next) {
|
|
document.querySelector('body').removeAttribute('style')
|
|
this.HiddenNavbar(true)
|
|
this.HiddenTabbar(true)
|
|
this.HiddenContent(true)
|
|
next()
|
|
},
|
|
computed: {
|
|
...mapGetters({
|
|
getBookList: 'BookList'
|
|
})
|
|
},
|
|
components: {
|
|
InfiniteLoading,
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.read {
|
|
p {
|
|
padding: 0.2rem 0.3rem;
|
|
font-size: 16px;
|
|
}
|
|
}
|
|
</style>
|