阶段性提交

This commit is contained in:
@fawn-nine
2024-06-06 15:06:04 +08:00
parent ae7971a71e
commit b295b7ef4a
19 changed files with 1382 additions and 165 deletions

View File

@@ -2,17 +2,85 @@
<view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<z-nav-bar title="课程设置"></z-nav-bar>
<public-module></public-module>
<z-nav-bar :title="courseInfo.id ? courseTitle : '课程说明'">
<uni-icons type="bars" class="topRight" slot="right" @click="showDrawer('showRight')" size="22"></uni-icons>
</z-nav-bar>
<view class="containerBg">
<view class="example-body">
<!-- <button type="primary" @click="showDrawer('showRight')"><text class="word-btn-white">全部课程</text>
</button> -->
<uni-drawer ref="showRight" mode="right" :width="320" @change="changeD($event,'showRight')">
<!-- <view class="close">
<button @click="closeDrawer('showRight')"><text
class="word-btn-white">关闭Drawer</text></button>
</view> -->
<view class="proTitle">
<text>点击课程名称即可查看对应的课程说明</text>
</view>
<uni-collapse accordion v-model="accordionVal" v-if="treeList.length > 0" @change="collapseChange">
<uni-collapse-item v-for="(item, index) in treeList" :key="index" :title="item.title"
:show-animation="true">
<view class="content">
<!-- <text class="text">{{item.title}}</text> -->
<view class="sub1List">
<view :class="['item', 'leve2',curId == item1.id ? 'active' : '']"
v-for="(item1, index1) in item.children" :key="index1"
@click.stop="clickCourseInfo(item1)">
<text class="textss"> {{item1.title}}</text>
<view class="sub2List" v-if="item1.children">
<view :class="['item', 'leve3',curId == item2.id ? 'active' : '']"
v-for="(item2, index2) in item1.children" :key="index2"
@click.stop="clickCourseInfo(item2)">
<text class="textss">{{item2.title}}</text>
<view class="sub3List" v-if="item2.children">
<view :class="['item', 'leve4',curId == item3.id ? 'active' : '']"
v-for="(item3, index3) in item2.children" :key="index3"
@click.stop="clickCourseInfo(item3)">
<text class="textss">{{item3.title}}33</text>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</uni-collapse-item>
</uni-collapse>
</uni-drawer>
</view>
<view class="infoBox" v-if="courseInfo.id">
<uni-section :title="courseTitle" type="line" titleFontSize="16px">
<rich-text v-if="courseInfo.content" class="content"
:nodes="formatRichText(courseInfo.content)"></rich-text>
<!-- <text>超强树选择器树组件树插件无限级联树单选树多选树自定义样式树树形选择 </text> -->
<view class="audio" v-if="courseInfo.mediaType == 2 && courseInfo.media != ''">
<audio style="text-align: left" :src="current.src" :poster="current.poster" :name="current.name"
:author="current.author" :action="audioAction" controls></audio>
</view>
<view>
<view v-if="courseInfo.mediaType ==1 && courseInfo.media != ''" style="width: 100%;height: 100%;text-align: center;" v-html="videoHTML">
</view>
<!-- 视频播放器样式 -->
<!-- <view class="videoTemp" v-show="showTemp">
<u-icon name="play-circle" color="#fff" size="40" @click="clickToPlay"></u-icon>
<image src="../../static/video.jpg" mode="aspectFit"></image>
</view> -->
<!-- <view class="" v-if="!showTemp"> -->
<!-- <video ref="myVideo" id="myVideo" poster="../../static/videoF.jpg" src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"
enable-danmu danmu-btn controls @ended="playEnd"></video> -->
<!-- </view> -->
</view>
</uni-section>
</view>
</view>
<z-navigation></z-navigation>
<!-- <music-play :playData="playData"></music-play> -->
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
// import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
var clear;
import {
@@ -21,95 +89,312 @@
export default {
data() {
return {
playData: {},
tagId: null,
// status:0, // 0 不显示, 1 加载中2 加载全部完成3 暂无数据
// page:1,
// flag:true, // 函数是否执行完
playData: {},
accordionVal: '',
// extraIcon:{
// color: '#4cd964',
// size: '100',
// }
treeList: [],
tagId: null,
pid: null,
courseInfo: {},
poster:'../../static/videoF.jpg', //封面图
current: {
poster: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/music-a.png',
name: '致爱丽丝',
author: '暂无',
src: 'https://web-ext-storage.dcloud.net.cn/uni-app/ForElise.mp3',
},
audioAction: {
method: 'pause'
},
curId: null,
courseTitle: '',
showTemp:true,
videoContext:null,
videoUrl:'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4'
};
},
//第一次加载
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
// this.tagId = e.id
// this.pageTitle = e.title
// console.log(e, '传入分类id')
this.getData();
},
onReachBottom() {
if(this.status != 2){
this.page ++
this.getData() }
console.log('触底加载',this.page)
this.pid = e.pid
this.tagId = e.id
console.log(e, '------')
this.videoContext = uni.createVideoContext('myVideo')
},
computed: {
...mapState(['userInfo'])
},
...mapState(['userInfo']),
videoHTML() {
return `<video class="video-box" poster="http://ehh-public-01.oss-cn-beijing.aliyuncs.com/wumenyishu-image/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240606110049.jpg" src="${this.videoUrl}" enable-danmu danmu-btn controls style="width:100%;height:320rpx"></video>`
}
},
//页面显示
onShow() {
// 隐藏原生的tabbar
uni.hideTabBar();
this.getData()
},
onUnload() {
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary'); // 清除横屏
// #endif
this.showTemp = true
this.videoContext = null
},
onPullDownRefresh(){
uni.stopPullDownRefresh()
},
components: {
musicPlay
// musicPlay
},
//方法
methods: {
getData() {
if(!this.flag){
console.log('正在执行,未完成')
return
showDrawer(e) {
this.$refs[e].open()
this.videoContext.pause()
this.showTemp = true
console.log(5555)
},
// 关闭窗口
closeDrawer(e) {
this.$refs[e].close()
},
collapseChange(e){
console.log(e,'折叠面板点击');
if(e){
this.tagId = this.treeList[e].id
this.getCourseInfo(this.tagId)
this.closeDrawer('showRight')
}
this.status = 1
this.flag = false
},
changeD(e, type) {
// console.log((type === 'showRight' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
this[type] = e
if(!e){
this.showTemp = false
console.log('关闭弹窗')
this.videoContext.play()
}
},
formatRichText(html) { //控制图片大小
let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
return match;
});
newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
'max-width:100%;');
return match;
});
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
newContent = newContent.replace(/\<img/gi,
'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
return newContent;
},
getData() {
this.$http
.post('medical/home/getCourseMedicalTree')
.then(res => {
if (res.code == 0 && res.labels.length > 0) {
this.treeList = res.labels
this.getCourseInfo(this.treeList[0].id)
this.showDrawer('showRight')
} else {
this.treeList = []
}
}).catch(e => {
console.log(e, '报错')
});
},
// 获取课程详情
getCourseInfo(id) {
$http.request({
url: "medical/home/getMarketCourseList",
url: "medical/home/getCourseMedicalDetail",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
"id": this.tagId,
"limit": 12,
"page": this.page
id: id
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if (res.code == 0) {
if (res.courseList.records.length > 0) {
var list = res.courseList.records
this.courseList = this.courseList.concat(list)
if(res.courseList.pages > this.page){
this.status = 0
}else{
this.status = 2
}
} else if(this.page > 1){
this.status = 2 // 加载完成
if (res.code == 0 && res.course.id) {
this.courseInfo = res.course
this.courseTitle = this.courseInfo.title + '课程说明'
this.curId = id
if(this.courseInfo.mediaType == 1 && this.courseInfo.media != ''){
// this.videoUrl = this.courseInfo.media
// this.poster = this.videoUrl +
// "?x-oss-process=video/snapshot,t_0,f_jpg"
}else{
// this.videoUrl = ''
this.poster = ''
}
this.status = 3 // 暂无数据
}
console.log('status',this.status)
// console.log(id, 'id')
} else {
this.courseInfo = {}
this.videoUrl = ''
this.poster = ''
}
this.flag = true
}).catch(e => {
console.log(e,'数据报错')
this.courseInfo = {}
this.courseTitle = ''
this.curId = null
this.poster = ''
this.videoUrl = ''
console.log(e, '课程详情报错')
});
},
clickCourseInfo(item) {
this.getCourseInfo(item.id)
this.closeDrawer('showRight')
},
playEnd(){
this.showTemp = true
},
clickToPlay(){
this.showTemp = false
this.videoContext.play()
}
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.flexbox{display: flex; }
.imgcontainer {
background-color: $imgBg;
::v-deep .containerBg {
// .uni-collapse-item__title-box {
// background-color: transparent !important;
// }
// .uni-collapse-item__title {
// background-image: linear-gradient(90deg, #258feb 0%, #00e1ec 100%) !important;
// text {
// color: #fff !important;
// font-size: 28rpx !important;
// }
// }
#myVideo {
width: 100% !important;
}
video{width: 100% !important; }
}
.infoBox {
padding: 20rpx;
font-size: 26rpx;
}
// .leve2{background-color: #71a5ff; }
// .leve3{background-color: #9bbeff; }
// .leve4{background-color: #b6d0ff; }
.containerBg {
// background-color: $containerColor;
background-color: #fff;
padding: 0 20rpx;
min-height: calc(100vh - 270rpx);
}
.uni-collapse-item__title-text {
font-size: 30rpx;
}
.videoTemp {
position: relative;
.u-icon {
position: absolute;
z-index: 2;
left: calc(50% - 40rpx);
top: calc(50% - 40rpx);
}
image {
width: 100%;
}
}
.videoTemp:before {
content: '';
display: block;
width: 100%;
position: absolute;
left: 0;
top: 0;
height: 100%;
background-color: rgba(0, 0, 0, .5);
z-index: 1;
}
.proTitle {
text-align: center;
padding: 20rpx 0;
margin-top: 60rpx;
// margin-bottom: 20rpx;
color: #666;
font-size: 26rpx;
}
.sub1List {
background-color: #f7f7f7;
// padding-left: 20rpx;
}
.content {
.item {
background-color: #fff;
line-height: 80rpx;
font-size: 26rpx;
color: #497387;
// border-bottom: 1px solid #dae8f0;
text {
padding-left: 20rpx;
}
.item:last-child{
border-bottom: 0;
}
}
.item.active {
// background-color: #aed1ec;
color: #fff;
background-image: linear-gradient(90deg, #258feb 0%, #00e1ec 100%) !important;
}
.textss{display: inline-block; width: 100%; border-bottom: 1px solid #ebeef5;}
.leve2{
.textss{padding-left: 20rpx;}
}
.leve2{
.textss{padding-left: 40rpx;}
}
.leve3{
.textss{padding-left: 60rpx;}
}
.leve4{
.textss{padding-left: 80rpx;}
}
}
// .textss:last-child{
// border-bottom: 0;
// }
.topRight{margin-right: 20rpx; font-size: 28rpx; display: flex;}
audio {
width: 100% !important;
}
</style>