接口改动

This commit is contained in:
@fawn-nine
2023-09-27 18:17:01 +08:00
parent 63cbc9da2f
commit aaf15515da
17 changed files with 430 additions and 425 deletions

View File

@@ -96,7 +96,7 @@ import { data } from 'jquery';
getBooks(){
this.$http
.post('book/teach/getTeachBooks',{
'limit': 9,
'limit': 100,
'page': this.page
})
.then(res => {

View File

@@ -5,14 +5,14 @@
<view class="title">{{talkBookDetail.title}}</view>
<view class="voices" v-if="talkBookDetail.voices != '' && audioShow">
<audio style="text-align: left" :src="talkBookDetail.voices" poster="../../static/icon/fengziIcon.jpg"
:name="talkBookDetail.title" :author="bookInfo.authorName" :action="audioAction" controls></audio>
:name="talkBookDetail.title" :author="bookInfo.author.authorName" :action="audioAction" controls></audio>
</view>
<view class="content" v-if="talkBookDetail.content != ''" v-html="talkBookDetail.content"></view>
<view class="content" v-else></view>
<view class="time">
<text>{{talkBookDetail.createTime}}</text>
</view>
<view class="tuijin" v-if="!isBuy">
<view class="tuijin" v-if="!isBuy && bookInfo.productId != null">
<p>觉得这本书还不错</p>
<view class="flexbox" style="justify-content: space-between; border: 1px solid #55aa7f; padding: 10rpx; border-radius: 10rpx;">
<view class="flexbox">
@@ -22,7 +22,7 @@
</view>
<view>
<text style=" display: inline-block; margin-top: 40rpx;">{{bookInfo.name}}</text><br/>
<text>作者{{bookInfo.authorName}}</text>
<text>作者{{bookInfo.author.authorName}}</text>
</view>
</view>
<view class="btn" @click="gotoBuy()">
@@ -57,7 +57,11 @@
playData: {},
teachId: null, // 讲书id
bookId: null, // 书籍id
bookInfo: {}, // 书籍信息
bookInfo: {
author:{
authorName:''
}
}, // 书籍信息
talkBookDetail: {},
}
},
@@ -78,13 +82,16 @@
// 购买
gotoBuy(){
uni.navigateTo({
url: '../bookShop/settlementBook?type=2&list=' + this.bookId
url: '../bookShop/commodityDetail?id=' + this.bookInfo.productId
});
},
getBookInfo() {
// 获取书本基本信息
this.$http
.post('book/book/appinfo/' + this.bookId + '/' + this.userInfo.id)
this.$http
.post('book/book/getBookInfo', {
'bookId': this.bookId,
'userId': this.userInfo.id
})
.then(res => {
if (res.code == 0) {
console.log(res, 'res')

View File

@@ -1,11 +1,11 @@
<template>
<!--父组件-->
<view class="container">
<view class="container" style="padding-bottom: 10rpx;">
<!-- <view class="mini"></view> -->
<view>
<z-nav-bar title="讲书目录"></z-nav-bar>
<!-- 基本信息 -->
<!-- 基本信息 -->
<view class="book_neir">
<view class="flexbox info">
<view class="item">
@@ -24,8 +24,8 @@
</view>
<view
style="color: #9b9b9b;font-size: 28rpx;margin:20rpx 0 0 0;max-width: 400rpx;line-height: 38rpx;">
<p @click="onAuCHJump(bookInfo.authorId,1)" style="margin-bottom: 20rpx;">
{{bookInfo.authorName}} [] >
<p @click="onAuCHJump(bookInfo.author.id,1)" style="margin-bottom: 20rpx;">
{{bookInfo.author.authorName}} [] >
</p>
<p @click="onAuCHJump(item.id,2)" v-for="item in this.bookInfo.publisherNIList">
{{item.title}} >
@@ -58,6 +58,15 @@
</view>
</view>
</view>
<view style="width: 100%;">
<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>
<music-play :playData="playData"></music-play>
@@ -84,81 +93,57 @@
data() {
return {
isBuy: false, // true 已购买false 未购买
playData: {},
stopPlay: false, // 关闭音频
jia: false, // 下一I首
forceRefresh: true,
current: 0,
bookInfo: {}, // 书籍详情
playData: {},
bookInfo: {
author:{
authorName:''
}
}, // 书籍详情
bookid: null, // 书籍id
playid: null, // 正在播放的章节id
playchapName: '', // 正在播放的章节名称
playIndex: null, // 正在播放的序号值
onlineH: { // 线上的历史听书
playIndex: null, // 存储的播放index
time: 0, // 存储的播放秒数
},
currentTime: {
time: 0,
flag: ''
},
freeChapterCount: 0, // 免费章节数
pageTab: [{
name: '正在播放'
},
{
name: '播放列表'
}
],
fengImg: '', // 播放封面
libLIst: [
// {
// name:"第二章",
// url: 'https://ehh-private-01.oss-cn-beijing.aliyuncs.com/2023/07/14/6c6d7f7b947c4dc18881e8682b4dc36a2ce742.mp3'
// },
], // 书籍目录
videoList: [], //音频文件
BsNav: [ //倍数-自定义
{
id: 1.0,
bs: '1.0'
}, {
id: 1.5,
bs: '1.5'
}, {
id: 2.0,
bs: '2.0'
}
],
orderPlayBtn: false, // 是否开启按顺序播放
LibVisible: false,
boardRemark: '',
StyleSheet: 'font-size:36rpx; text-align:center',
jian: false, // 上一曲切换
status:3,
freeChapterCount: 0, // 免费章节数
libLIst: [], // 书籍目录
videoList: [], //音频文件
page:1,
totalPage:0,
}
},
onPullDownRefresh() {
console.log('下拉刷新了')
this.libLIst = []
this.page = 1
this.totalPage = 0
uni.stopPullDownRefresh();
},
onReachBottom() {
console.log('到底了')
if(this.page+1 <= this.totalPage){
this.page++
this.status = 0
this.getLibList()
}else{
this.status = 1
}
},
onHide() {
this.libLIst = []
this.page = 1
},
//第一次加载
onLoad(e) {
console.log('------------------')
// 隐藏原生的tabbar
console.log(e, 'e')
uni.hideTabBar();
this.bookid = e.bookid
//console.log(this.userInfo.playFlag,'this.userInfo.playFlag')
this.bookid = e.bookid
},
onShow() {
// this.libLIst = []
// this.page = 1
// this.totalPage = 0
this.getLibList()
this.getBookInfo()
},
created() {
},
onShow() {
// console.log(this.userInfo.orderPlayBtn,'初始化')
if (this.userInfo.orderPlayBtn != undefined) {
this.orderPlayBtn = this.userInfo.orderPlayBtn
}
},
computed: {
...mapState(['userInfo'])
@@ -181,8 +166,11 @@
},
getBookInfo() {
// 获取书本基本信息
this.$http
.post('book/book/appinfo/' + this.bookid + '/' + this.userInfo.id)
this.$http
.post('book/book/getBookInfo', {
'bookId': this.bookid,
'userId': this.userInfo.id
})
.then(res => {
if (res.code == 0) {
console.log(res, 'res')
@@ -218,123 +206,30 @@
.post('book/teach/getBookTeachItems', {
'bookId': this.bookid,
'limit': 10,
'page': 1
'page': this.page
// 'userid': this.userInfo.id,
// 'bookid':
// 'id': this.playid
})
.then(res => {
if (res.code == 0) {
console.log(res, 999)
console.log(res, '章节目录')
if (res.page.records.length > 0) {
this.libLIst = res.page.records
// this.fengImg = res.images
this.libLIst = this.libLIst.concat(res.page.records)
this.status = 3
this.totalPage = res.page.pages
} else {
this.libLIst = []
// uni.showToast({
// title:'暂无可听章节哦~',
// icon:'none'
// })
// setTimeout(()=>{
// uni.navigateBack({ // 返回上一页
// delta: 1
// });
// },2000)
this.totalPage = 0
}
}
}).catch((e) => {
console.log(e.msg)
})
},
// 获取音频数据
listen(e, index) {
console.log(this.currentTime, 'this.currentTime')
// console.log(e,'playchapName')
this.playid = e.chapterId
this.playIndex = index
this.playchapName = e.chapterName
this.playIndex >= this.libLIst.length - 1 ? this.jia = true : this.jia = false
this.playIndex > 0 ? this.jian = true : this.jian = false
// console.log(this.jian,45454545)
this.forceRefresh = false
this.$http
.post('book/bookchaptercontent/appBooksChapterContent', {
'userId': this.userInfo.id,
'bookid': this.bookid,
'id': this.playid
})
.then(res => {
//this.tmpChapter.text = res.bookCatalogue
if (res.code == 0) {
// console.log(res)
if (res.bookCatalogue.voices[0] != null && res.bookCatalogue.voices[0].length > 15) {
// console.log('走这')
this.videoList = []
this.boardRemark = res.bookCatalogue.chapter[0]
this.fengImg = res.image
this.videoList.push({
'recorPath': res.bookCatalogue.voices[0]
})
console.log(res.bookCatalogue.voices[0], 'path')
this.forceRefresh = true
} else {
this.forceRefresh = true
uni.showToast({
title: '暂无可播放音频,加载下一章',
icon: 'none',
duration: 2000
})
setTimeout(() => {
if (this.playIndex + 1 >= this.libLIst.length) {
// this.stopPlay = true
uni.showToast({
title: '本书已全部播放完毕',
icon: 'none',
duration: 2000
})
} else {
this.listen(this.libLIst[this.playIndex], this.playIndex)
}
}, 2000)
}
}
}).catch((e) => {})
},
// 下一首
xiayishou() {
console.log('加载下一首')
if (this.playIndex + 1 <= this.libLIst.length - 1) {
this.playIndex += 1
this.saveRate(0)
this.currentTime.time = 0
this.currentTime.flag = ''
this.listen(this.libLIst[this.playIndex], this.playIndex)
} else {
this.jia = false
uni.showToast({
title: "音频已经播放完毕!",
icon: "none"
})
}
},
TabChange(e) {
// tab 切换
this.current = e.index
// console.log(e)
}
},
// watch:{
// list: {
// handler (newName, oldName) {
// console.log(newName)
// },
// immediate: true
// }
// }
}
</script>