对接接口

This commit is contained in:
nisen
2023-09-02 14:48:59 +08:00
parent b49b83a7cf
commit 5346f360bc
7 changed files with 219 additions and 291 deletions

View File

@@ -18,15 +18,17 @@
<router-link to="/grateful/gratefulNotice" style="font-size: 14px;">查看更多</router-link>
</div>
<ul>
<li v-for="(item, index) in 6" :key="index" style="cursor: pointer;line-height: 22px;" class="liList">
<router-link :to="'/case/detail?id=' + item.id" style="display: flex;align-items: center;">
<li v-for="(item, index) in courseList.noticeList" :key="index"
style="cursor: pointer;line-height: 22px;" class="liList">
<router-link :to="'/grateful/noticeDetail?id=' + item.id"
style="display: flex;align-items: center;">
<span class="portal-right-text blue-one">
<img :src="getPic(index)" alt="">
</span>
<div class="portal-title-desc"
style="flex: 1;font-size: 14px;display: flex;justify-content: space-between;">
<span class="title-line-ellipsis " style="width: 130px;">哈哈哈哈哈哈哈哈哈哈哈哈哈</span>
<span>2023-09-09</span>
<span class="title-line-ellipsis " style="width: 130px;">{{ item.content }}</span>
<span>{{ item.createTime.split(' ')[0] }}</span>
</div>
</router-link>
</li>
@@ -89,11 +91,6 @@
<!--内容列表内容-->
<div v-for="(course, ccidx) in courseList.list" :key="'cc' + ccidx" class="xindex-course"
style="position: relative;margin-right: 0;">
<div style="position: absolute; right: 25px; bottom: 72px">
<interactBar nodeWidth="20px" :courseExclusive="true" :type="1" :data="course" :comments="false"
:praises="false" :shares="false" :views="false">
</interactBar>
</div>
<a @click="toCourseDetail(course)">
<div class="xindex-course-image">
<course-image :course="course"></course-image>
@@ -104,13 +101,12 @@
</div>
<div class="course-author">
<div class="course-author-left">
{{ course.authorInfo.name }}
<span class="study-num">{{ formatNum(course.studys) }}人学习</span>
{{ course.createName }}
<span class="study-num">{{ formatNum(course.studies) }}人学习</span>
</div>
<div style="display: flex">
<div v-if="course.score">
<span class="course-score-value" style="margin-left: 10px">{{ toScore(course.score) }}</span>
<div v-if="course.score != '0'">
<span class="course-score-value" style="margin-left: 10px">{{ toScore(Number(course.score)) }}</span>
</div>
<div v-else class="course-score-no">未评分</div>
</div>
@@ -157,18 +153,13 @@
</template>
<script>
import { mapGetters } from "vuex";
import apiCourseStudy from "@/api/modules/courseStudy.js";
import apiCourse from "@/api/modules/coursePortal.js";
import interactBar from "@/components/Portal/interactBar.vue";
import courseImage from "@/components/Course/courseImage.vue";
import { toScore, formatUserNumber } from "@/utils/tools.js";
import apiIndex from "@/api/phase2/index.js";
import { saveOpinion } from '@/api/modules/grateful.js'
import { saveOpinion, noticeList, courselList } from '@/api/modules/grateful.js'
export default {
name: "Grateful",
components: {
interactBar,
courseImage,
},
data() {
@@ -178,24 +169,20 @@ export default {
},
gratefulVisible: false,
formatNum: formatUserNumber,
isNext: true,
toScore,
// 列表
courseList: {
num: 12,
orderType: 2,
list: [],
}
noticeList: []
},
};
},
mounted() {
this.getCourseData(1);
},
computed: {
...mapGetters(["userInfo", "studyTaskCount"]),
swiper() {
return this.$refs.mySwiper.swiper;
},
this.getNoticeData()
this.getToolData()
},
methods: {
submitNotice() {
@@ -213,85 +200,44 @@ export default {
this.gratefulVisible = false
},
toCourseDetail(item) {
//二期调整,直接改成一个地址
//return this.webBaseUrl + '/course/detail?id=' + item.id;
let $this = this;
if (item.type == 10) {
//return this.webBaseUrl + "/course/studyindex?id=" + item.id;
//console.log("直接进入学习页面");
this.$router.push("/course/studyindex?id=" + item.id);
} else if (item.type == 20) {
apiCourseStudy.hasSignup(item.id).then((rs) => {
if (rs.status == 200) {
//return $this.webBaseUrl + "/course/studyindex?id=" + item.id;
this.$router.push("/course/studyindex?id=" + item.id);
} else {
//return $this.webBaseUrl + "/course/detail?id=" + item.id;
this.$router.push("/course/detail?id=" + item.id);
}
});
//return $this.webBaseUrl + "/course/detail?id=" + item.id;
}
},
getCourseData(pageIndex) {
this.isNext = false;
let { orderType, num } = this.courseList;
let course = {
pageSize: 8,
device: 1,
orderField: orderType == 1 ? "" : "studys",
orderAsc: false,
topOrder: true,
pageIndex: pageIndex,
};
apiIndex.courselist(course).then((res) => {
if (res.status == 200 && res.result.length > 0) {
let courseIds = [];
res.result.forEach((item) => {
item.authorInfo = {
aid: "",
name: "",
orgInfo: "",
avatar: "",
code: "",
sex: null,
};
courseIds.push(item.id);
});
this.loadCouserTeacher(res.result, courseIds);
this.courseList.list = res.result;
courselList({
pageNo: pageIndex,
pageSize: 8
}).then((res) => {
if (res.code == 200 && res.data.records.length > 0) {
console.log(res.result, '之前的');
this.courseList.list = res.data.records;
} else {
console.log("加载课程信息失败:" + res.error);
}
});
},
loadCouserTeacher(list, ids) {
// 先查课程关联教师iD
apiCourse.getTeacherByCourseIDs(ids).then((cres) => {
if (cres.status == 200) {
let userIds = [];
list.forEach((item, index) => {
cres.result.some((courseTeahcer) => {
if (courseTeahcer.courseId == item.id) {
if (courseTeahcer.teacherIds) {
userIds.push(courseTeahcer.teacherIds[0]);
item.authorInfo.aid = courseTeahcer.teacherIds[0];
item.authorInfo.name = courseTeahcer.names[0];
if (item.authorInfo.name == "BOE教师") {
item.authorInfo.name = "";
}
}
return true;
} else {
return false;
}
});
});
//that.loadCourseAuthorInfo(list, userIds);
}
});
}
getNoticeData() {
noticeList({
pageNo: 1,
pageSize: 6,
isTop: '0'
}).then((res) => {
this.courseList.noticeList = res.data.records || []
})
},
getToolData() {
},
},
};
</script>