书籍附加功能添加权限检查

This commit is contained in:
@fawn-nine
2023-11-27 17:28:46 +08:00
parent f53a3b1b62
commit 815554aa18
6 changed files with 495 additions and 210 deletions

View File

@@ -139,6 +139,9 @@ import { data } from 'jquery';
import {
mapState
} from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default {
data() {
return {
@@ -218,9 +221,24 @@ import { data } from 'jquery';
}
if(e==2){
// 跳转到读书打卡
uni.navigateTo({
url: '../clock/clock?bookid='+ productInfo.id
let data = {
'userId': this.userInfo.id,
'bookId': productInfo.id
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../clock/clock?bookid='+ productInfo.id
})
}else{
uni.showToast({
title:'购买本书后方可参与打卡!',
icon:'none'
})
}
})
}
if(e==3){
// 跳转到购买

View File

@@ -102,10 +102,10 @@
<view class="btns flexbox" @click.stop="toMore(item)">
<view class="title">{{item.name}}</view>
<view class="pianshuping">{{item.forumNum}}篇书评</view>
</view>
</view>
<image class="feng" v-if="item.images" :src="item.images" mode="aspectFill" @click.stop="toMore(item)"></image>
<view class="shupingList">
<view class="description" v-for="(item1,index1) in item.forums" :key="index1" @click.stop="toDetail(item1)">{{item1.title}}</view>
<view class="description" v-for="(item1,index1) in item.forums" :key="index1" @click.stop="toDetail1(item1)">{{item1.title}}</view>
</view>
<view class="btns flexbox" @click.stop="toMore(item)">
<span class="left"></span>
@@ -142,6 +142,9 @@ import { data } from 'jquery';
import {
mapState, mapMutations
} from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default {
data() {
return {
@@ -265,17 +268,54 @@ import { data } from 'jquery';
},
// 查看本书更多书评
toMore(val){
console.log(val,'val')
uni.navigateTo({
url: '../comments/comments?bookid='+val.id,
});
// console.log(val,'val')
let data = {
'userId': this.userInfo.id,
'bookId': val.id
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../comments/comments?bookid='+val.id,
});
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
// 书评详情
toDetail(val){
console.log(val,'val')
uni.navigateTo({
url:'../comments/commentsDetail?bookid='+val.bookid+'&bfa_id='+val.id
// console.log(val,'val')
uni.navigateTo({
url:'../comments/commentsDetail?bookid='+val.bookid+'&bfa_id='+val.id
})
},
// 判断健全
toDetail1(val){
// console.log(val,'val')
let data = {
'userId': this.userInfo.id,
'bookId': val.bookid
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url:'../comments/commentsDetail?bookid='+val.bookid+'&bfa_id='+val.id
})
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
clickLike(item){
this.$http

View File

@@ -4,7 +4,7 @@
<view class="book_neir flexbox">
<view class="bn_img">
<img :src="bookMessage.images" mode="scaleToFill">
</view>
<view class="bn_nes">
<view style="font-weight: bold;margin-bottom: 30rpx;">
@@ -20,10 +20,13 @@
</view>
<view class="tags">
<uni-tag class="tag" @click="toMore()" :inverted="true" text="书评" type="success"></uni-tag>
<uni-tag @click="gotoListen()" class="tag" v-if="bookMessage.canListen" :inverted="true" text="听书" type="primary"></uni-tag>
<uni-tag @click="gotoListen()" class="tag" v-if="bookMessage.canListen" :inverted="true" text="听书"
type="primary"></uni-tag>
<!-- 1:打卡2不打卡 -->
<uni-tag @click="gotoclock()" v-if="bookMessage.clockIn == 1" class="tag" :inverted="true" text="打卡" type="warning"></uni-tag>
<uni-tag @click="goJiangShu()" v-if="bookMessage.teachIn == 1" class="tag" :inverted="true" text="讲书" type="error"></uni-tag>
<uni-tag @click="gotoclock()" v-if="bookMessage.clockIn == 1" class="tag" :inverted="true" text="打卡"
type="warning"></uni-tag>
<uni-tag @click="goJiangShu()" v-if="bookMessage.teachIn == 1" class="tag" :inverted="true"
text="讲书" type="error"></uni-tag>
</view>
<view class="buy" v-if="!bookMessage.isBuy">
<view class="btn" @click="goBuy">
@@ -43,52 +46,54 @@
<text>
{{bookMessage.description}}
</text>
</view>
<u-divider v-else text="暂无简介信息"></u-divider>
<view class="head_line" style="margin-bottom:30rpx;">
<b></b>
<text>精彩试听</text>
</view>
<view class="playList" v-if="libLIst.length > 0">
<view class="item" v-for="(item,index) in libLIst" :key="index" >
<view >
<view v-if="item.isFree == 1"
:class="[]" @click="listenOne(item, index)">
<span :class="[userInfo.playingInfo.bookId==item.bookId && userInfo.playingInfo.id == item.id ? 'playing' : '','graytitle']">{{item.chapter}}</span>&nbsp;&nbsp;
<uni-tag v-if="item.isFree == 1" class="tag" size="small" :inverted="true" text="试听" type="success" />
<!-- <image class="playingFig" src="/static/playingGif.gif" mode="aspectFill"></image> -->
</view>
</view>
</view>
<view class="" style="text-align: center;" @click="gotoListen">
<text style="font-size: 28rpx; color:#27b386">查看完整目录</text>
</view>
</view>
<u-divider v-else text="暂无试听数据"></u-divider>
<view class="head_line" style="margin-bottom:30rpx;">
<b></b>
<text>热门书评</text>
</view>
<view class="list shupingList" v-if="shupingList.length > 0">
<view class="item" @click.stop="toDetail(item)" v-for="item in shupingList" :key="item.id">
<h4>{{item.title}}</h4>
<view class="" v-if="item.content && item.content != '' ">
<view class="info" v-html="item.content">
<u-divider v-else text="暂无简介信息"></u-divider>
<view class="head_line" style="margin-bottom:30rpx;">
<b></b>
<text>精彩试听</text>
</view>
<view class="playList" v-if="libLIst.length > 0">
<view class="item" v-for="(item,index) in libLIst" :key="index">
<view>
<view v-if="item.isFree == 1" :class="[]" @click="listenOne(item, index)">
<span
:class="[userInfo.playingInfo.bookId==item.bookId && userInfo.playingInfo.id == item.id ? 'playing' : '','graytitle']">{{item.chapter}}</span>&nbsp;&nbsp;
<uni-tag v-if="item.isFree == 1" class="tag" size="small" :inverted="true" text="试听"
type="success" />
<!-- <image class="playingFig" src="/static/playingGif.gif" mode="aspectFill"></image> -->
</view>
</view>
</view>
<view class="more" @click.stop="toDetail(item)">立即查看</view>
<view class="" style="text-align: center;" @click="gotoListen">
<text style="font-size: 28rpx; color:#27b386">查看完整目录</text>
</view>
</view>
<view class="moreBtn" @click="toMore(item)">
<text>查看更多</text>
<u-divider v-else text="暂无试听数据"></u-divider>
<view class="head_line" style="margin-bottom:30rpx;">
<b></b>
<text>热门书评</text>
</view>
<view class="list shupingList" v-if="shupingList.length > 0">
<view class="item" @click.stop="toDetail(item)" v-for="item in shupingList" :key="item.id">
<h4>{{item.title}}</h4>
<view class="" v-if="item.content && item.content != '' ">
<view class="info" v-html="item.content">
</view>
</view>
<view class="more" @click.stop="toDetail(item)">立即查看</view>
</view>
<view class="moreBtn" @click="toMore(item)">
<text>查看更多</text>
</view>
</view>
<u-divider v-else text="暂无书评数据"></u-divider>
</view>
<view>
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle'
:iconStyle="iconStyle"></u-back-top>
</view>
<u-divider v-else text="暂无书评数据"></u-divider>
</view>
<view>
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle"></u-back-top>
</view>
</view>
<music-play :playData="playData"></music-play>
@@ -96,25 +101,29 @@
</template>
<script>
import musicPlay from '@/components/music.vue'
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
import {
mapState,mapMutations
mapState,
mapMutations
} from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default {
data() {
return {
playData:{},
youhuiShow:false,
youhuiIndex:'',
youhuiList:[], // 优惠券列表
playData: {},
youhuiShow: false,
youhuiIndex: '',
youhuiList: [], // 优惠券列表
couponMz: 0, // 优惠券钱数
useCouponAmount: '' , // 使用的优惠券金额
useCouponAmount: '', // 使用的优惠券金额
bookJiageA: 0,
youhuiContent: {
coupons:{
id:'0'
coupons: {
id: '0'
}
},
scrollTop: 0,
@@ -128,9 +137,11 @@
tab_muJian: 0,
bookId: '',
bookMessage: {
flag: false,
author:{authorName:''}
flag: false,
author: {
authorName: ''
}
},
bookCatalogue: [],
bgiStyle: {
@@ -145,10 +156,10 @@
buyShow: false,
buysignShow: false,
buysignContent: '',
libLIst:[],
freeChapterCount:0,
isBuy:false,
shupingList:[],
libLIst: [],
freeChapterCount: 0,
isBuy: false,
shupingList: [],
};
},
@@ -170,7 +181,7 @@
onShow() {
this.getData();
},
components: {
components: {
musicPlay
},
//方法
@@ -185,11 +196,11 @@
'userId': this.userInfo.id
})
.then(res => {
console.log('书详细',res.book)
console.log('书详细', res.book)
this.bookMessage = res.book
this.bokMesDet.bookId = res.book.id
this.bokMesDet.bookName = res.book.name,
this.bokMesDet.images = res.book.images
this.bokMesDet.images = res.book.images
this.isBuy = res.book.isBuy
this.freeChapterCount = res.book.freeChapterCount
this.bokMesDet.userId = this.userInfo.id
@@ -219,120 +230,173 @@
this.getLibList()
// 获取
this.getComments()
},
// 去讲书
goJiangShu(){
uni.navigateTo({
url: '../talkBook/talkBookML?bookid='+ this.bookId
});
goJiangShu() {
let data = {
'userId': this.userInfo.id,
'bookId': this.bookId
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../talkBook/talkBookML?bookid=' + this.bookId
});
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
// 去听书
gotoListen(){
uni.navigateTo({
url: "../listen/listen?bookid="+ this.bookId
gotoListen() {
uni.navigateTo({
url: "../listen/listen?bookid=" + this.bookId
});
},
// 去打卡
gotoclock(){
this.onPageJump('../clock/clock?bookid='+ this.bookId)
gotoclock() {
let data = {
'userId': this.userInfo.id,
'bookId': this.bookId
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
this.onPageJump('../clock/clock?bookid=' + this.bookId)
}else{
uni.showToast({
title:'购买本书后方可参与打卡!',
icon:'none'
})
}
})
},
// 查看本书更多书评
toMore(val){
console.log(val,'val')
uni.navigateTo({
url: '../comments/comments?bookid='+ this.bookId,
});
toMore(val) {
// console.log(val, 'val')
let data = {
'userId': this.userInfo.id,
'bookId': this.bookId
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../comments/comments?bookid=' + this.bookId,
});
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
// 去购买
goBuy(){
goBuy() {
uni.navigateTo({
url: '../bookShop/commodityDetail?id=' + this.bookMessage.productId
url: '../bookShop/commodityDetail?id=' + this.bookMessage.productId
});
},
// 获取书评
getComments(){
getComments() {
let data = {
'page': 1,
'limit': 3,
'bookid' : this.bookId
'bookid': this.bookId
}
this.$http
.post('forum/articles/descupdatelist', data)
.then(res => {
console.log(res.page.list,'评论获取成功')
this.shupingList = res.page.list
}).catch((e)=>{
console.log(e,'e')
.then(res => {
console.log(res.page.list, '评论获取成功')
this.shupingList = res.page.list
}).catch((e) => {
console.log(e, 'e')
})
},
// 播放单个音频
listenOne(item,index){
console.log('点击了',index)
if(this.libLIst.length > 0){
this.setUserInfo({'playIndex': index})
this.$music.setList(this.libLIst,'autoPlay',index)
this.setUserInfo({'playVisible': true})
listenOne(item, index) {
console.log('点击了', index)
if (this.libLIst.length > 0) {
this.setUserInfo({
'playIndex': index
})
this.$music.setList(this.libLIst, 'autoPlay', index)
this.setUserInfo({
'playVisible': true
})
uni.setStorage({
key: 'playVisible',
data: true,
success: function () {
success: function() {
console.log('success');
}
});
// 本地存储播放列表
uni.setStorage({
key: 'playData',
data: {'myList':this.libLIst},
success: function () {
console.log('success');
}
});
// 系统暂存
this.setUserInfo({'myList':this.libLIst})
}
// 本地存储播放列表
uni.setStorage({
key: 'playData',
data: {
'myList': this.libLIst
},
success: function() {
console.log('success');
}
});
// 系统暂存
this.setUserInfo({
'myList': this.libLIst
})
}
},
// 获取章节列表
getLibList(){
getLibList() {
this.$http
.post('book/book/getBookCatalogue', {
'userId': this.userInfo.id,
'bookId': this.bookId,
// 'id': this.playid
})
.then(res => {
if(res.code == 0){
console.log(res,999)
if(res.BookCatalogue.length > 0){
res.BookCatalogue.map( item => {
if(item.isFree == 1){
.then(res => {
if (res.code == 0) {
console.log(res, 999)
if (res.BookCatalogue.length > 0) {
res.BookCatalogue.map(item => {
if (item.isFree == 1) {
this.libLIst.push(item)
}
})
console.log('改变后的试听目录',this.libLIst)
console.log('改变后的试听目录', this.libLIst)
//this.libLIst = res.BookCatalogue
// this.fengImg = res.images
}
}
}).catch((e)=>{
}).catch((e) => {
console.log(e.msg)
})
},
},
// 跳转
onPageJump(url) {
uni.navigateTo({
url: url
});
});
},
// 书评详情
toDetail(val){
console.log(val,'val')
toDetail(val) {
console.log(val, 'val')
uni.navigateTo({
url:'../comments/commentsDetail?bookid='+val.bookid+'&bfa_id='+val.id
url: '../comments/commentsDetail?bookid=' + val.bookid + '&bfa_id=' + val.id
})
},
// 信息介绍跳转
@@ -342,8 +406,8 @@
});
},
@@ -352,35 +416,103 @@
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.playing{color: #1daa5c !important;}
.graytitle{color: #666;}
.flexbox{display: flex;}
.tags{
.tag{
margin-left: 0; margin-right: 10rpx;
.playing {
color: #1daa5c !important;
}
.graytitle {
color: #666;
}
.flexbox {
display: flex;
}
.tags {
.tag {
margin-left: 0;
margin-right: 10rpx;
}
}
.moreBtn{text-align: center; margin-top: 20rpx;
text{padding: 6rpx 20rpx; border: 1px solid #27b386; color: #27b386; border-radius: 10rpx;}
.moreBtn {
text-align: center;
margin-top: 20rpx;
text {
padding: 6rpx 20rpx;
border: 1px solid #27b386;
color: #27b386;
border-radius: 10rpx;
}
}
.buy{ text-align: right;
.btn{display: inline-block; padding: 6rpx 8rpx; font-size: 36rpx; color: #d75f54; border: 1px solid #d75f54; border-radius: 10rpx;}
.buy {
text-align: right;
.btn {
display: inline-block;
padding: 6rpx 8rpx;
font-size: 36rpx;
color: #d75f54;
border: 1px solid #d75f54;
border-radius: 10rpx;
}
}
.shupingList{
h4{font-size: 36rpx;}
.item{padding: 30rpx 20rpx; padding-bottom: 60rpx; border-bottom: 20rpx solid #eee; border-radius: 46rpx;}
.more{display: inline-block; margin-top: 20rpx; padding: 3rpx 5rpx; color: #27b386; border: 1px solid #27b386; border-radius:8rpx;}
.info{line-height:40rpx ; font-size: 26rpx; margin-top: 20rpx; height: 80rpx; overflow: hidden; }
.shupingList {
h4 {
font-size: 36rpx;
}
.item {
padding: 30rpx 20rpx;
padding-bottom: 60rpx;
border-bottom: 20rpx solid #eee;
border-radius: 46rpx;
}
.more {
display: inline-block;
margin-top: 20rpx;
padding: 3rpx 5rpx;
color: #27b386;
border: 1px solid #27b386;
border-radius: 8rpx;
}
.info {
line-height: 40rpx;
font-size: 26rpx;
margin-top: 20rpx;
height: 80rpx;
overflow: hidden;
}
}
.playList{padding: 20rpx; color: #666; }
.playList .item{display: block;line-height:60rpx; white-space: nowrap;
overflow-x: hidden; font-size: 36rpx;
text-overflow: ellipsis;}
.tag{margin-left: 20rpx;}
.playList {
padding: 20rpx;
color: #666;
}
.playList .item {
display: block;
line-height: 60rpx;
white-space: nowrap;
overflow-x: hidden;
font-size: 36rpx;
text-overflow: ellipsis;
}
.tag {
margin-left: 20rpx;
}
.head_line {
margin: 50rpx 0 0 0;
b {
display: inline-block;
width: 12rpx;
@@ -389,12 +521,12 @@
vertical-align: bottom;
margin: 0 20rpx 0 0;
}
text {
font-size: 32rpx;
font-weight: bold;
}
i {
float: right;
font-style: normal;
@@ -403,46 +535,52 @@
margin: 5rpx 35rpx 0 0;
}
}
.yq_youhui {
.yqLeft {
display: inline-block;
margin-right: 10rpx;
}
.yqRight {
float: right;
}
.yq_youhui {
.yqLeft {
display: inline-block;
margin-right: 10rpx;
}
.dagnqian {
float: right;
font-size: 22rpx;
background-color: #dd1919;
color: #fff;
border-radius: 20rpx;
padding: 5rpx 10rpx;
}
.yqRight {
float: right;
}
.yq_yunfei {
.yqLeft {
display: inline-block;
margin-right: 10rpx;
}
text {
float: right;
}
.dagnqian {
float: right;
font-size: 22rpx;
background-color: #dd1919;
color: #fff;
border-radius: 20rpx;
padding: 5rpx 10rpx;
}
}
.yq_yunfei {
.yqLeft {
display: inline-block;
margin-right: 10rpx;
}
text {
float: right;
}
}
.book_neir {
margin: 20rpx 0 0 0;
position: relative;
.bn_img {
width: 250upx;
height: 320upx;
img{width: 250upx;
height: 320upx;}
img {
width: 250upx;
height: 320upx;
}
}
.bn_nes {
@@ -493,13 +631,13 @@
line-height: 40rpx;
}
}
.book_vip{
.book_vip {
background: url('../../static/icon/mine_card.png') top center no-repeat;
color: #87510d;
font-weight: bold;
}
.book_tab {
@@ -633,6 +771,7 @@
display: inline-block;
}
}
.youhuiItem {
border: 1px solid #d9d9d9;
border-radius: 10rpx;
@@ -644,12 +783,12 @@
background-color: #fff;
font-size: 30rpx;
}
.youhuiItem>view {
float: left;
}
.youhuiItem.youItem_style {
border-color: #fd6004;
}
</style>
</style>

View File

@@ -110,6 +110,9 @@
import {
mapState,mapMutations
} from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default {
components: {
// cxAdudioPlay,
@@ -218,10 +221,23 @@
// },
// 查看本书更多书评
toMore(val){
console.log(val,'val')
uni.navigateTo({
url: '../comments/comments?bookid='+ this.bookid,
});
let data = {
'userId': this.userInfo.id,
'bookId': this.bookid
}
checkBookRight(data,res=>{
// console.log(res)
if(res.success){
uni.navigateTo({
url: '../comments/comments?bookid='+ this.bookid,
});
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
// 去听书
gotoListen(){
@@ -231,15 +247,43 @@
},
// 去讲书
goJiangShu(){
uni.navigateTo({
url: '../talkBook/talkBookDetail?bookId='+ this.bookid
});
let data = {
'userId': this.userInfo.id,
'bookId': this.bookid
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../talkBook/talkBookML?bookid=' + this.bookid
});
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
// 去打卡
gotoclock(){
uni.navigateTo({
url: '../clock/clock?bookid='+ this.bookid,
});
gotoclock(){
let data = {
'userId': this.userInfo.id,
'bookId': this.bookid
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../clock/clock?bookid='+ this.bookid,
});
}else{
uni.showToast({
title:'购买本书后方可参与打卡!',
icon:'none'
})
}
})
},
getBookInfo(){
// 获取书本基本信息

View File

@@ -86,6 +86,9 @@
mapState,
mapMutations
} from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default {
components: {
// cxAdudioPlay,
@@ -157,10 +160,25 @@
// 查看本书更多书评
toMore(val) {
console.log(val, 'val')
uni.navigateTo({
url: '../comments/comments?bookid=' + this.bookid,
});
// console.log(val, 'val')
let data = {
'userId': this.userInfo.id,
'bookId': this.bookid
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({
url: '../comments/comments?bookid=' + this.bookid,
});
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
},
// 去打卡
gotoclock() {