he2802 3 years ago
parent
commit
f0c4ce45e4
5 changed files with 140 additions and 20 deletions
  1. 3 1
      common/api.js
  2. 7 0
      common/httpList/answer.js
  3. 26 0
      common/httpList/note.js
  4. 12 0
      common/methodTool.js
  5. 92 19
      pages2/class/detail.vue

+ 3 - 1
common/api.js

@@ -16,6 +16,7 @@ import order from './httpList/order.js'
 import informUser from './httpList/informUser.js'
 import study from './httpList/study.js'
 import answer from './httpList/answer.js'
+import note from './httpList/note.js'
 export default {
 	...login,
 	...polyvVideo,
@@ -34,5 +35,6 @@ export default {
 	...order,
 	...informUser,
 	...study,
-	...answer
+	...answer,
+	...note
 }

+ 7 - 0
common/httpList/answer.js

@@ -16,5 +16,12 @@ export default {
 			method: 'post',
 			data: data
 		})
+	},
+	delAnswer(data) {
+		return myRequest({
+			url: '/app/answer/edit',
+			method: 'post',
+			data: data
+		})
 	}
 }

+ 26 - 0
common/httpList/note.js

@@ -0,0 +1,26 @@
+import {
+	myRequest
+} from '../request.js'
+export default {
+	noteList(data) {
+		return myRequest({
+			url: '/user/note/listDate',
+			method: 'get',
+			data: data
+		})
+	},
+	postNote(data) {
+		return myRequest({
+			url: '/user/note',
+			method: 'post',
+			data: data
+		})
+	},
+	delNote(data) {
+		return myRequest({
+			url: '/user/note/edit',
+			method: 'post',
+			data: data
+		})
+	}
+}

+ 12 - 0
common/methodTool.js

@@ -152,5 +152,17 @@ export default {
 			}
 		}
 		return returnAge; //返回周岁年龄
+	},
+	getDate () {
+	  let nowDate = new Date()
+	  let date = {
+	    year: nowDate.getFullYear(),
+	    month: nowDate.getMonth() + 1,
+	    date: nowDate.getDate()
+	  }
+	  return  date.year + '-' + date.month + '-' + date.date
+	},
+	getZeroTime () {
+		return Number(new Date(new Date().toLocaleDateString()).getTime()/1000)
 	}
 }

+ 92 - 19
pages2/class/detail.vue

@@ -68,22 +68,22 @@
 				<view class="inputBottom">
 					<view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
 					<view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;">
-						<u-input height="78" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="value" />
+						<u-input height="78" fixed="true" :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="noteValue" />
 					</view>
-					<view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;">提交</view>
+					<view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postNote">提交</view>
 				</view>
-				<view v-for="(item, index) in menuList">
-					<view class="dateBox">2021年10月30日</view>
-					<view class="noteBox">
+				<view v-for="(item, index) in noteList">
+					<view class="dateBox">{{$method.timestampToTime(item.dateNote)}}</view>
+					<view class="noteBox" v-for="(item1, index1) in item.userNotes">
 						<view class="tBox">
 							<image src="/static/icon/note1.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
 							<view class="title leftPadding">施工承发包模式-施工合同与物资采购合同</view>
 						</view>
-						<view class="tBox2">
+						<view class="tBox2" v-if="false">
 							<view class="title" style="width: 39rpx;height: 39rpx;margin:0 29rpx;">00:20</view>
 							<view class="t2Content leftPadding">这是一段用户记录的笔记本文,当内容过长时 需要换行,完整显示文字内容。</view>
 						</view>
-						<view class="tBox">
+						<view class="tBox" v-if="false">
 							<image src="/static/icon/note2.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image>
 							<view class="title leftPadding">施工承发包模式-施工合同与物资采购合同</view>
 						</view>
@@ -95,22 +95,25 @@
 			<view v-show="current == 3">
 				<view class="inputBottom">
 					<view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;margin-left: 10% ;">
-						<u-input height="78" fixed="true" placeholder="您可以在这里输入答疑内容" type="textarea" :custom-style="inputStyle" v-model="value" />
+						<u-input height="78" fixed="true"   :placeholder="placeholder" type="textarea" :custom-style="inputStyle" v-model="ctxValue" />
 					</view>
 					<view style="color: #007AFF;font-size: 30rpx;font-weight: bold;width: 15%;text-align: center;" @click="postContent">提交</view>
 				</view>
 				<view v-for="(item, index) in answerList" style="background-color: #FFFFFF;">
-					<view class="chat_box">
-						<view style="display: flex;">
+					<view class="chat_box" @click.stop="clearCtx">
+						<view style="display: flex;" >
 							<view><image :src="$method.splitImgHost(item.avatar)" style="width: 64rpx;height: 64rpx;"></image></view>
 							<view style="margin-left: 15rpx;">
 								<view class="chat1">{{item.realname}}</view>
 								<view class="chat2">{{$method.timestampToTime(item.createTime)}}</view>
-								<view class="chat3">{{item.answerText}}</view>
+								<view class="chat3">
+									<text v-if="item.assignUserId>0">回复</text>
+									<text v-if="item.assignUserId>0" style="color: #007AFF;">@{{item.assignRealname}}</text>
+									{{item.answerText}}</view>
 							</view>
 						</view>
-						<view class="btnReply" @click="replyContent(item)" v-if="item.userId!=userInfo.userId">回复</view>
-						<view v-else class="btnDel" @click="delContent(item)">删除</view>
+						<view class="btnReply" @click.stop="replyContent(item)" v-if="item.userId!=userInfo.userId">回复</view>
+						<view v-else class="btnDel" @click.stop="delContent(item)">删除</view>
 					</view>
 					<u-line color="#D6D6DB" />
 				</view>
@@ -211,7 +214,12 @@ export default {
 			chapterId:0,
 			moduleId:0,
 			reMenuList: [],
-			answerList: []
+			answerList: [],
+			assignUserId:0,
+			placeholder:'您可以在这里输入答疑内容',
+			ctxValue:'',
+			noteList:[],
+			noteValue:''
 		};
 	},
 	onUnload() {},
@@ -259,24 +267,88 @@ export default {
 		});
 	},
 	methods: {
+		postNote() {
+			let self = this;
+			if(!(this.playSectionId>0)){
+				this.$u.toast('目前无播放视频');
+				retun
+			}
+			if(!this.noteValue){
+				this.$u.toast('请输入内容');
+				retun
+			}
+			 var polyvPlayerContext = this.selectComponent('#playerVideo');
+			let noteDate = this.$method.getZeroTime()
+			let noteSecond= polyvPlayerContext.getCurrentTime()
+			if(!noteSecond){
+				this.$u.toast('视频暂未开始');
+				retun
+			}
+			let data = { 
+				gradeId:this.gradeId,
+				goodsId:this.goodsId,
+				sectionId:this.playSectionId,
+				courseId: this.courseId,
+				noteText:this.noteValue,
+				noteDate:noteDate,
+				noteSecond:noteSecond}
+				console.log(data,66)
+			this.$api.postNote(data).then(res => {
+				if (res.data.code == 200) {
+					this.$u.toast('发布成功');
+					self.getNoteList()
+					this.noteValue = ''
+				}
+			});
+		},
+		getNoteList() {
+			let self = this;
+			this.$api.noteList({ courseId: this.courseId,gradeId:this.gradeId,goodsId:this.goodsId }).then(res => {
+				if (res.data.code == 200) {
+					self.noteList = res.data.rows;
+				}
+			});
+		},
+		delAnswer(answerId) {
+			let self = this;
+			let data = { answerId: answerId,status:-1 }
+			this.$api.delAnswer(data).then(res => {
+				if (res.data.code == 200) {
+					self.getAnswerList()
+				}
+			});
+		},
+		clearCtx(){
+			console.log(4234)
+			this.placeholder ='您可以在这里输入答疑内容'
+			this.ctxValue = ''
+			this.assignUserId=0
+		},
 		replyContent(item){
-			
+			this.assignUserId = item.userId
+			this.placeholder = '@'+item.realname
 		},
 		delContent(item){
-			
+			this.delAnswer(item.answerId)
 		},
 		postAnswer() {
 			let self = this;
-			this.$api.postAnswer({ courseId: this.courseId,answerText:this.value }).then(res => {
+			let data = { courseId: this.courseId,answerText:this.ctxValue }
+			if(this.assignUserId>0){
+				data.assignUserId = this.assignUserId
+			}
+			this.$api.postAnswer(data).then(res => {
 				if (res.data.code == 200) {
 					this.$u.toast('发布成功');
 					self.getAnswerList()
-					self.value = ''
+					this.placeholder ='您可以在这里输入答疑内容'
+					this.ctxValue = ''
+					this.assignUserId=0
 				}
 			});
 		},
 		postContent(){
-			if(!this.value){
+			if(!this.ctxValue){
 				this.$u.toast('请输入内容');
 			}
 			this.postAnswer()
@@ -479,6 +551,7 @@ export default {
 				self.gradeId = self.goodsData.gradeId
 				self.getMenuList();
 				self.getReMenuList() //获取重修目录
+				self.getNoteList()
 				if(self.goodsData.goodsPlayConfig){
 					self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
 					if(self.goodsPlayConfig.autoPlay>0){