评论组件化
This commit is contained in:
@@ -137,84 +137,9 @@
|
||||
</template>
|
||||
</uni-section>
|
||||
<view class="liuyanBox">
|
||||
<view class="box" v-if="sayList.length > 0">
|
||||
<view class="firstLeve flexbox leve" v-for="(item, index) in sayList" :key="index" style="flex-wrap: wrap;">
|
||||
<view class="imgbox" :style="getBackGround(item.user.avatar)">
|
||||
<view class="img">
|
||||
<image :src="item.user.avatar" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="contentBox contentBoxfirstLeve">
|
||||
<view class="name">
|
||||
{{item.user.name == '' ? '暂无昵称': item.user.name}}
|
||||
</view>
|
||||
<view class="content" v-if="item.content != ''">
|
||||
<rich-text class="content" :nodes="formatRichText(item.content)"></rich-text>
|
||||
</view>
|
||||
<view class="imagesList flexbox" v-if="item.images !=''">
|
||||
<view class="item" v-for="(item2, index2) in item.imgList" :key="index2">
|
||||
<image @click="previewImage(item2)" :src="item2" mode="widthFix"
|
||||
style="width: 80rpx; height: 80rpx;"></image>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="others flexbox">
|
||||
<view class="dianzan flexbox" @click="support('one',index,item)">
|
||||
<u-icon v-if="item.support" name="heart-fill" color="#ff5500" size="24"></u-icon>
|
||||
<u-icon v-else name="heart" color="#999" size="24"></u-icon>
|
||||
<text>{{item.supportCount}}</text>
|
||||
</view>
|
||||
<view class="pinglun flexbox" @click="addSay(index,item)">
|
||||
<!-- <u-icon name="chat-fill" color="#999" size="24"></u-icon> -->
|
||||
<u-icon name="chat" color="#999" size="24"></u-icon>
|
||||
<text>{{item.children && item.children.length > 0? item.children.length : 0}}</text>
|
||||
</view>
|
||||
<text>{{item.createTime}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 二级 -->
|
||||
<view class="boxB" v-if="item.Bchildren && item.Bchildren.length > 0" style="width: 100%;">
|
||||
<view class=" flexbox leve" v-for="(citem, cindex) in item.Bchildren" :key="cindex">
|
||||
<view class="imgbox" :style="getBackGround(citem.user.avatar)">
|
||||
<view class="img">
|
||||
<image :src="citem.user.avatar" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="contentBox">
|
||||
<view class="name">
|
||||
{{citem.user.name == '' ? '暂无昵称': citem.user.name}}
|
||||
</view>
|
||||
<view class="content" v-if="citem.content != ''">
|
||||
<rich-text class="content" :nodes="formatRichText(citem.content)"></rich-text>
|
||||
</view>
|
||||
<view class="imagesList flexbox" v-if="citem.images !=''">
|
||||
<view class="item" v-for="(item3, index3) in citem.imgList" :key="index3">
|
||||
<image @click="previewImage(item3)" :src="item3" mode="widthFix"
|
||||
style="width: 80rpx; height: 80rpx;"></image>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="others flexbox">
|
||||
<view class="dianzan flexbox" @click="support(index,cindex,citem)">
|
||||
<u-icon v-if="citem.support" name="heart-fill" color="#ff5500" size="24"></u-icon>
|
||||
<u-icon v-else name="heart" color="#999" size="24"></u-icon>
|
||||
<text>{{citem.supportCount}}</text>
|
||||
</view>
|
||||
<!-- <view class="pinglun flexbox" @click="addSay(cindex,citem)">
|
||||
<u-icon name="chat" color="#999" size="24"></u-icon>
|
||||
<text>{{citem.children && citem.children.length > 0? item.children.length : 0}}</text>
|
||||
</view> -->
|
||||
<text style="margin-left: 20rpx;">{{citem.createTime}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="loadMore" v-show="item.Bchildren.length < item.children.length" @click="showMoreChildren(index,item)">
|
||||
<text>加载更多追评</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- end -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="" v-if="sayList.length > 0">
|
||||
<commentsList :sayList = "sayList" @support="support" @showSayModule="showSayModule"></commentsList>
|
||||
</view>
|
||||
<u-divider v-show="status == 2" text="已加载全部"></u-divider>
|
||||
<u-divider v-show="status == 3" text="暂无留言数据"></u-divider>
|
||||
<u-divider v-show="status == 1" text="加载中..."></u-divider>
|
||||
@@ -332,6 +257,7 @@
|
||||
|
||||
<script>
|
||||
// import musicPlay from '@/components/music.vue'
|
||||
import commentsList from '@/components/commentsList.vue'
|
||||
import emojiList1 from '../../bkhumor-emojiplus/emoji/biaoqin.js'
|
||||
import emotion from '@/bkhumor-emojiplus/components/bkhumor-emojiplus/bkhumor-emojiplus.vue';
|
||||
import $http from '@/config/requestConfig.js';
|
||||
@@ -394,6 +320,7 @@
|
||||
status: 88,
|
||||
loadFlag: false,
|
||||
fatherSay:{},
|
||||
fatherIndex:null,
|
||||
supportFlag:false,
|
||||
};
|
||||
},
|
||||
@@ -437,6 +364,7 @@
|
||||
components: {
|
||||
// musicPlay
|
||||
emotion,
|
||||
commentsList
|
||||
|
||||
},
|
||||
//方法
|
||||
@@ -452,24 +380,18 @@
|
||||
// }
|
||||
},
|
||||
// 评论
|
||||
// 加载更多子评论
|
||||
showMoreChildren(i,val){
|
||||
console.log('更多评论');
|
||||
if(val.children.length <= val.Bchildren.length){
|
||||
uni.showToast({
|
||||
title:'没有更多了哦',
|
||||
icon:'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
let _list = []
|
||||
let _cc = [...val.children]
|
||||
_list = _cc.slice(val.Bchildren.length, val.Bchildren.length + 6)
|
||||
this.sayList[i].Bchildren = this.sayList[i].Bchildren.concat(_list)
|
||||
showSayModule(data){
|
||||
console.log(data,'父级收到值了');
|
||||
this.fatherSay = data.item
|
||||
this.fatherIndex = data.index
|
||||
console.log(this.fatherSay,this.fatherIndex,'父级收到值了');
|
||||
this.sayVisible = true
|
||||
},
|
||||
// 点赞
|
||||
support(index1,index,val){
|
||||
console.log(index1,index,val);
|
||||
support(data){
|
||||
console.log(data,'父级收到值了吗?');
|
||||
let _obj = {...data} // index,index1,val
|
||||
|
||||
if(this.supportFlag){
|
||||
uni.showToast({
|
||||
title:'操作太快了,歇一下吧~',
|
||||
@@ -478,13 +400,13 @@
|
||||
return
|
||||
}
|
||||
this.supportFlag = true
|
||||
if(!val.support){
|
||||
if(!_obj.val.support){
|
||||
$http.request({
|
||||
url: "common/courseGuestbook/addCourseGuestbookSupport",
|
||||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||||
data: {
|
||||
"userId": this.userInfo.id,
|
||||
"guestbookId":val.id ,
|
||||
"guestbookId":_obj.val.id ,
|
||||
},
|
||||
header: { //默认 无 说明:请求头
|
||||
'Content-Type': 'application/json'
|
||||
@@ -496,13 +418,13 @@
|
||||
title:"点赞成功",
|
||||
icon:'success'
|
||||
})
|
||||
if(index1 == 'one'){ // 一级
|
||||
this.sayList[index].support = true
|
||||
this.sayList[index].supportCount++
|
||||
if(_obj.index1 == 'one'){ // 一级
|
||||
this.sayList[_obj.index].support = true
|
||||
this.sayList[_obj.index].supportCount++
|
||||
}
|
||||
if(index1 != undefined && index1 != null && index1 != 'one'){
|
||||
this.sayList[index1].Bchildren[index].support = true
|
||||
this.sayList[index1].Bchildren[index].supportCount++
|
||||
if(_obj.index1 != undefined && _obj.index1 != null && _obj.index1 != 'one'){
|
||||
this.sayList[_obj.index1].Bchildren[_obj.index].support = true
|
||||
this.sayList[_obj.index1].Bchildren[_obj.index].supportCount++
|
||||
}
|
||||
this.supportFlag = false
|
||||
}).catch(e => {
|
||||
@@ -519,7 +441,7 @@
|
||||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||||
data: {
|
||||
"userId": this.userInfo.id,
|
||||
"guestbookId":val.id ,
|
||||
"guestbookId":_obj.val.id ,
|
||||
},
|
||||
header: { //默认 无 说明:请求头
|
||||
'Content-Type': 'application/json'
|
||||
@@ -532,12 +454,12 @@
|
||||
icon:'success'
|
||||
})
|
||||
if(index1 == 'one'){ // 一级
|
||||
this.sayList[index].support = false
|
||||
this.sayList[index].supportCount--
|
||||
this.sayList[_obj.index].support = false
|
||||
this.sayList[_obj.index].supportCount--
|
||||
}
|
||||
if(index1 != undefined && index1 != null && index1 != 'one'){
|
||||
this.sayList[index1].Bchildren[index].support = false
|
||||
this.sayList[index1].Bchildren[index].supportCount--
|
||||
if(_obj.index1 != undefined && _obj.index1 != null && _obj.index1 != 'one'){
|
||||
this.sayList[_obj.index1].Bchildren[_obj.index].support = false
|
||||
this.sayList[_obj.index1].Bchildren[_obj.index].supportCount--
|
||||
}
|
||||
this.supportFlag = false
|
||||
}).catch(e => {
|
||||
@@ -593,7 +515,7 @@
|
||||
forUserId = this.fatherSay.user.id
|
||||
pid = this.fatherSay.id
|
||||
}
|
||||
console.log(this.fatherSay.cIndex,'this.fatherSay.cIndex');
|
||||
console.log(this.fatherIndex,'this.fatherIndex');
|
||||
// return false
|
||||
$http.request({
|
||||
url: "common/courseGuestbook/addCourseGuestbook",
|
||||
@@ -630,15 +552,18 @@
|
||||
_obj.imgList = []
|
||||
}
|
||||
|
||||
console.log(this.sayList[this.fatherSay.cIndex],'this.fatherSay.cIndex------------')
|
||||
if(this.fatherSay.cIndex != undefined && this.fatherSay.cIndex != null ){ // 二级
|
||||
this.sayList[this.fatherSay.cIndex].Bchildren.unshift(_obj)
|
||||
console.log(this.sayList[this.fatherIndex],'this.fatherSay.cIndex------------')
|
||||
if(this.fatherIndex != undefined && this.fatherIndex != null ){ // 二级
|
||||
this.sayList[this.fatherIndex].children.push(_obj)
|
||||
this.sayList[this.fatherIndex].Bchildren.unshift(_obj)
|
||||
|
||||
}else{ // 一级
|
||||
this.sayList.unshift(_obj)
|
||||
console.log(_obj,'_obj返回的一级')
|
||||
}
|
||||
this.sayVisible = false
|
||||
this.fatherSay = {}
|
||||
this.fatherIndex = null
|
||||
// this.getSayList()
|
||||
// 获得的新实例,插入到数组的前面
|
||||
|
||||
@@ -795,7 +720,7 @@
|
||||
// #ifdef APP-PLUS || MP-WEIXIN || H5
|
||||
uni.createSelectorQuery().select('#editor').context((res) => {
|
||||
this.editorCtx = res.context
|
||||
// this.editorCtx.clear()
|
||||
this.editorCtx.clear()
|
||||
this.editorCtx.setContents(res.context)
|
||||
}).exec()
|
||||
// #endif
|
||||
@@ -812,6 +737,7 @@
|
||||
sayclose() {
|
||||
this.sayVisible = false
|
||||
this.fatherSay = {}
|
||||
this.fatherIndex = null
|
||||
},
|
||||
goToLearn(){
|
||||
uni.navigateTo({
|
||||
@@ -1008,26 +934,7 @@
|
||||
url: `${url}?id=${id}`
|
||||
});
|
||||
},
|
||||
getBackGround(src){
|
||||
return `background: url(${src});background-size: contain;`
|
||||
},
|
||||
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:40rpx;height:40rpx;display:inline-block;margin:10rpx auto;"');
|
||||
return newContent;
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1226,17 +1133,6 @@
|
||||
border-radius: 100%; overflow: hidden;
|
||||
}
|
||||
|
||||
// .img {
|
||||
// width: 80rpx;
|
||||
// height: 80rpx;
|
||||
// border-radius: 100%;
|
||||
|
||||
// image {
|
||||
// width: 100%;
|
||||
// height: 80rpx;
|
||||
// }
|
||||
// }
|
||||
|
||||
.contentBox {
|
||||
font-size: 24rpx;
|
||||
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
|
||||
|
||||
</view>
|
||||
<u-tabs :class="['tabList']" @click="" :current="curTagId"
|
||||
:activeStyle="activeStyle" :scrollable="scrollable" :list="tabList"
|
||||
itemStyle="padding-left: 15px; background-color:#fff; padding-right: 15px; height: 50px;"></u-tabs>
|
||||
<view class="imgcontainer">
|
||||
<u-tabs :class="['tabList']" @click="" :current="curTagId"
|
||||
:activeStyle="activeStyle" :scrollable="scrollable" :list="tabList"
|
||||
itemStyle="padding-left: 15px; padding-right: 15px; height: 50px;"></u-tabs>
|
||||
</view>
|
||||
<view class="box">
|
||||
<rich-text v-if="chapter.detail.content" class="content"
|
||||
:nodes="formatRichText(chapter.detail.content)"></rich-text>
|
||||
@@ -82,7 +84,7 @@
|
||||
color: '#258feb',
|
||||
},
|
||||
tabList:[
|
||||
{id:1, name:"章节介绍"},{id:2, name:"评论"},
|
||||
{id:1, name:"章节介绍"},{id:3, name:"本节作业"},{id:2, name:"评论"}
|
||||
],
|
||||
scrollTop: 0,
|
||||
courseId: null,
|
||||
@@ -168,7 +170,9 @@
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import '@/style/mixin.scss';
|
||||
|
||||
.imgcontainer {
|
||||
background-color: $imgBg;
|
||||
}
|
||||
.scroll-view_H {
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
<z-nav-bar :title="pageTitle ? pageTitle : '课程详情'"></z-nav-bar>
|
||||
<view class="containerBg1">
|
||||
<!-- <view class="vipSee"> -->
|
||||
<view class="vipSee" v-if="userInfo.vip != 0">
|
||||
<text>VIP畅学权益生效中</text>
|
||||
</view>
|
||||
<view :class="[userInfo.vip == 0 ? 'vipBox' : '']" style="padding:0 10px;">
|
||||
|
||||
<view class="courseTitle flexbox" v-if="course.id">
|
||||
<view class="vipSee" v-if="userInfo.vip == 0">
|
||||
<text>VIP畅学权益生效中</text>
|
||||
</view>
|
||||
<view class="curseImg flexbox imgcontainer" style="align-items: center;">
|
||||
<image v-if="!course.image" src="/static/nobg.jpg" mode="widthFix"></image>
|
||||
<image v-else :src="course.image" mode="widthFix"></image>
|
||||
@@ -21,8 +23,9 @@
|
||||
<!-- <uni-tag type="primary" text=""></uni-tag> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coursePart flexbox" v-if="librayList.length > 1">
|
||||
</view>
|
||||
</view>
|
||||
<view :class="['coursePart','flexbox',fixed ? 'fixed' : '']" v-if="librayList.length > 1">
|
||||
<view :class="['item','flexbox',curId == item.id? 'active': '' ]" v-for="(item, index) in librayList"
|
||||
:key="index" @click="clicklib(item,index)">
|
||||
<u-icon v-if="item.isBuy == 0 && curId == item.id" name="lock" color="#258feb" size="28"></u-icon>
|
||||
@@ -162,6 +165,7 @@
|
||||
loadFlag: false,
|
||||
fatherSay:{},
|
||||
supportFlag:false,
|
||||
fixed: false,
|
||||
};
|
||||
},
|
||||
//第一次加载
|
||||
@@ -179,7 +183,8 @@
|
||||
},
|
||||
onPageScroll(e) {
|
||||
this.scrollTop = e.scrollTop;
|
||||
if (this.scrollTop > 500) {
|
||||
if (this.scrollTop > 100) {
|
||||
// console.log('高度符合');
|
||||
this.fixed = true
|
||||
} else {
|
||||
this.fixed = false
|
||||
@@ -656,59 +661,13 @@
|
||||
},
|
||||
choosePrice(item) {
|
||||
console.log(item, 'choosePrice')
|
||||
this.curProId = item.productId
|
||||
// uni.showModal({
|
||||
// title: '提示',
|
||||
// cancelText: '再想想',
|
||||
// content: `您正在购买 ${item.productName},价格是${item.price}元,是否继续?`,
|
||||
// success: function(res) {
|
||||
// if (res.confirm) {
|
||||
// console.log('用户点击确定');
|
||||
// } else if (res.cancel) {
|
||||
// console.log('用户点击取消');
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
this.curProId = item.productId
|
||||
},
|
||||
chooseChapter(item, index) {
|
||||
// 检查课程是否已经购买了 是否为试听
|
||||
if (item.isAudition == 1) {
|
||||
// 未购买仅试听
|
||||
// this.getPath(item, index)
|
||||
chooseChapter(item, index) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/course/learn?courseId=${this.course.id}&catalogueId
|
||||
=${this.curId}&chapterId=${item.id}`
|
||||
})
|
||||
} else if (this.librayList[this.curIndex].isBuy == 1) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
cancelText: '再看看',
|
||||
confirmText: '去学习',
|
||||
content: `当前操作即将跳转至学习页面,是否继续?`,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
cancelText: '知道了',
|
||||
confirmText: '立即购买',
|
||||
content: `本章节不支持试听,购买课程后即可观看`,
|
||||
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getPath(item, index) {
|
||||
$http.request({
|
||||
@@ -803,6 +762,7 @@
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import '@/style/mixin.scss';
|
||||
|
||||
.endBox{
|
||||
// @include theme("vipbtnbg");
|
||||
background-color: #d3f9e8;
|
||||
@@ -985,8 +945,25 @@
|
||||
width: calc(100% - 70rpx);
|
||||
}
|
||||
}
|
||||
|
||||
.vipSee{ @include theme("btn_bg"); color: #fff; padding: 20rpx;}
|
||||
.fixed {
|
||||
position: fixed; top: 70rpx;
|
||||
z-index: 1; width: 100%; background-color: #fff;
|
||||
}
|
||||
.vipBox{
|
||||
|
||||
.courseTitle{position: relative;overflow: hidden;
|
||||
border: 2px solid #b39aff;
|
||||
// background-image: linear-gradient(90deg, #ccc3fa 0%, #9fc3fb 100%);
|
||||
}
|
||||
}
|
||||
.vipSee{
|
||||
position: absolute; right:0; bottom:0;
|
||||
font-size: 24rpx;
|
||||
background-image: linear-gradient(90deg, #6429db 0%, #0075ed 100%);
|
||||
// @include theme("btn_bg");
|
||||
color: #fff; padding: 10rpx; border-radius: 50rpx 0 0 50rpx;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.leve {
|
||||
@@ -1000,16 +977,16 @@
|
||||
border-radius: 100%; overflow: hidden;
|
||||
}
|
||||
|
||||
// .img {
|
||||
// width: 80rpx;
|
||||
// height: 80rpx;
|
||||
// border-radius: 100%;
|
||||
.img {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 100%;
|
||||
|
||||
// image {
|
||||
// width: 100%;
|
||||
// height: 80rpx;
|
||||
// }
|
||||
// }
|
||||
image {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.contentBox {
|
||||
font-size: 24rpx;
|
||||
@@ -1359,6 +1336,7 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
.btnContainer {
|
||||
border-top: 1px solid #cac6e1;
|
||||
margin-top: 20rpx;
|
||||
@@ -1407,13 +1385,15 @@
|
||||
}
|
||||
|
||||
.courseTitle {
|
||||
// justify-content: space-between;
|
||||
// overflow: hidden;
|
||||
// background-image: url(@/static/bg1.jpg);
|
||||
// background-size: cover;
|
||||
// background-repeat: no-repeat;
|
||||
// background-image: linear-gradient(180deg, #cfe0ff 0%, #fff 50%);
|
||||
padding: 0 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
@include ptop_bottm(10px);
|
||||
@include pleft_right(10px);
|
||||
// color: #fff;
|
||||
border: 2px solid #a3bbe0;
|
||||
@include mshadow(10px, 1)
|
||||
|
||||
.title {
|
||||
// display: block;
|
||||
font-size: 30rpx;
|
||||
|
||||
Reference in New Issue
Block a user