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,51 @@
<template lang="jade">
#app
v-navbar(v-if="this.hiddenNavbar")
div(:class="{content : this.isContent}")
router-view
v-tabbar(v-if="this.hiddenTabbar")
</template>
<script>
import { mapGetters } from "vuex";
import headComponents from './components/tpl/head'
import footerComponents from './components/tpl/footer'
export default {
name: 'App',
created() {
},
data () {
return {
}
},
methods: {
},
components: {
'v-navbar': headComponents,
'v-tabbar': footerComponents
},
computed: {
...mapGetters({
hiddenNavbar: 'HiddenNavbar',
hiddenTabbar: 'HiddenTabbar',
isContent: 'iscontent',
onscroll: 'onscroll'
})
},
}
</script>
<style lang="less">
@import './assets/less/_main';
.content {
padding: 1rem 0 0.8rem 0;
}
body {
background: #f4f4f4;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,51 @@
//-------------------- 重置UI框架样式 --------------------
.yd-navbar {
background: @global-color !important;
.yd-navbar-center-title {
color: @white-color !important;
}
.yd-navbar-item {
span {
color: @white-color !important;
}
}
}
// 修改轮播图小圆点的位置
.yd-slider-pagination {
justify-content: flex-end;
padding-right: 11px;
}
.yd-grids-4 .yd-grids-item:not(:nth-child(4n)):before {
width: 0;
}
.yd-navbar:after {
height: 0 !important;
}
.g-fix-ios-prevent-scroll {
position: inherit !important;
}
//-------------------- 连接被激活时候的颜色 --------------------
.router-link-active {
color: @global-color !important;
}
//-------------------- 去除隐藏滚动条的样式 --------------------
::-webkit-scrollbar {/*滚动条整体样式*/
width: 0px;
height: 0px;
}
::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
border-radius: 0;
background: rgba(0, 0, 0, 0);
}
::-webkit-scrollbar-track {/*滚动条里面轨道*/
border-radius: 10px;
background: rgba(0, 0, 0, 0);
}

View File

@@ -0,0 +1,48 @@
font-face {
font-family: 'iconfont'; /* project id 976730 */
src: url('//at.alicdn.com/t/font_976730_nk6iqvvpus.eot');
src: url('//at.alicdn.com/t/font_976730_nk6iqvvpus.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_976730_nk6iqvvpus.woff') format('woff'),
url('//at.alicdn.com/t/font_976730_nk6iqvvpus.ttf') format('truetype'),
url('//at.alicdn.com/t/font_976730_nk6iqvvpus.svg#iconfont') format('svg');
}
[class^="icon-custom-"]:before, [class*=" icon-custom-"]:before {
font-family: 'iconfont';
}
.icon-custom-shuj:before {
content: '\e60a';
}
.icon-custom-shuc:before {
content: '\e73e';
}
.icon-custom-class:before {
content: '\e635';
}
.icon-custom-about:before {
content: '\e657';
}
.icon-custom-bangzhu:before {
content: '\e60e';
}
.icon-custom-qingchuhuancun:before {
content: '\e630';
}
.icon-custom-night:before {
content: '\e79d';
}
.icon-custom-setting:before {
content: '\e72a';
}
.icon-custom-banben:before {
content: '\e641';
}
.icon-custom-xieyi:before {
content: '\e658';
}
.icon-custom-start:before {
content: '\e63c';
}

View File

@@ -0,0 +1,11 @@
@import './_variables/index.less';
@import './_mixins/index.less';
@import './_icons/index.less';
@import './_cover/index.less';
// 首页的样式
@import './view/index/_main.less';
// 书架样式
@import './view/like/index.less';
// 详情页样式
@import './view/info/index.less';

View File

@@ -0,0 +1,12 @@
.rounded-corners (@radius: 10px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}
.flex_layout (@dir: row, @content: space-between) {
display: flex;
flex-direction: @dir;
justify-content: @content;
align-items: center;
}

View File

@@ -0,0 +1,6 @@
@global-color: #a70a0a;
@white-color: #fff;
@BottomSecant: .2rem;

View File

@@ -0,0 +1 @@
@import "./index.less";

View File

@@ -0,0 +1,30 @@
.index {
.index-scroll {
width: 100%;
overflow-x: scroll;
background: @white-color;
position: fixed;
top: 1rem;
z-index: 9;
transform: translateZ(0);
ul {
width: 130%;
li {
float: left;
width: 1.9rem;
height: 0.8rem;
line-height: 0.8rem;
text-align: center;
a {
font-size: 17px;
}
}
}
}
.yd-grids-4 {
margin-bottom: @BottomSecant;
}
}
.yd-slider {
padding-top: 40px;
}

View File

@@ -0,0 +1,111 @@
@main-color: #f3f3f3;
@full-height: 100%;
.infos {
height: @full-height;
.info-background {
width: @full-height;
height: 4rem;
position: absolute;
top: 0;
z-index: 1;
filter: grayscale(50%) blur(30px);
}
.info-header {
width: @full-height;
height: 4rem;
position: absolute;
top: 0;
z-index: 2;
.flex_layout();
align-items: flex-end;
padding: 0 0.39rem 0.21rem 0.39rem;
.header-img {
img {
width: 1.81rem;
}
}
.header-info {
width: @full-height;
padding-left: 0.4rem;
align-self: center;
margin-top: 0.9rem;
p {
font-size: 0.36rem;
font-weight: 600;
letter-spacing: 0.02rem;
margin-bottom: 0.2rem;
color: @main-color;
}
.header-class {
margin-bottom: 0.16rem;
color: @main-color;
}
}
}
.info-introduce{
padding: 0.21rem 0.39rem;
color: #797879;
background: @white-color;
padding-top: 4.72rem;
.introduce-title {
font-size: 0.34rem;
margin-bottom: 0.2rem;
}
.introduce-content{
font-size: 0.28rem;
letter-spacing: 0.02rem;
}
.introduce-newbook {
.flex_layout(row,space-between);
margin-top: 0.48rem;
}
}
.info-booklist {
margin-top: 0.2rem;
padding-bottom: 1.2rem;
}
.info-read {
position: fixed;
width: 90%;
height: 1rem;
margin-left: -168.75px;
left: 50%;
text-align: center;
line-height: 1rem;
z-index: 9;
color: #fff;
bottom: 10px;
font-size: 0.36rem;
.add-base {
border-top-left-radius: 40px;
border-bottom-left-radius: 40px;
}
.add-bookshelf-active {
background: linear-gradient(to right, #FFC500, #FF9402);
}
.add-bookshelf-noactive {
background: linear-gradient(to right, #858485, #3c0a12);
}
.start-read {
background: linear-gradient(to right, #FF7A00, #FE560A);
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
}
}
}
.yd-back-icon:before, .yd-next-icon:before {
font-size: .48rem !important;
}
.yd-navbar {
width: 100%;
position: fixed;
top: 0;
z-index: 6;
}
.yd-navbar .yd-navbar-item span {
color: #b9b9b9 !important;
}

View File

@@ -0,0 +1,17 @@
.book-like {
.no-book {
.flex_layout(column);
margin: 2rem 0;
height: 100%;
img {
width: 58%;
}
.yd-btn {
padding: .08rem 1.1rem;
span {
font-size: .34rem;
}
}
}
}

View File

@@ -0,0 +1,70 @@
<template lang="jade">
.booklist
.yd-head(v-if="title")
p {{ title ? title : '标题未设置'}}
.more
span 查看更多
yd-navbar-next-icon
yd-list(:theme='themeType ? themeType : 4')
yd-list-item(v-for='item, key in bookList', :key='key')
img(slot='img', :src='item.img ? item.img : item.imgUrl')
span(slot='title') {{ item.title }}
yd-list-other(slot='other')
div
span.demo-list-price
em
| {{item.price ? item.price : item.introduce.substring(0,50)}}
span.demo-list-del-price {{ item.w_price }}
</template>
<script>
export default {
props: {
title: {
type: String,
required: false
},
bookList: {
type: Array,
required: true
},
themeType: {
type: Number,
required: false
}
},
created() {
},
data() {
return {
}
},
}
</script>
<style lang="less">
@import "./../../assets/less/_mixins/index";
@import "./../../assets/less/_variables/index";
.booklist {
margin-bottom: @BottomSecant;
.yd-head {
.flex_layout();
padding: 0 .14rem;
background: #fff;
height: .8rem;
p {
font-size: .3rem;
}
span {
font-size: 12px;
color: #999;
vertical-align: sub;
}
}
}
</style>

View File

@@ -0,0 +1,34 @@
<template lang="jade">
.footer
yd-tabbar(slot='tabbar' fixed :exact="false")
yd-tabbar-item(v-for='(item, index) in tabBar', :title='item.title', :link='item.link', :key='index')
yd-icon(v-bind:name='item.icons' slot='icon' custom)
</template>
<script>
import { mapActions } from "vuex";
export default {
data () {
return {
tabBar: [
{ title: '书架', link: '/like', icons: 'shuj' },
{ title: '书城', link: '/home', icons: 'shuc' },
{ title: '分类', link: '/class', icons: 'class' },
{ title: '我的', link: '/about', icons: 'about' }
]
}
},
methods: {
...mapActions([
'SetTitle'
]),
changeTitle (titles) {
this.SetTitle(titles)
}
}
}
</script>
<style lang="less" scoped>
</style>

View File

@@ -0,0 +1,25 @@
<template lang="jade">
.head
yd-navbar(slot='navbar', fontsize="17px", :title='title' fixed)
router-link(to='#', slot='right')
yd-icon(name='type' size='25px')
</template>
<script>
import { mapGetters } from "vuex";
export default {
data () {
return {
}
},
computed: {
...mapGetters({
title: 'Title'
})
}
}
</script>
<style lang="less">
</style>

View File

@@ -0,0 +1,19 @@
<template lang="jade">
yd-slider(autoplay='3000')
yd-slider-item(v-for="(n , index) in swiperList", :key="index")
a(:href='n.href')
img(:src='n.src')
</template>
<script>
export default {
props: {
swiperList: Array
}
}
</script>
<style lang="less" scoped>
</style>

View File

@@ -0,0 +1,33 @@
<template lang="jade">
.login-header
.login-header-banner
h3 {{title}}
</template>
<script>
export default {
props: ['title']
}
</script>
<style lang="less" scoped>
@import "./../../assets/less/_variables/index";
@import "./../../assets/less/_mixins/index";
.login-header {
.login-header-banner {
width: 100%;
height: 5rem;
background: @global-color;
.flex_layout(row,center);
h3 {
color: @white-color;
font-size: .48rem;
letter-spacing: .04rem;
font-weight: bolder;
}
}
}
</style>

View File

@@ -0,0 +1,87 @@
<template lang="jade">
.book-about
.about-message
img(src="./../../../assets/img/user.png", alt="")
p 编码猿
.about-setting
yd-cell-group
yd-cell-item(arrow='')
yd-icon(slot='icon', name='start', size='.42rem' custom)
span(slot='left') 我的收藏
span(slot='right') 查看收藏
yd-cell-item(arrow='')
yd-icon(slot='icon', name='night', size='.42rem' custom)
span(slot='left') 夜间模式
span(slot='right')
.line
yd-cell-item(arrow='')
yd-icon(slot='icon', name='setting', size='.42rem' custom)
span(slot='left') 设置
span(slot='right') 设置
yd-cell-item(arrow='')
yd-icon(slot='icon', name='bangzhu', size='.42rem' custom)
span(slot='left') 帮助与反馈
span(slot='right') gogo
yd-cell-item(arrow='')
yd-icon(slot='icon', name='xieyi', size='.42rem' custom)
span(slot='left') 使用协议
span(slot='right') gogo
yd-cell-item(arrow='')
yd-icon(slot='icon', name='banben', size='.42rem' custom)
span(slot='left') 版本
span(slot='right') gogo
yd-cell-item(arrow='')
yd-icon(slot='icon', name='qingchuhuancun', size='.42rem' custom)
span(slot='left') 清除缓存
span(slot='right') gogo
</template>
<script>
import { mapGetters, mapActions } from "vuex";
export default {
created() {
this.SetTitle("我的")
},
methods: {
...mapActions({
SetTitle:'SetTitle'
})
}
}
</script>
<style lang="less" scoped>
.book-about {
.about-message {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 4.4rem;
margin-top: -0.04rem;
background: #a70a0a;
img {
width: 2.1rem;
}
p {
margin-top: 20px;
font-size: 17px;
letter-spacing: 2px;
color: #fff;
}
}
.about-setting{
margin-top: 0.2rem;
.yd-cell-item{
padding: 0.1rem 0 0.1rem 0.24rem;
border-bottom: 1px solid #f3f3f3
}
}
.line{
height: 0.2rem;
background: #f2efef;
}
}
</style>

View File

@@ -0,0 +1,48 @@
<template lang="jade">
.book-class
yd-scrolltab
yd-scrolltab-panel(label='空调', icon='demo-icons-category1')
v-havebook(:bookList="bookList", :themeType='2')
yd-scrolltab-panel(label='冰箱', icon='demo-icons-category2', active='')
v-havebook(:bookList="bookList", :themeType='2')
yd-scrolltab-panel(label='洗衣机', icon='demo-icons-category3')
v-havebook(:bookList="bookList", :themeType='2')
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import booklist from "./../../tpl/booklist.vue";
export default {
created() {
console.log('分类');
this.SetTitle("分类")
},
data() {
return {
bookList: [
{img: "http://img1.shikee.com/try/2016/06/23/14381920926024616259.jpg", title: "标题111标题标题标题标题", price: 156.23, w_price: 89.36},
{img: "http://img1.shikee.com/try/2016/06/21/10172020923917672923.jpg", title: "标题222标题标题标题标题", price: 256.23, w_price: 89.36},
{img: "http://img1.shikee.com/try/2016/06/23/15395220917905380014.jpg", title: "标题333标题标题标题标题", price: 356.23, w_price: 89.36}
]
}
},
components: {
'v-havebook': booklist
},
methods: {
...mapActions({
SetTitle:'SetTitle'
})
}
}
</script>
<style lang="less" scoped>
.book-class {
position: fixed;
top: 1.06rem;
bottom: 1.14rem;
width: 100%;
}
</style>

View File

@@ -0,0 +1,96 @@
<template lang="jade">
.index-info
yd-backtop
div(v-if="($route.params.id).toString() === '1' ")
//- 轮播图下面的分类
yd-grids-group(:rows='4')
yd-grids-item(v-for="(item,index) in classList", :key="index")
img(slot='icon', :src='item.src')
span(slot='text') {{ item.text }}
yd-infinitescroll(:callback='loadList', ref='infinitescrollDemo')
yd-list(theme='4', slot='list')
yd-list-item(v-for='item, key in this.getClassData', :key='key' @click.native="enterInfo(item.url)")
img(slot='img', :src='item.imgURL')
span(slot='title') {{item.title}} | {{item.author}}
yd-list-other(slot='other')
div
span.list-price
em {{item.introduce.substring(0,50)}}
span(slot='doneTip') 啦啦啦啦啦啦没有数据啦~~
img(slot='loadingTip', src='http://static.ydcss.com/uploads/ydui/loading/loading10.svg')
div(v-else-if="($route.params.id).toString() === '2' ") 2
div(v-else-if="($route.params.id).toString() === '3' ") 3
div(v-else-if="($route.params.id).toString() === '4' ") 4
div(v-else-if="($route.params.id).toString() === '5' ") 5
div(v-else='')
h2 分类id不存在
</template>
<script>
import { mapGetters, mapActions, mapMutations } from "vuex";
import booklistComponents from "./../../tpl/booklist.vue";
export default {
created() {
if (this.getClassData.length == 0) {
this.loadData()
}
},
data() {
return {
page: 1,
class: 1,
maxPage: 267,
classList: [
{ id: 1, src: require('./../../../assets/img/book-list.png'), text: '书架' },
{ id: 2, src: require('./../../../assets/img/nav-order.png'), text: '书城' },
{ id: 3, src: require('./../../../assets/img/book-like.png'), text: '推荐' },
{ id: 4, src: require('./../../../assets/img/book-setting.png'), text: '我的' }
],
title: '口碑神作',
bookList: []
}
},
methods: {
...mapActions({
SetTitle:'SetTitle',
GetClass: 'GetClassData',
}),
loadList() {
++this.page
if(this.page > this.maxPage) {
this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
return;
}else {
this.loadData()
this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
}
},
async loadData() {
await this.GetClass({
class: this.class,
page: this.page,
action: 'more'
})
},
enterInfo(title) {
this.$router.push({ path: '/info', query: { id: title.substring(22) }})
}
},
computed: {
...mapGetters({
getClassData: 'ClassVideoData'
})
},
components: {
'v-book': booklistComponents
}
}
</script>
<style lang="less" scoped>
</style>

View File

@@ -0,0 +1,52 @@
<template lang="jade">
.index
.index-scroll
ul
li(v-for="(item, index) in classList", :key="index")
router-link(:to="{ name: 'indexInfo', params: { id: item.type }}") {{ item.title }}
v-swiper(:swiperList="swiper")
router-view
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import swiperComponents from "./../../tpl/swiper.vue";
export default {
created () {
this.SetTitle("书城")
},
data () {
return {
classList: [
{ id: '1', title: '玄幻小说', type: 1 },
{ id: '2', title: '修真小说', type: 2 },
{ id: '3', title: '都市小说', type: 3 },
{ id: '4', title: '穿越小说', type: 4 },
{ id: '5', title: '网游小说', type: 5 }
],
swiper: [
{ id: 1, href: '/index', src: 'http://statics.zhuishushenqi.com/recommendPage/15453823588110' },
{ id: 2, href: '/index', src: 'http://statics.zhuishushenqi.com/recommendPage/154538237741967' },
{ id: 3, href: '/index', src: 'http://statics.zhuishushenqi.com/recommendPage/154348118998888' }
]
}
},
methods: {
...mapActions({
SetTitle: 'SetTitle'
})
},
computed: {
...mapGetters({
indexData: 'homeData'
})
},
components: {
'v-swiper': swiperComponents
}
}
</script>
<style scoped lang='less'>
</style>

View File

@@ -0,0 +1,133 @@
<template lang="jade">
.infos
yd-navbar(style="background: #d9d9d900 !important;")
yd-navbar-back-icon(slot='left',@click.native="$router.go(-1)")
yd-icon(name="share1" size="25px" color="#b9b9b9", slot='right')
//- 头部主要信息
.info-background(:style="{ background: 'url('+url+') no-repeat center', backgroundSize: '100% 100%' }")
.info-header
.header-img
img(:src="info.imgUrl" v-if="info")
.header-info(v-if="info")
p {{info.title }}
.header-class
span {{info.author}}
span &nbsp;|&nbsp;
span 玄幻
br
span {{info.updateTime}}
//- 简介和目录
.info-introduce
p.introduce-title 简介
p.introduce-content(v-if="info") {{info.introduce.length == 0 ? '这可能是一本很精彩的小说...' : info.introduce }}
.introduce-newbook(v-if="info")
p 最新
p {{ info.newChapter.newTitle }}
//- 小说章节列表
.info-booklist(v-if="info")
yd-cell-group
yd-cell-item(arrow='', v-for="(item,index) in info.oldChapter", :key="index", @click.native="StartRead(item.chapterUrl)")
span(slot='left') {{item.chapterTitle}}
//- 加入书架 + 开始阅读
.info-read
yd-flexbox
yd-flexbox-item(:class=" isActive ? 'add-base add-bookshelf-active' : 'add-base add-bookshelf-noactive' ")(@click.native=" isActive ? addBook() : '' ") 加入书架
yd-flexbox-item.start-read(@click.native="StartRead(info.oldChapter[0].chapterUrl)") 开始阅读
yd-backtop
</template>
<script>
import { mapMutations } from "vuex";
export default {
data() {
return {
info: null,
url: null,
isActive: true
}
},
created() {
this.getInfoData()
this.checkBook()
},
methods: {
...mapMutations({
HiddenNavbar :'SET_HiddenNavbar',
HiddenTabbar :'SET_HiddenTabbar',
HiddenContent: 'SET_isContent',
SaveBookList: 'SET_BOOKLIST'
}),
async getInfoData() {
this.info = (await this.$http.get({
url: '/info',
params: {
id: this.$route.query.id
}
})).data;
// 将小说的所有章节存到vuex中
this.SaveBookList(this.info.oldChapter)
this.url = this.info.imgUrl;
},
StartRead (chapterUrl) {
this.$router.push({ path: '/read', query: { id: chapterUrl }})
},
/**
* 一进入页面就去检查这本书是否已经被用户添加书架
* 1: 没有收藏 增按钮激活,可点击能收藏
* 2已经收藏按钮灰色不可点击
*/
async checkBook () {
let check = await this.$http.post({ url: '/user/checkbook', params: { userid: (JSON.parse(localStorage.getItem('loginStatus'))).id, bookid: this.$route.query.id }});
check.data == "已收藏" ? this.isActive = false : '';
},
/**
* 添加书到书架
* @returns {Promise<void>}
*/
async addBook () {
let add = await this.$http.post({
url: '/user/addbok',
params: {
userid: (JSON.parse(localStorage.getItem('loginStatus'))).id,
bookid: this.$route.query.id
}
});
if (add.status == 200) {
this.$dialog.toast({
mes: add.data,
timeout: 1500,
icon: 'success'
});
this.isActive = false
}
}
},
beforeRouteEnter (to, from, next) {
next(vm => {
vm.HiddenNavbar(false)
vm.HiddenTabbar(false)
vm.HiddenContent(false)
})
},
beforeRouteLeave (to, from, next) {
this.HiddenNavbar(true)
this.HiddenTabbar(true)
this.HiddenContent(true)
next()
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,105 @@
<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>

View File

@@ -0,0 +1,96 @@
<template lang="jade">
.book-like
.no-book(v-if="isHaveBook")
img(src="../../../assets/img/bootjia.png", alt="没有书")
yd-button(size="small",type="danger",shape="circle") 添加书籍
.have-book(v-else)
yd-list(theme='4')
yd-list-item(v-for='item, key in bookList', :key='key' @click.native="itemAction(item,key)")
img(slot='img', :src='item.img ? item.img : item.imgUrl')
span(slot='title') {{ item.title }}
yd-list-other(slot='other')
div
span.demo-list-price
em
| {{item.price ? item.price : item.introduce.substring(0,50)}}
span.demo-list-del-price {{ item.w_price }}
yd-actionsheet(:items='myItems1', v-model='isShowActionsheet', cancel='取消')
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import booklist from "./../../tpl/booklist.vue";
export default {
created() {
this.SetTitle("书架")
this.getLikeData()
},
data() {
return {
isShowActionsheet: false,
isHaveBook: false,
bookList: [],
readBook: {},
readBookIndex: null,
myItems1: [
{
label: '阅读',
callback: () => {
this.$router.push({ path: '/read', query: { id: this.readBook.oldChapter[0].chapterUrl }})
}
},
{
label: '删除',
callback: () => {
this.deleteBook()
}
}
]
}
},
methods: {
...mapActions({
SetTitle:'SetTitle'
}),
async getLikeData () {
this.bookList = (await this.$http.get({
url: '/user/getbook',
params: {
userid: (JSON.parse(localStorage.getItem('loginStatus'))).id
}
})).data;
this.bookList.length == 0 ? this.isHaveBook = true : this.isHaveBook = false
},
itemAction(e,index) {
// 显示弹窗
this.isShowActionsheet = !this.isShowActionsheet
// 存储用户点击的书
this.readBook = e
this.readBookIndex = index
},
async deleteBook() {
let delB = (await this.$http.get({
url: '/user/deletebook',
params: {
uid: (JSON.parse(localStorage.getItem('loginStatus'))).id,
bid: this.readBook.bookid
}
})).data;
this.bookList.splice(this.readBookIndex,1)
this.bookList.length == 0 ? this.isHaveBook = true : this.isHaveBook = false
}
},
components: {
'v-havebook': booklist
}
}
</script>
<style lang="less" scoped>
</style>

View File

@@ -0,0 +1,95 @@
<template lang="jade">
.login
v-header(title="登录")
.login-input
yd-cell-group
yd-cell-item
span(slot='left') 手机号
yd-input(slot='right', v-model='UserLogin.phone', regex='mobile', placeholder='手机号码')
yd-cell-item
span(slot='left') 密码
yd-input(slot='right', min="6", type='password', v-model='UserLogin.password', placeholder='密码')
yd-button-group
yd-button(@click.native="UserLoging()", size='large', bgcolor="#a70a0a", color="#fff", type='primary', shape='circle')
yd-button-group.other-setting
router-link(:to="{ name: 'userReg'}" style="float:left") 注册
a(class="forget" style="float:right") 忘记密码
</template>
<script>
/**
* 1: 首先检查 服务器是否已经登录
* 如果已经登录直接登录成功,否则手动登录
*
*/
import { mapMutations, mapActions } from "vuex";
import userheader from "./../../tpl/userheader.vue";
export default {
data() {
return {
UserLogin: {
phone: null,
password: null
}
}
},
created() {
this.SetTitle("登录")
},
methods: {
...mapMutations({
HiddenNavbar :'SET_HiddenNavbar',
HiddenTabbar :'SET_HiddenTabbar',
HiddenContent: 'SET_isContent'
}),
...mapActions([
'SetTitle'
]),
//
async UserLoging() {
let userLogin = await this.$http.post({
url: '/user/login',
params: {
name: this.UserLogin.phone,
pwd: this.UserLogin.password
}
});
if(userLogin.status == 200) {
localStorage.setItem('loginStatus', JSON.stringify(userLogin.data))
this.$router.push({ path: 'home/info/1'})
}
}
},
beforeRouteEnter (to, from, next) {
next(vm => {
vm.HiddenTabbar(false)
vm.HiddenContent(false)
})
},
beforeRouteLeave (to, from, next) {
this.HiddenTabbar(true)
this.HiddenContent(true)
next()
},
components: {
'v-header': userheader
}
}
</script>
<style lang="less" scoped>
.login {
.login-input{
.other-setting {
margin-top: .3rem;
position: fixed;
bottom: .16rem;
width: 100%;
a {
color: #a09e9e;
font-size: 15px;
}
}
}
}
</style>

View File

@@ -0,0 +1,126 @@
<template lang="jade">
.reg
v-header(title="注册")
yd-cell-group
yd-cell-item
span(slot='left') 手机号
yd-input(slot='right',ref="userPhone", regex='mobile', placeholder='手机号码', v-model="UserReg.userPhone",:required="true")
yd-cell-item
span(slot='left') 密码
yd-input(slot='right',ref="userPwd", min="6",:show-error-icon="false",:show-success-icon="false", type='password', placeholder='密码', v-model="UserReg.userPwd")
yd-cell-item
span(slot='left') 确认密码
yd-input(slot='right',ref="userAgainPwd",:show-error-icon="false",:show-success-icon="false",min="6", type='password', placeholder='确认密码', v-model="UserReg.userAgainPwd")
p(v-if="showError" class="error") {{nullTips}}}
yd-button-group
yd-button(size='large', bgcolor="#a70a0a", color="#fff", type='primary', shape='circle',@click.native="UserLogin")
yd-button-group.other-setting
a(href="#/login" style="float:left" )
a(class="forget" style="float:right") 忘记密码
</template>
<script>
import userheader from "./../../tpl/userheader.vue";
import { mapMutations, mapActions } from "vuex";
export default {
data () {
return {
showError: false,
nullTips: null,
UserReg: {
userPhone: null,
userPwd: null,
userAgainPwd: null
}
}
},
watch: {
'UserReg.userPwd' (newVal, oldVal) {
if (!this.$refs.userPwd.valid) {
this.showError = true
this.nullTips = '密码至少6位'
}else {
if (this.UserReg.userAgainPwd != this.UserReg.userPwd) {
this.showError = true
this.nullTips = '两次密码不一致'
}else {
this.showError = false
this.nullTips = null
}
}
},
'UserReg.userAgainPwd' (newVal, oldVal) {
if (newVal !== this.UserReg.userPwd) {
this.showError = true
this.nullTips = '两次密码不一致'
} else {
this.showError = false
}
}
},
created() {
this.SetTitle("注册")
},
methods: {
...mapMutations({
HiddenNavbar :'SET_HiddenNavbar',
HiddenTabbar :'SET_HiddenTabbar',
HiddenContent: 'SET_isContent'
}),
...mapActions([
'SetTitle'
]),
async UserLogin() {
if(this.$refs.userPhone.valid == true && this.showError == false) {
let userReg = await this.$http.post({
url: '/user/reg',
params: {
name: this.UserReg.userPhone,
pwd: this.UserReg.userPwd
}
});
userReg.status == 200 ? this.$router.push({ path: '/login'}) :''
}else {
console.log('error')
}
}
},
beforeRouteEnter (to, from, next) {
next(vm => {
vm.HiddenTabbar(false)
vm.HiddenContent(false)
})
},
beforeRouteLeave (to, from, next) {
this.HiddenTabbar(true)
this.HiddenContent(true)
next()
},
components: {
'v-header': userheader
},
computed: {
}
}
</script>
<style lang="less" scoped>
.other-setting {
margin-top: .3rem;
position: fixed;
bottom: .16rem;
width: 100%;
a {
color: #a09e9e;
font-size: 15px;
}
}
.error{
padding-left: 13px;
color: #a7250c;
}
</style>

View File

@@ -0,0 +1,6 @@
export default {
HttpUrl: {
// 获取小说分类的api接口
class: '/class'
}
}

View File

@@ -0,0 +1,74 @@
import Vue from 'vue'
import axios from "axios";
import { Loading, Toast } from 'vue-ydui/dist/lib.rem/dialog';
axios.defaults.baseURL = 'http://127.0.0.1:3000/api/json/1.0';
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
// 在发送请求之前做些什么
Loading.open("很快加载好了")
return config;
}, function (error) {
// 对请求错误做些什么
return Promise.reject(error);
});
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
switch (response.data.status) {
case 404:
Toast({
mes: response.data.data,
timeout: 1500
})
break;
}
return response;
}, function (error) {
// 对响应错误做点什么
return Promise.reject(error);
});
export default {
/**
* get请求
* @param {*} pars
*/
get(pars) {
return new Promise(function(resolve,reject) {
axios.get(pars.url, {
params: pars.params
})
.then((response) => {
Loading.close()
resolve(response.data);
})
.catch((error) => {
reject(error);
});
})
},
/**
* post 请求
* @param {*} pars
*/
post(pars) {
return new Promise(function(resolve,reject) {
axios.post(pars.url, pars.params)
.then((response) => {
Loading.close()
resolve(response.data);
})
.catch((error) => {
reject(error);
});
})
}
}

View File

@@ -0,0 +1,34 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import router from './router';
import Vuex from 'vuex';
import YDUI from 'vue-ydui';
import 'vue-ydui/dist/ydui.rem.css';
import vuescroll from 'vuescroll/dist/vuescroll-native';
import 'vuescroll/dist/vuescroll.css';
import http from "./http";
import store from "./vuex/index.js";
Vue.use(YDUI);
Vue.use(Vuex);
Vue.use(vuescroll);
Vue.config.productionTip = false;
Vue.prototype.$http = http;
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
});

View File

@@ -0,0 +1,141 @@
import Vue from 'vue'
import Router from 'vue-router'
import homeComponents from '~/components/view/index'
import childrenPageComponents from '~/components/view/index/children.vue'
// 分类关于
import classComponents from '~/components/view/class'
import aboutComponents from '~/components/view/about'
//书架
import likeComponents from '~/components/view/like'
// 登录注册
import LoginComponents from '~/components/view/user/login'
import RegComponents from '~/components/view/user/reg'
// 小说详情+阅读
import InfoComponents from '~/components/view/info/'
import ReadComponents from "~/components/view/info/read";
Vue.use(Router)
const router = new Router({
routes: [
// 当访问根路径时候跳转到index页面为了解决ydui yd-tabbar :exact="false" 导致的书架
// 激活类去除不掉 的问题
// 文档参考: https://router.vuejs.org/zh/api/#exact
{
path: '/',
redirect: {
path: '/like'
}
},
{
path: '/like',
name: 'like',
component: likeComponents,
meta: {
isLogin: true,
title: '书架'
}
},
{
path: '/home',
name: 'home',
component: homeComponents,
redirect: {
path: 'home/info/1'
},
children: [
{
path: 'info/:id',
name: 'indexInfo',
component: childrenPageComponents,
meta: {
isLogin: false,
title: '书城'
}
}
]
},
{
path: '/class',
name: 'class',
component: classComponents,
meta: {
isLogin: false,
title: '分类'
}
},
{
path: '/about',
name: 'about',
component: aboutComponents,
meta: {
isLogin: true,
title: '我的'
}
},
{
path: '/login',
name: 'login',
component: LoginComponents,
meta: {
isLogin: false,
title: '登录'
}
},
{
path: '/userReg',
name: 'userReg',
component: RegComponents,
meta: {
isLogin: false,
title: '注册'
}
},
{
path: '/info',
name: 'info',
component: InfoComponents,
meta: {
isLogin: false,
title: '详情'
}
},
{
path: '/read',
name: 'read',
component: ReadComponents,
meta: {
isLogin: false,
title: '阅读'
}
}
]
})
/**
* 全局导航守卫
*/
router.beforeEach((to, from, next) => {
document.title = to.meta.title
if(to.meta.isLogin) {
if(localStorage.getItem("loginStatus") == null) {
next({
path: '/login',
query: {
redirect: to.name
}
})
} else {
next()
}
}else {
next()
}
})
export default router

View File

@@ -0,0 +1,9 @@
/**
* 全局工具函数
*/
export default {
}

View File

@@ -0,0 +1,10 @@
const getters = {
ClassVideoData: state => state.home.ClassVideo,
Title: state => state.pub.NavBarTitle,
HiddenNavbar: state => state.pub.hiddenNavbar,
HiddenTabbar: state => state.pub.hiddenTabbar,
iscontent: state => state.pub.isContent,
BookList: state => state.info.BookList
}
export default getters

View File

@@ -0,0 +1,21 @@
import Vue from 'vue'
import Vuex from 'vuex'
import home from './modules/home'
import pub from './modules/public'
import info from './modules/info'
import getters from './getters'
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
home,
pub,
info
},
getters
})
export default store

View File

@@ -0,0 +1,25 @@
import http from "./../../http";
import config from "./../../config";
const home = {
state: {
ClassVideo: []
},
mutations: {
SET_CLASSVIDEO: (state, data) => {
state.ClassVideo = [ ...state.ClassVideo, ...data ]
// 2 for (var i =0 ;i<data.length;i++) {
// state.ClassVideo.push(data[i])
// }
// 3 state.ClassVideo = state.ClassVideo.concat(data)
}
},
actions: {
async GetClassData({ commit }, par) {
let datas = await http.get({ url: config.HttpUrl.class, params: par })
commit('SET_CLASSVIDEO', datas)
}
}
}
export default home

View File

@@ -0,0 +1,15 @@
import http from "./../../http";
import config from "./../../config";
const info = {
state: {
BookList: []
},
mutations: {
SET_BOOKLIST: (state, data) => {
state.BookList = data
}
}
}
export default info

View File

@@ -0,0 +1,30 @@
const publics = {
state: {
NavBarTitle: "书架",
hiddenNavbar: true,
hiddenTabbar: true,
isContent: true
},
mutations: {
SET_NavBarTitle: (state, title) => {
state.NavBarTitle = title
},
SET_HiddenNavbar: (state, status) => {
state.hiddenNavbar = status
},
SET_HiddenTabbar: (state, status) => {
state.hiddenTabbar = status
},
SET_isContent: (state, status) => {
state.isContent = status
}
},
actions: {
async SetTitle({ commit }, ti) {
commit('SET_NavBarTitle', ti)
}
}
}
export default publics