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

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

@@ -235,6 +235,32 @@ export const getLatLon = function(tip) {
}); });
} }
// 查看是否有某本书的权限
export const checkBookRight = function(data,callback) {
console.log('接受的值', data)
$http.request({
url: "/book/user/checkUserBook",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data:data,
header: { //默认 无 说明请求头1
'Content-Type': 'application/json'
},
}).then(res => {
// console.log(res,'checkBookRight')
if(res.code === 0){
callback && callback({
success: true,
data: '有权限'
});
}
}).catch(e => {
callback && callback({
success: false,
data: '无权限'
});
})
}
// 单独微信支付 // 单独微信支付
export const setWXPay = function(payInfo, callback) { export const setWXPay = function(payInfo, callback) {
$http.request({ $http.request({

View File

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

View File

@@ -105,7 +105,7 @@
</view> </view>
<image class="feng" v-if="item.images" :src="item.images" mode="aspectFill" @click.stop="toMore(item)"></image> <image class="feng" v-if="item.images" :src="item.images" mode="aspectFill" @click.stop="toMore(item)"></image>
<view class="shupingList"> <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>
<view class="btns flexbox" @click.stop="toMore(item)"> <view class="btns flexbox" @click.stop="toMore(item)">
<span class="left"></span> <span class="left"></span>
@@ -142,6 +142,9 @@ import { data } from 'jquery';
import { import {
mapState, mapMutations mapState, mapMutations
} from 'vuex'; } from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default { export default {
data() { data() {
return { return {
@@ -265,18 +268,55 @@ import { data } from 'jquery';
}, },
// 查看本书更多书评 // 查看本书更多书评
toMore(val){ toMore(val){
console.log(val,'val') // console.log(val,'val')
let data = {
'userId': this.userInfo.id,
'bookId': val.id
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({ uni.navigateTo({
url: '../comments/comments?bookid='+val.id, url: '../comments/comments?bookid='+val.id,
}); });
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
}, },
// 书评详情 // 书评详情
toDetail(val){ toDetail(val){
console.log(val,'val') // console.log(val,'val')
uni.navigateTo({ uni.navigateTo({
url:'../comments/commentsDetail?bookid='+val.bookid+'&bfa_id='+val.id 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){ clickLike(item){
this.$http this.$http
.post("forum/articles/chickForumContlike?forum_id=" + item.id,) .post("forum/articles/chickForumContlike?forum_id=" + item.id,)

View File

@@ -20,10 +20,13 @@
</view> </view>
<view class="tags"> <view class="tags">
<uni-tag class="tag" @click="toMore()" :inverted="true" text="书评" type="success"></uni-tag> <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不打卡 --> <!-- 1:打卡2不打卡 -->
<uni-tag @click="gotoclock()" v-if="bookMessage.clockIn == 1" class="tag" :inverted="true" text="打卡" type="warning"></uni-tag> <uni-tag @click="gotoclock()" v-if="bookMessage.clockIn == 1" class="tag" :inverted="true" text="打卡"
<uni-tag @click="goJiangShu()" v-if="bookMessage.teachIn == 1" class="tag" :inverted="true" text="讲书" type="error"></uni-tag> type="warning"></uni-tag>
<uni-tag @click="goJiangShu()" v-if="bookMessage.teachIn == 1" class="tag" :inverted="true"
text="讲书" type="error"></uni-tag>
</view> </view>
<view class="buy" v-if="!bookMessage.isBuy"> <view class="buy" v-if="!bookMessage.isBuy">
<view class="btn" @click="goBuy"> <view class="btn" @click="goBuy">
@@ -52,11 +55,12 @@
<view class="playList" v-if="libLIst.length > 0"> <view class="playList" v-if="libLIst.length > 0">
<view class="item" v-for="(item,index) in libLIst" :key="index"> <view class="item" v-for="(item,index) in libLIst" :key="index">
<view> <view>
<view v-if="item.isFree == 1" <view v-if="item.isFree == 1" :class="[]" @click="listenOne(item, index)">
:class="[]" @click="listenOne(item, index)">
<span :class="[userInfo.playingInfo.bookId==item.bookId && userInfo.playingInfo.id == item.id ? 'playing' : '','graytitle']">{{item.chapter}}</span>&nbsp;&nbsp; <span
<uni-tag v-if="item.isFree == 1" class="tag" size="small" :inverted="true" text="试听" type="success" /> :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> --> <!-- <image class="playingFig" src="/static/playingGif.gif" mode="aspectFill"></image> -->
</view> </view>
</view> </view>
@@ -87,7 +91,8 @@
<u-divider v-else text="暂无书评数据"></u-divider> <u-divider v-else text="暂无书评数据"></u-divider>
</view> </view>
<view> <view>
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle"></u-back-top> <u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle'
:iconStyle="iconStyle"></u-back-top>
</view> </view>
</view> </view>
@@ -99,8 +104,12 @@
import musicPlay from '@/components/music.vue' import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js'; import $http from '@/config/requestConfig.js';
import { import {
mapState,mapMutations mapState,
mapMutations
} from 'vuex'; } from 'vuex';
import {
checkBookRight
} from '@/config/utils';
export default { export default {
data() { data() {
return { return {
@@ -129,7 +138,9 @@
bookId: '', bookId: '',
bookMessage: { bookMessage: {
flag: false, flag: false,
author:{authorName:''} author: {
authorName: ''
}
}, },
bookCatalogue: [], bookCatalogue: [],
@@ -223,9 +234,24 @@
}, },
// 去讲书 // 去讲书
goJiangShu() { goJiangShu() {
let data = {
'userId': this.userInfo.id,
'bookId': this.bookId
}
checkBookRight(data,res=>{
console.log(res)
if(res.success){
uni.navigateTo({ uni.navigateTo({
url: '../talkBook/talkBookML?bookid=' + this.bookId url: '../talkBook/talkBookML?bookid=' + this.bookId
}); });
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
}, },
// 去听书 // 去听书
gotoListen() { gotoListen() {
@@ -235,14 +261,44 @@
}, },
// 去打卡 // 去打卡
gotoclock() { 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) this.onPageJump('../clock/clock?bookid=' + this.bookId)
}else{
uni.showToast({
title:'购买本书后方可参与打卡!',
icon:'none'
})
}
})
}, },
// 查看本书更多书评 // 查看本书更多书评
toMore(val) { toMore(val) {
console.log(val,'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({ uni.navigateTo({
url: '../comments/comments?bookid=' + this.bookId, url: '../comments/comments?bookid=' + this.bookId,
}); });
}else{
uni.showToast({
title:'购买本书后方可查看此内容!',
icon:'none'
})
}
})
}, },
// 去购买 // 去购买
goBuy() { goBuy() {
@@ -270,9 +326,13 @@
listenOne(item, index) { listenOne(item, index) {
console.log('点击了', index) console.log('点击了', index)
if (this.libLIst.length > 0) { if (this.libLIst.length > 0) {
this.setUserInfo({'playIndex': index}) this.setUserInfo({
'playIndex': index
})
this.$music.setList(this.libLIst, 'autoPlay', index) this.$music.setList(this.libLIst, 'autoPlay', index)
this.setUserInfo({'playVisible': true}) this.setUserInfo({
'playVisible': true
})
uni.setStorage({ uni.setStorage({
key: 'playVisible', key: 'playVisible',
data: true, data: true,
@@ -284,13 +344,17 @@
// 本地存储播放列表 // 本地存储播放列表
uni.setStorage({ uni.setStorage({
key: 'playData', key: 'playData',
data: {'myList':this.libLIst}, data: {
'myList': this.libLIst
},
success: function() { success: function() {
console.log('success'); console.log('success');
} }
}); });
// 系统暂存 // 系统暂存
this.setUserInfo({'myList':this.libLIst}) this.setUserInfo({
'myList': this.libLIst
})
} }
}, },
// 获取章节列表 // 获取章节列表
@@ -352,31 +416,99 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '@/style/mixin.scss'; @import '@/style/mixin.scss';
.playing{color: #1daa5c !important;}
.graytitle{color: #666;} .playing {
.flexbox{display: flex;} color: #1daa5c !important;
}
.graytitle {
color: #666;
}
.flexbox {
display: flex;
}
.tags { .tags {
.tag { .tag {
margin-left: 0; margin-right: 10rpx; 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 { .shupingList {
h4{font-size: 36rpx;} h4 {
.item{padding: 30rpx 20rpx; padding-bottom: 60rpx; border-bottom: 20rpx solid #eee; border-radius: 46rpx;} font-size: 36rpx;
.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; .item {
overflow-x: hidden; font-size: 36rpx; padding: 30rpx 20rpx;
text-overflow: ellipsis;} padding-bottom: 60rpx;
.tag{margin-left: 20rpx;} 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;
}
.head_line { .head_line {
margin: 50rpx 0 0 0; margin: 50rpx 0 0 0;
@@ -403,6 +535,7 @@
margin: 5rpx 35rpx 0 0; margin: 5rpx 35rpx 0 0;
} }
} }
.yq_youhui { .yq_youhui {
.yqLeft { .yqLeft {
display: inline-block; display: inline-block;
@@ -422,6 +555,7 @@
padding: 5rpx 10rpx; padding: 5rpx 10rpx;
} }
} }
.yq_yunfei { .yq_yunfei {
.yqLeft { .yqLeft {
display: inline-block; display: inline-block;
@@ -432,6 +566,7 @@
float: right; float: right;
} }
} }
.book_neir { .book_neir {
margin: 20rpx 0 0 0; margin: 20rpx 0 0 0;
position: relative; position: relative;
@@ -441,8 +576,11 @@
width: 250upx; width: 250upx;
height: 320upx; height: 320upx;
img{width: 250upx;
height: 320upx;} img {
width: 250upx;
height: 320upx;
}
} }
.bn_nes { .bn_nes {
@@ -633,6 +771,7 @@
display: inline-block; display: inline-block;
} }
} }
.youhuiItem { .youhuiItem {
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 10rpx; border-radius: 10rpx;

View File

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

View File

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