Files
nuttyreading-html/pages/library/library.vue
2024-01-16 10:36:15 +08:00

714 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<!-- 公共组件-每个页面必须引入 -->
<!-- <public-module></public-module> -->
<!-- <z-nav-bar title="我的图书"></z-nav-bar> -->
<view class="home_bg">
<view class="" style=" ">
<view style="height: 80rpx"></view>
<view class="icon_hua">
<image src="../../static/icon/home_icon_3.png" mode="aspectFit" class="icon_hua_1"></image>
</view>
<view class="hehan">
<image src="../../static/icon/hehan.png" mode="aspectFit" class="icon_hua_1"></image>
</view>
<!-- <view class="search_box flexbox" @click="onPageJump('../peanut/searchFor')">
<view class="search">
<text class="icon_search"></text>
<text class="prompt">请输入书名</text>
</view>
</view> -->
<!-- <view class="searBtn flexbox">
<text>搜索</text>
</view> -->
</view>
<!-- <view class="home_lunbo">
<u-swiper :list="list3" indicator indicatorMode="line" circular style="height: 180rpx;"></u-swiper>
</view> -->
</view>
<!-- <view class="contentButton">
<u-tabs :scrollable="false" bg-color="#d4d4d4" active-color="#2979ff" inactive-color="#606266" bar-height="10" :list="contentButtonList" @click="contentButtonClick" lineWidth="42" :inactiveStyle="{fontSize:'32rpx'}" :activeStyle="{color: '#303133',fontWeight: 'bold', transform: 'scale(1.01)'}"></u-tabs>
</view> -->
<view class="" style="padding:20rpx 20rpx;">
<view class="mytabs flexbox">
<view :class="['item','item1', contentShow == 1 ? 'active' :'']" @click="setData(1)">
已购图书
</view>
<view :class="['item','item2', contentShow == 2 ? 'active' :'']" @click="setData(2)">
推荐图书
</view>
</view>
</view>
<scroll-view class="scroll-view_H " scroll-x="true" scroll-left="0" v-if="contentShow == 1">
<view class="ProTabs">
<text v-for="item in tagList" :key="item.splId" :class="[tabsid == item.splId ? 'cur' :'']" @click="tabsChange(item)">{{item.labelName}}</text>
</view>
</scroll-view>
<view class="listenList">
<view class="wrap" v-if="contentShow == 1">
<view class="" v-if="bookList.length > 0">
<u-row gutter="16" justify="flex-start">
<u-col span="12" v-for="(item,index) in bookList" :key="index">
<view>
<view class="flexbox yigoumaiList">
<view class="info">
<view class="videoBox demo-layout bg-purple">
<image v-if="item.images != '' && item.images != null" :src="item.images"
mode="scaleToFill"></image>
<image v-else src="../../static/icon/wufeng.jpg" mode="scaleToFill"></image>
</view>
</view>
<view class="btns">
<view class="text">
<view class="bookName">{{item.name}}</view>
<!-- <view class="author">
作者<text v-if="item.authorName == null || item.authorName == ''">暂无</text>
<text v-else>{{item.authorName}}</text>
</view> -->
</view>
<view class="flexbox icons">
<view class="item " >
<!-- <u-icon name="chat" color="#fcbd71" size="24"></u-icon> -->
<view v-if="item.clockIn != null && item.clockIn != 2" @click="goDaKa(item)">
<image src="../../static/icon/home1.png" mode="aspectFit"></image>
</view>
<view v-else @click="noOp()">
<image class="gray" src="../../static/icon/home1.png" mode="aspectFit"></image>
</view>
<view class="v1"><text> </text></view>
</view>
<view class="item " >
<!-- <u-icon name="volume" color="#71d5a1" size="24"></u-icon> -->
<view v-if="item.canListen" @click="goToListenFree(item)">
<image src="../../static/icon/home2.png" mode="aspectFit"></image>
</view>
<view v-else @click="noOp()">
<image class="gray" src="../../static/icon/home2.png" mode="aspectFit"></image>
</view>
<view class="v1"><text> </text></view>
</view>
<view class="item " @click="goPingshu(item)">
<!-- <u-icon name="chat" color="#fcbd71" size="24"></u-icon> -->
<view class="">
<image src="../../static/icon/home3.png" mode="aspectFit"></image>
</view>
<view class="v1"><text> </text></view>
</view>
<view class="item " >
<!-- <u-icon name="chat" color="#fcbd71" size="24"></u-icon> -->
<view class="" v-if="item.teachIn != null && item.teachIn != 0" @click="goJiangShu(item)">
<image src="../../static/icon/home4.png" mode="aspectFit"></image>
</view>
<view class="" v-else @click="noOp()">
<image class="gray" src="../../static/icon/home4.png" mode="aspectFit"></image>
</view>
<view class="v1">
<text> </text>
</view>
</view>
<view class="item " >
<!-- <u-icon name="chat" color="#fcbd71" size="24"></u-icon> -->
<view class="" v-if="item.relationId != null && item.relationId != 0" @click="goGuji(item)">
<image src="../../static/icon/home6.png" mode="aspectFit"></image>
</view>
<view class="" v-else @click="noOp()">
<image class="gray" src="../../static/icon/home6.png" mode="aspectFit"></image>
</view>
<view class="v1">
<text> </text>
</view>
</view>
</view>
</view>
</view>
</view>
</u-col>
</u-row>
<view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中
</font>
</view>
<view v-if="status==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
</view>
<u-divider v-else text="暂无已购买图书~"></u-divider>
</view>
<view class="wrap" v-if="contentShow == 2">
<view class="" v-if="tjBookLIst.length > 0">
<u-row gutter="16" justify="flex-start">
<u-col span="4" v-for="(item,index) in tjBookLIst" :key="index">
<view class=" listenItem">
<view class="" @click="goDetail(item)">
<image v-if="item.images != '' && item.images != null" :src="item.images"
mode="scaleToFill"></image>
<image v-else src="../../static/icon/wufeng.jpg" mode="scaleToFill"></image>
</view>
<view class="bookName"><text>{{item.name}}</text></view>
</view>
</u-col>
</u-row>
<view>
<view v-if="tjstatus==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中
</font>
</view>
<view v-if="tjstatus==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
</view>
<u-divider v-else text="暂无推荐图书~"></u-divider>
</view>
</view>
<!-- <view class="shuwuLink">
<image @click="" src="../../static/icon/shuwu.jpg" mode="aspectFit"></image>
</view> -->
<music-play :playData="playData"></music-play>
<z-navigation></z-navigation>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import {
mapState
} from 'vuex';
export default {
data() {
return {
list3: [
// '../../static/icon/home_ban_1.jpg',
'../../static/icon/home_ban_2.jpg',
'../../static/icon/home_ban_3.jpg',
],
showEbook: false,
playData: {},
loadingNow: false,
bookList: [],
contentShow: 1,
page: 1, // 页码
status: 3,
totalPage: 1,
tjPage: 1,
tjstatus: 3,
tjTotalPage: 1,
tjBookLIst: [],
contentButtonList: [{
name: '已购图书'
},
{
name: '推荐图书'
}
],
tagList:[
{splId:"",labelName:"全部"},
{splId:"2",labelName:"中医经典"},
{splId:"1",labelName:"中医基础"},
{splId:"3",labelName:"各家学说"},
{splId:"4",labelName:"中医临床"},
{splId:"5",labelName:"文学"},
{splId:"6",labelName:"哲学"},
] ,// 推荐标签列表
tabsid: ''
}
},
onLoad() {
},
onHide() {
// this.contentShow = 1
this.page = 1
this.tjPage = 1
this.bookList = []
this.tjBookLIst = []
},
onShow() {
this.getListDate()
this.getfreeBook()
},
onPullDownRefresh() {
console.log('下拉刷新了')
// this.contentShow = 1
this.page = 1
this.tjPage = 1
this.bookList = []
this.getfreeBook()
this.tjBookLIst = []
this.getListDate()
uni.stopPullDownRefresh();
},
onReachBottom() {
// this.loadingNow = true
console.log('到底了')
if (this.contentShow == 1) {
if (this.page + 1 <= this.totalPage) {
this.page++
this.status = 0
this.getfreeBook()
} else {
this.status = 1
}
} else if (this.contentShow == 2) {
if (this.tjPage + 1 <= this.tjTotalPage) {
this.tjPage++
// console.log('加载',this.tjPage)
this.tjstatus = 0
this.getListDate()
} else {
this.tjstatus = 1
}
}
},
components: {
musicPlay
},
computed: {
...mapState(['userInfo'])
},
methods: {
setData(e) {
this.contentShow = e
},
// 未购买图书,评书跳转
wgGoPingshu(item) {
console.log('未购买评书', item)
uni.navigateTo({
url: '../comments/comments?bookid=' + item.id,
// url:'../bookShop/commodityDetail'
});
},
// 跳转到评书
goPingshu(val) {
console.log('评书', val)
uni.navigateTo({
url: '../comments/comments?bookid=' + val.id,
});
},
contentButtonClick(e) {
this.contentShow = e.index
},
tabsChange(item){
this.bookList = []
this.tabsid = item.splId
this.page = 1
// 获取推荐数据
this.getfreeBook()
},
// 获取已购买书籍
getfreeBook() {
this.$http
.post('book/book/getMyBooks', {
// .post('book/buyorderdetail/querybuy', {
'userId': this.userInfo.id,
'page': this.page,
'limit': 10,
'type':this.tabsid
})
.then(res => {
if (res.code == 0) {
console.log(res, '获取已购买书籍')
if (res.page.records.length > 0) {
this.bookList = this.bookList.concat(res.page.records)
this.totalPage = res.page.pages
if (this.page == this.totalPage) {
this.status = 1
} else {
this.status = 3
}
} else {
this.bookList = []
}
}
});
},
// 获取推荐图书(未购买)
getListDate() {
this.loadingNow = false
// 获取书架列表
this.$http
.post('book/book/getBestBooks', {
'userId': this.userInfo.id,
'limit': 10,
'page': this.tjPage
})
.then(res => {
console.log(res, '获取推荐图书(未购买)')
if (res.code == 0) {
// this.tjTotalPage = res.pages.totalPage
var arr = []
if (res.page.records.length > 0) {
this.tjBookLIst = this.tjBookLIst.concat(res.page.records)
this.tjTotalPage = res.page.pages
this.tjstatus = 3
} else {
this.tjBookLIst = []
this.tjTotalPage = 1
}
}
});
},
noOp(){
uni.showToast({
title:'该书未开通此功能',
icon:'none'
})
},
// 跳转详情页
goDetail(item) {
console.log(item, 'goDetail-----')
uni.navigateTo({
url: '../eBook/bookContent?Id=' + item.id
// url: '../bookShop/commodityDetail?id=' + item.id
});
},
goToListen(item) {
console.log(item, 'item')
uni.navigateTo({
url: "../listen/listen?bookid=" + item.id
});
},
// 跳转到讲书
goJiangShu(val){
uni.navigateTo({
url: '../talkBook/talkBookML?bookid='+ val.id
})
},
// 跳转到古籍
goGuji(val){
uni.navigateTo({
url: '../eBook/bookContent?Id='+ val.relationId
})
},
// 跳转到打卡
goDaKa(val){
uni.navigateTo({
url: '../clock/clock?bookid='+ val.id
})
},
// 跳转到听书详情
goToListenFree(item) {
// console.log(item,'item')
uni.navigateTo({
url: "../listen/listen?bookid=" + item.id // 前台播放版本
});
},
// 跳转11
onPageJump(url) {
uni.navigateTo({
url: url
});
},
}
}
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.gray {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
}
.yigoumaiList{ background-color: #fff;
.btns{ margin-left: 20rpx; width: calc(100% - 200rpx); box-sizing: border-box; font-size: 34rpx; justify-content: space-between;
.item{ margin-bottom:30rpx; width: 20%; text-align: center;
image{
display: block; height: 108rpx;
}
.v1{margin-top: -10rpx;}
}
}
.author{
font-size: 28rpx; color: #999;
}
.info{width:200rpx;
image{width:100% ; height: 280rpx; border-radius: 20rpx;}
}
.icons{ margin-top: 10rpx;margin-left: -10rpx;
text{font-size: 26rpx; margin-top: -10rpx; color: #999;}
}
}
.hehan {
width: 50%;
margin: 0 auto;
}
.home_lunbo {
margin: 40rpx 30rpx 0 30rpx;
}
.mytabs {
// background: url('@/static/icon/bgtushu.png') no-repeat left top;
height: 80rpx;
// margin-bottom: 30rpx;
.item {
border-radius: 10rpx;
background-color: #c6ead0;
width: 48%;
// margin: 0 10rpx;
text-align: center;
color: #3c7f56;
font-size: 36rpx;
line-height: 80rpx;
}
.item.active {
background-color: #3c7f56;
color: #fff;
}
.item1 {
margin-right: 20rpx;
}
}
.listenItem {
image {
width: 100%;
height: 280rpx;
border-radius: 20rpx;
}
}
.shuwuLink {
padding: 0 20rpx;
image {
border-radius: 30rpx;
}
}
.contentButton {
margin: 50rpx 0;
}
.quesheng {
text-align: center;
margin-top: 100rpx;
color: #8b8a91;
}
.bookName {
margin-top: 30rpx;
display: block;
white-space: nowrap;
// font-weight: bold;
overflow-x: hidden;
text-overflow: ellipsis;
font-size: 30rpx;
color: #333;
padding: 10rpx 0;
}
// .videoBox{position: relative;}
.playButton {
position: absolute;
z-index: 1;
right: 4px;
bottom: 4px;
padding: 5px;
border-radius: 100%;
}
uni-image {
width: auto !important;
height: 350rpx;
}
.u-row {
flex-wrap: wrap;
}
.u-col {
overflow: hidden;
margin-bottom: 30rpx;
overflow: hidden;
}
.listenList {
padding:0 20rpx;
box-sizing: border-box;
width: calc(100% - 10rpx);
}
.flexbox {
display: flex;
}
.scroll-Y {
height: 300rpx;
}
// .scroll-view_H {
// white-space: nowrap;
// width: 100%;
// }
.scroll-view_H{background-color: #fff;white-space: nowrap;
padding:10rpx ; margin-top: 12rpx;}
.scroll-view_H{
.item { padding: 10rpx; overflow: hidden; display: inline-block; padding-bottom: 0;
width: 180rpx !important; margin-right: 20rpx; border-radius: 10rpx;
.videoBox{
image{display: block; width:150rpx;
height: 170rpx;
}
}
.bookName{display: block; margin-top: 6rpx; color: #666; font-size: 24rpx; white-space: nowrap;
overflow-x: hidden; overflow: hidden;
text-overflow: ellipsis;}
}
// .item.active{margin-right: 20rpx; border: 1px solid #55aa00; border-radius: 10rpx;}
}
.ProTabs{
// margin: 20rpx 0;
padding:0 20rpx;
text{padding: 8rpx 14rpx; font-size: 32rpx; display: inline-block; border-radius: 10rpx; overflow: hidden;
// background-color: #eee;
color: #55aa7f; margin-right: 10rpx;}
text.cur{background-color:#55aa7f ; color: #fff;}
}
.scroll-view-item {
height: 300rpx;
line-height: 300rpx;
text-align: center;
font-size: 36rpx;
}
.scroll-view-item_H {
display: inline-block;
width: 60%;
height: 300rpx;
line-height: 300rpx;
text-align: center;
font-size: 36rpx;
}
.head_line {
margin: 50rpx 0;
b {
display: inline-block;
width: 12rpx;
height: 40rpx;
background-color: #54a966;
vertical-align: bottom;
margin: 0 20rpx 0 0;
}
text {
font-size: 32rpx;
font-weight: bold;
}
i {
float: right;
font-style: normal;
color: #8b8a91;
font-size: 24rpx;
margin: 5rpx 35rpx 0 0;
}
}
.home_bg {
background-image: url('@/static/icon/home_bg.jpg');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
padding: 20rpx;
position: relative;
// margin-bottom: 30rpx;
// height: 400rpx; margin-bottom: 130rpx;
.icon_hua_1 {
// margin: 0 auto;
width: 100%;
text-align: center;
height: 150rpx;
image {
width: 150rpx;
height: 150rpx;
}
}
.icon_hua {
width: 100%;
text-align: center;
display: block;
image {
width: 150rpx;
height: 150rpx;
margin: 0 auto;
}
}
.search_box {
margin: 0 auto;
margin-top: 20rpx;
align-items: center;
width: calc(100% - 30rpx);
margin-top: 0;
margin-bottom: 20rpx;
.search {
height: 56upx;
display: flex;
width: 86%; margin: 0 auto;
align-items: center;
padding: 0upx 40upx;
background-color: #fff;
border-radius: 20upx;
box-shadow: 0 0px 10px 1px #54a96633;
}
.prompt {
color: #838383;
font-size: 24rpx;
}
.icon_search {
background-image: url('@/static/icon/map_ic_search.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 36upx;
height: 36upx;
margin-right: 20upx;
}
}
.searBtn {
width: 80rpx;
align-items: center;
font-size: 30rpx;
color: #fff;
}
}
</style>