mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/student-h5.git
synced 2025-12-09 02:46:47 +08:00
feat:增加loading
This commit is contained in:
@@ -113,13 +113,13 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, toRefs, watch } from "vue";
|
||||
import { reactive, toRefs, watch, ref } from "vue";
|
||||
// import TitleHead from "@/components/TitleHead.vue";
|
||||
import ReturnHead from "@/components/ReturnHead.vue";
|
||||
import { request, useRequest } from "@/api/request";
|
||||
import { useRoute } from "vue-router/dist/vue-router";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ElMessage, ElLoading } from "element-plus";
|
||||
import {
|
||||
COMMENT_COLLECTION,
|
||||
COMMENT_PRAISE,
|
||||
@@ -156,7 +156,17 @@ const {
|
||||
discussId,
|
||||
noMore,
|
||||
} = toRefs(state);
|
||||
|
||||
const loading = ref(false); // loading
|
||||
const openLoading = () => {
|
||||
loading.value = ElLoading.service({
|
||||
lock: true,
|
||||
text: "Loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
};
|
||||
const closeLoading = () => {
|
||||
loading.value.close();
|
||||
};
|
||||
//获取讨论详情
|
||||
const {
|
||||
query: { id, type },
|
||||
@@ -186,7 +196,7 @@ function getPostList(discussId) {
|
||||
current: state.pageNo,
|
||||
order: 1,
|
||||
});
|
||||
|
||||
openLoading();
|
||||
request(PostList, {
|
||||
pid: discussId,
|
||||
current: state.pageNo,
|
||||
@@ -210,6 +220,7 @@ function getPostList(discussId) {
|
||||
if (e.data.records.length === 0 || e.data.records.length < 10) {
|
||||
state.noMore = true;
|
||||
}
|
||||
closeLoading();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
||||
@@ -96,7 +96,7 @@ import { useRouter } from "vue-router";
|
||||
// import UploadImg from "@/components/img/UploadImg.vue";
|
||||
import FileTypeImg from "@/components/FileTypeImg.vue";
|
||||
import { useRoute } from "vue-router/dist/vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ElMessage, ElLoading } from "element-plus";
|
||||
import ReturnHead from "@/components/ReturnHead.vue";
|
||||
const fileList = ref([]);
|
||||
// const fielPath = ref(import.meta.env.VITE_FILE_PATH);
|
||||
@@ -115,9 +115,22 @@ const {
|
||||
query: { courseId: workId, type, id: taskId, infoId },
|
||||
} = useRoute();
|
||||
// console.log("type", type);
|
||||
const loading = ref(false); // loading
|
||||
const openLoading = () => {
|
||||
loading.value = ElLoading.service({
|
||||
lock: true,
|
||||
text: "Loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
};
|
||||
openLoading();
|
||||
const closeLoading = () => {
|
||||
loading.value.close();
|
||||
};
|
||||
const { data } =
|
||||
taskId && taskId !== "undefined"
|
||||
? useRequest(TASK_WORK_DETAIL, { workId, taskId, type }, (e) => {
|
||||
closeLoading();
|
||||
if (e.code === 6) {
|
||||
console.log("作业判断", e);
|
||||
router.push({
|
||||
@@ -126,6 +139,7 @@ const { data } =
|
||||
}
|
||||
})
|
||||
: useRequest(TASK_WORK_DETAIL, { workId, type }, (e) => {
|
||||
closeLoading();
|
||||
if (e.code === 6) {
|
||||
console.log("作业判断", e);
|
||||
router.push({
|
||||
|
||||
Reference in New Issue
Block a user