feat:增加面授课评论等

This commit is contained in:
lixg
2023-03-04 21:22:04 +08:00
parent c109388bb0
commit ece975dfbb
10 changed files with 195 additions and 36 deletions

40
src/api/method.js Normal file
View File

@@ -0,0 +1,40 @@
/*
* @Author: lixg lixg@dongwu-inc.com
* @Date: 2022-12-19 11:35:37
* @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2023-03-04 17:42:01
* @FilePath: /fe-stu/src/views/project/method.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// 修改时间格式---------start-----------------------------
function formatNumber(n) {
n = n.toString();
return n[1] ? n : "0" + n;
}
function toDate(number, format) {
var formateArr = ["Y", "M", "D", "h", "m", "s"];
var returnArr = [];
if (number === 0) {
return 0;
} else {
var date = new Date(number * 1000);
}
returnArr.push(date.getFullYear());
returnArr.push(formatNumber(date.getMonth() + 1));
returnArr.push(formatNumber(date.getDate()));
returnArr.push(formatNumber(date.getHours()));
returnArr.push(formatNumber(date.getMinutes()));
returnArr.push(formatNumber(date.getSeconds()));
for (var i in returnArr) {
format = format.replace(formateArr[i], returnArr[i]);
}
return format;
}
// 修改时间格式---------end-----------------------------
export {
toDate
}

View File

@@ -1,6 +1,14 @@
import {watch, ref} from "vue";
import {boeRequest} from "@/api/request";
import {GET_USER_LIST} from "@/api/ThirdApi";
/*
* @Author: lixg lixg@dongwu-inc.com
* @Date: 2023-01-17 19:47:07
* @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2023-03-04 13:22:53
* @FilePath: /stu_h5/src/api/utils.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { watch, ref } from "vue";
import { boeRequest } from "@/api/request";
import { GET_USER_LIST } from "@/api/ThirdApi";
export function useImage(src) {
return new URL(`../assets/image/${src}`, import.meta.url).href
@@ -19,9 +27,9 @@ export function getCookie(name) {
export function useUserInfo(id) {
const userInfo = ref({})
watch(id, () => {
id.value && boeRequest(GET_USER_LIST, {id: id.value}).then(res => {
id.value && boeRequest(GET_USER_LIST, { id: id.value }).then(res => {
userInfo.value = res.result.userInfoList[0]
userInfo.value.avatar = userInfo.value.avatar?userInfo.value.avatar:'/800e23f7-b58c-4192-820d-0c6a2b7544cc.png'
userInfo.value.avatar = userInfo.value.avatar ? userInfo.value.avatar.includes(import.meta.env.VITE_FILE_PATH) ? userInfo.value.avatar : (import.meta.env.VITE_FILE_PATH + userInfo.value.avatar) : '/800e23f7-b58c-4192-820d-0c6a2b7544cc.png'
})
})
return userInfo

View File

@@ -86,8 +86,10 @@
</div>
</div>
<div class="btns">
<div class="btns1" @click="reply1Blur">取消</div>
<div class="btns2" @click="send">发布</div>
<button class="btns1" @click="reply1Blur">取消</button>
<button class="btns2" @click="send" v-loading="submitLoading">
发布
</button>
</div>
</div>
</div>
@@ -247,7 +249,7 @@
</div>
</template>
<script setup>
import { reactive, ref, computed, defineProps } from "vue";
import { reactive, ref, computed, defineProps, watch } from "vue";
import ReturnHead from "@/components/ReturnHead.vue";
import px from "@/assets/image/discuss/px.jpg";
import { request, useRequest } from "@/api/request";
@@ -261,6 +263,7 @@ import {
import { useRoute, useRouter } from "vue-router/dist/vue-router";
import UploadPostImg from "@/components/img/UploadPostImg.vue";
import { ElMessage } from "element-plus";
import { toDate } from "@/api/method";
import store from "@/store";
const props = defineProps({
type: {
@@ -286,12 +289,13 @@ const hfPage = ref({
const noMorePost = ref(false);
// 获取数据
console.log("props.faceId", props.faceId);
const getData = () => {
// 获取帖子下的评论
request(COMMENT_LIST, {
id: props.faceId,
type: 3,
pageNo: hfPage.value.currentPage,
type: 2,
current: hfPage.value.currentPage,
pageSize: 10,
})
.then((res) => {
@@ -299,15 +303,27 @@ const getData = () => {
commontList.value = commontList.value.concat(res.data.records);
hfPage.value.total = Number(res.data.total);
clearText();
submitLoading.value = false;
if (res.data.records.length === 0 || res.data.records.length < 10) {
noMorePost.value = true;
}
})
.catch((err) => {
console.log(err);
submitLoading.value = false;
});
};
getData();
// watch(
// props.faceId,
// () => {
// console.log("props.faceId", props.faceId);
// getData();
// },
// {
// deep: true,
// }
// );
// 查看更多-展开回复列表
function lookMore(i) {
@@ -397,6 +413,7 @@ function reply1Blur() {
// }
// 提交评论
const submitLoading = ref(false);
function submitComment() {
console.log(disDetail.value, fileListComment.value);
let imgFileUrl = [];
@@ -407,15 +424,21 @@ function submitComment() {
id: disDetail.value.id,
targetId: disDetail.value.id,
content: disComment.value.content,
type: 1,
type: 2,
img: imgFileUrl.length !== 0 ? imgFileUrl.toString() : "",
});
if (!disComment.value.content && imgFileUrl.length === 0)
return ElMessage.success("请输入评论内容");
if (submitLoading.value) {
ElMessage.error(`请勿频繁点击`);
return;
}
submitLoading.value = true;
request(COMMENT_ADD, {
targetId: disDetail.value.id,
id: props.faceId,
targetId: props.faceId,
content: disComment.value.content,
type: 1,
type: 2,
img: imgFileUrl.length !== 0 ? imgFileUrl.toString() : "",
})
.then((res) => {
@@ -424,6 +447,7 @@ function submitComment() {
hfPage.value.pageNo = 1;
hfPage.value.currentPage = 1;
commontList.value = [];
submitLoading.value = false;
getData();
})
.catch((err) => {
@@ -442,16 +466,21 @@ function submitReplayComment() {
id: disDetail.value.id,
targetId: disDetail.value.id,
content: replayComment.value.content,
type: 1,
type: 2,
pid: replayComment.value.pid,
img: imgFileUrl.length !== 0 ? imgFileUrl.toString() : "",
});
if (!replayComment.value.content && imgFileUrl.length === 0)
return ElMessage.success("请输入回复内容");
if (submitLoading.value) {
ElMessage.error(`请勿频繁点击`);
return;
}
submitLoading.value = true;
request(COMMENT_ADD, {
targetId: disDetail.value.id,
content: replayComment.value.content,
type: 1,
type: 2,
pid: replayComment.value.pid,
img: imgFileUrl.length !== 0 ? imgFileUrl.toString() : "",
})
@@ -461,14 +490,22 @@ function submitReplayComment() {
ElMessage.success("回复成功");
for (let i = 0; i < commontList.value.length; i++) {
if (commontList.value[i].id === replayComment.value.pid) {
//获取当前时间
let nowTime = toDate(new Date().getTime() / 1000, "Y-M-D h:m:s");
let obj = {
id: res.data,
studentAvatar: userInfo.value.avatar,
studentName: userInfo.value.realName,
content: replayComment.value.content,
praised: false,
praiseNum: 0,
createTime: nowTime,
};
commontList.value[i].children.push(obj);
commontList.value[i].children.unshift(obj);
}
}
reply1Show.value = false;
submitLoading.value = false;
clearText();
})
.catch((err) => {

View File

@@ -19,7 +19,7 @@
}"
>
<div
@click="toDetail(i)"
@click="toDetail(item, i)"
:class="
imgAttrindex === 1
? current === i
@@ -108,6 +108,10 @@ const props = defineProps({
type: Number,
default: null,
},
routerInfo: {
type: Object,
default: null,
},
});
const router = useRouter();
const visiable = ref(true);
@@ -239,7 +243,7 @@ const { data } = useRequest(
}
}
);
console.log("data", data);
console.log("data", data, props.routerInfo);
let current = ref(null);
watch(data, () => {
if (data && data.value && data.value.list) {
@@ -247,9 +251,14 @@ watch(data, () => {
current.value = data.value.list.findIndex(
(e) => e.id === data.value.currentChapterId
);
console.log("props.routerInfo", props.routerInfo);
}
closeLoading();
});
// watch(props.routerInfo, () => {
// console.log("props.routerInfo", props.routerInfo);
// });
// const current = computed(() => {
// data.value.list.findIndex((e) => e.id === data.value.currentChapterId);
// });
@@ -259,16 +268,54 @@ function show() {
visiable.value = true;
}
function toDetail(i) {
function toDetail(item, i) {
// console.log("import.meta.env.MODE", import.meta.env.MODE);
console.log("current.value !== i", current, i);
if (current.value !== i) {
return;
console.log("current.value !== i", current, i, item);
// 预览和学习设置
let previewSetting = props.routerInfo.previewSetting;
let studySetting = props.routerInfo.studySetting;
let isStudy = false;
if (previewSetting == null) {
// 如果未设置预览 则只可以看当前关卡 其余关卡不让点击
if (current.value !== i) {
ElMessage.warning("当前关卡不可预览");
return;
}
isStudy = true;
} else {
if (current.value !== i) {
let lookArr = [];
lookArr = previewSetting.split(",");
if (i + 1 >= lookArr[0] && i + 1 <= lookArr[1]) {
if (studySetting !== null) {
let studyArr = [];
studyArr = studySetting.split(",");
if (i + 1 >= studyArr[0] && i + 1 <= studyArr[1]) {
isStudy = true;
} else {
isStudy = false;
}
} else {
isStudy = false;
}
} else {
ElMessage.warning("当前关卡不可预览");
return;
}
} else {
isStudy = true;
}
}
// if (current.value !== i) {
// return;
// }
router.push({
path: "/pathmappage",
query: {
routerId: props.routerId,
chapterId: item.id,
isStudy,
// routerName: props.detail.routerName,
},
});

View File

@@ -2,7 +2,7 @@
* @Author: lixg lixg@dongwu-inc.com
* @Date: 2023-01-17 19:47:07
* @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2023-03-03 10:30:46
* @LastEditTime: 2023-03-04 19:01:36
* @FilePath: /stu_h5/src/store/index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@@ -87,8 +87,8 @@ export default createStore({
content.commit('INIT_PROJECT_INFO')
})
},
getRouterInfo(content, { routerId }) {
request(ROUTER_PROCESS, { routerId }).then(res => {
getRouterInfo(content, { routerId, chapterId }) {
request(ROUTER_PROCESS, { routerId, chapterId }).then(res => {
content.commit('SET_ROUTER_INFO', res.data)
content.commit('INIT_ROUTER_INFO')
})

View File

@@ -124,8 +124,10 @@
</div>
</div>
<div class="btns">
<div class="btns1" @click="reply1Blur">取消</div>
<div class="btns2" @click="send">发布</div>
<button class="btns1" @click="reply1Blur">取消</button>
<button class="btns2" @click="send" v-loading="submitLoading">
发布
</button>
</div>
</div>
</div>
@@ -326,6 +328,7 @@ import {
import { useRoute, useRouter } from "vue-router/dist/vue-router";
import UploadPostImg from "@/components/img/UploadPostImg.vue";
import { ElMessage } from "element-plus";
import { toDate } from "@/api/method";
import store from "@/store";
const userInfo = computed(() => store.state.userInfo);
const {
@@ -385,7 +388,7 @@ const getData = () => {
request(COMMENT_LIST, {
id: e.data.id,
type: 1,
pageNo: hfPage.value.currentPage,
current: hfPage.value.currentPage,
pageSize: 10,
})
.then((res) => {
@@ -393,12 +396,14 @@ const getData = () => {
commontList.value = commontList.value.concat(res.data.records);
hfPage.value.total = Number(res.data.total);
clearText();
submitLoading.value = false;
if (res.data.records.length === 0 || res.data.records.length < 10) {
noMorePost.value = true;
}
})
.catch((err) => {
console.log(err);
submitLoading.value = false;
});
});
};
@@ -511,6 +516,7 @@ function reply1Blur() {
// }
// 提交评论
const submitLoading = ref(false);
function submitComment() {
console.log(disDetail.value, fileListComment.value);
let imgFileUrl = [];
@@ -526,6 +532,11 @@ function submitComment() {
});
if (!disComment.value.content && imgFileUrl.length === 0)
return ElMessage.success("请输入评论内容");
if (submitLoading.value) {
ElMessage.error(`请勿频繁点击`);
return;
}
submitLoading.value = true;
request(COMMENT_ADD, {
targetId: disDetail.value.id,
content: disComment.value.content,
@@ -538,6 +549,7 @@ function submitComment() {
hfPage.value.pageNo = 1;
hfPage.value.currentPage = 1;
commontList.value = [];
submitLoading.value = false;
getData();
})
.catch((err) => {
@@ -562,6 +574,11 @@ function submitReplayComment() {
});
if (!replayComment.value.content && imgFileUrl.length === 0)
return ElMessage.success("请输入回复内容");
if (submitLoading.value) {
ElMessage.error(`请勿频繁点击`);
return;
}
submitLoading.value = true;
request(COMMENT_ADD, {
targetId: disDetail.value.id,
content: replayComment.value.content,
@@ -575,6 +592,8 @@ function submitReplayComment() {
ElMessage.success("回复成功");
for (let i = 0; i < commontList.value.length; i++) {
if (commontList.value[i].id === replayComment.value.pid) {
//获取当前时间
let nowTime = toDate(new Date().getTime() / 1000, "Y-M-D h:m:s");
let obj = {
id: res.data,
studentAvatar: userInfo.value.avatar,
@@ -582,10 +601,13 @@ function submitReplayComment() {
content: replayComment.value.content,
praised: false,
praiseNum: 0,
createTime: nowTime,
};
commontList.value[i].children.push(obj);
commontList.value[i].children.unshift(obj);
}
}
reply1Show.value = false;
submitLoading.value = false;
clearText();
})
.catch((err) => {

View File

@@ -549,7 +549,7 @@ function toSurvery() {
infoId: data.value.planDto.id,
chapterOrStageId: 0,
sName: data.value.planDto.name,
type,
type: 3,
},
});
}
@@ -570,7 +570,7 @@ function toWork() {
id: taskId,
infoId: data.value.planDto.id,
chapterOrStageId: 0,
type,
type: 3,
pName: "面授课",
sName: data.value.planDto.name,
},
@@ -592,7 +592,7 @@ function toExamItem(obj) {
path: "/externalexam",
query: {
courseId: obj.id,
type,
type: 3,
},
});
} else {

View File

@@ -95,7 +95,9 @@
</div>
</div>
</el-tab-pane>
<!-- <el-tab-pane label="课程评论" name="fourth"> </el-tab-pane> -->
<el-tab-pane label="课程评论" name="fourth">
<CommentReply :faceId="courseId" :type="3" />
</el-tab-pane>
<el-tab-pane label="材料下载" name="third">
<div
v-if="!data.offcourseDto?.attach"
@@ -170,6 +172,7 @@ import { STU_OFFCOURSE_DETAIL, FACETEACH_SIGNUP } from "@/api/api";
import { useRoute, useRouter } from "vue-router";
import { useUserInfo } from "@/api/utils";
import { ElMessage, messageConfig } from "element-plus";
import CommentReply from "@/components/CommentReply.vue";
import dayjs from "dayjs";
const router = useRouter();
const returnclick = () => {

View File

@@ -2,7 +2,7 @@
* @Author: lixg lixg@dongwu-inc.com
* @Date: 2023-01-19 14:59:34
* @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2023-03-02 01:59:54
* @LastEditTime: 2023-03-04 20:57:49
* @FilePath: /stu_h5/src/views/pathmap/LevelList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -29,6 +29,7 @@
<PathDetailImage
:img="data?.picUrl"
:routerId="routerId"
:routerInfo="data"
></PathDetailImage>
</div>
</div>

View File

@@ -138,6 +138,7 @@
</div>
</div>
<div
v-if="isStudy == 'true'"
class="goclass"
:style="{
background:
@@ -182,7 +183,7 @@ import { ROUTER, TASK_TYPES } from "@/api/CONST";
import ReturnHead from "@/components/ReturnHead.vue";
import { useStore } from "vuex";
const {
query: { routerId, routerName },
query: { routerId, routerName, chapterId, isStudy },
} = useRoute();
const router = useRouter();
const returnclick = () => {
@@ -191,7 +192,7 @@ const returnclick = () => {
const { commit, dispatch, state } = useStore();
const data = computed(() => state.routerInfo);
onMounted(() => {
dispatch("getRouterInfo", { routerId });
dispatch("getRouterInfo", { routerId, chapterId });
});
const userInfo = computed(() => store.state.userInfo);