提交 d9b41e57 authored 作者: lihuihui's avatar lihuihui

课程讨论模块提取

上级 b9174c64
......@@ -37,16 +37,20 @@ export function getChapterVideoAliyun(vid) {
/**
* 获取课程讨论列表
*/
export const getDiscussList = (path, dataJson) => {
export const getDiscussList = (param) => {
const paramPath = param.path || ''
return httpRequest.get(
`/v2/qa/questions${path}`,
dataJson
`/v2/qa/questions${paramPath}`,
param.dataJson
)
}
export const request = (obj) => {
/**
* 获取我的课程讨论列表
*/
export const getCourseDiscussList = (param) => {
const paramPath = param.path || ''
return httpRequest.get(
obj.path,
obj.dataJson
`/v2/qa/questions/course${paramPath}`,
param.dataJson
)
}
......@@ -28,7 +28,7 @@
</template>
<script>
import { request } from '../api/index'
import * as api from '../api/index'
export default {
name: 'Discuss',
......@@ -54,7 +54,7 @@ export default {
methods: {
loadAjax () {
const loading = this.$loading({ lock: true, text: '', spinner: '', background: 'rgba(255, 255, 255, 0.9)' })
request(this.params)
api[this.params.request](this.params)
.then(json => {
this.discussList = json
})
......
<template>
<div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss" scoped>
</style>
......@@ -74,7 +74,7 @@
<div :class='["item-order", (sort[1].isShow ? "on" : "")]' @click='sortFn' :data-index='1' :data-str='sort[1].str'>按投票排序</div>
</div>
<div class='discuss-scroll' bindscrolltolower='loadmore' bindscrolltoupper='updatenew'>
<template v-for='(item, index) in discussList'>
<!-- <template v-for='(item, index) in discussList'>
<div v-bind:key="index" class='item-list' @click='goDiscussDetail' :data-id='item.id' :data-sid='item.sid' :data-index='index'>
<div class='user'>
<template v-if="item.user.url">
......@@ -95,8 +95,8 @@
</template>
<template v-if='!discussList.length'>
<div class='no-data'>暂无相关讨论</div>
</template>
<!-- <discuss :params="params"></discuss> -->
</template> -->
<discuss :params="params"></discuss>
</div>
</template>
<template v-else>
......@@ -232,13 +232,14 @@ export default {
},
data () {
return {
// params: {
// path: `/v2/qa/questions/course/${this.sid}/${this.cid}`,
// page: {
// limit: 10,
// offset: 0
// }
// },
params: {
path: `/${this.sid}/${this.cid}`,
request: 'getCourseDiscussList',
page: {
limit: 10,
offset: 0
}
},
ckeditor: null,
activeName: '1',
activeName1: '1',
......@@ -394,9 +395,9 @@ export default {
this.tabs[3].assess = json1
loading.close()
}).catch(e => { this.$message.error(e.message) }).finally(() => { })
cAction.Discuss.getCourseDiscussList(this.cid, this.sid, this.param).then(json2 => {
this.discussList = json2
}).catch(e => { this.$message.error(e.message) }).finally(() => { })
// cAction.Discuss.getCourseDiscussList(this.cid, this.sid, this.param).then(json2 => {
// this.discussList = json2
// }).catch(e => { this.$message.error(e.message) }).finally(() => { })
}).catch(e => { this.$message.error(e.message); loading.close() }).finally(() => { })
window.addEventListener('resize', this.resizeRoot.bind(this), false)
/* 实时刷新数据 */
......@@ -737,17 +738,17 @@ export default {
message: '问题发布成功'
})
this.isPublicShow = false
// this.params = {
// path: `/v2/qa/questions/course/${this.sid}/${this.cid}`,
// page: {
// limit: 10,
// offset: 0
// },
// v: (new Date()).valueOf()
// }
cAction.Discuss.getCourseDiscussList(this.cid, this.sid, this.param).then(json2 => {
this.discussList = json2
}).catch(e => { this.$message.error(e.message) }).finally(() => { })
this.params = {
path: `/${this.sid}/${this.cid}`,
request: 'getCourseDiscussList',
page: {
limit: 10,
offset: 0
}
}
// cAction.Discuss.getCourseDiscussList(this.cid, this.sid, this.param).then(json2 => {
// this.discussList = json2
// }).catch(e => { this.$message.error(e.message) }).finally(() => { })
}).catch(e => { this.$message.error(e.message) }).finally(() => { loading.close() })
}
} else {
......@@ -774,18 +775,19 @@ export default {
this.param.sort = this.sort[index].isShow ? str : ''
this.param.offset = 0
const loading = this.$loading({ lock: true, text: '', spinner: '', background: 'rgba(255, 255, 255, 0.9)' })
// this.params = {
// path: `/v2/qa/questions/course/${this.sid}/${this.cid}`,
// dataJson: {
// limit: 10,
// offset: 0,
// sort: this.sort[index].isShow ? str : ''
// }
// }
cAction.Discuss.getCourseDiscussList(this.cid, this.sid, this.param).then(json => {
this.discussList = json
}).catch(e => { this.$message.error(e.message) }).finally(() => { loading.close() })
// const loading = this.$loading({ lock: true, text: '', spinner: '', background: 'rgba(255, 255, 255, 0.9)' })
this.params = {
path: `/${this.sid}/${this.cid}`,
request: 'getCourseDiscussList',
dataJson: {
limit: 10,
offset: 0,
sort: this.sort[index].isShow ? str : ''
}
}
// cAction.Discuss.getCourseDiscussList(this.cid, this.sid, this.param).then(json => {
// this.discussList = json
// }).catch(e => { this.$message.error(e.message) }).finally(() => { loading.close() })
}
}
}
......
......@@ -56,11 +56,11 @@ export default {
tabs: [{
title: this.$t('pages.learn.discussion.tap1'),
isShow: true,
path: '/v2/qa/questions/my'
path: '/my'
}, {
title: this.$t('pages.learn.discussion.tap2'),
isShow: false,
path: '/v2/qa/questions/involved'
path: '/involved'
}],
discussList: [
// {
......@@ -82,7 +82,8 @@ export default {
offset: 0 // 偏移量(未考虑传输时,产生新问题情况)
},
params: {
path: '/v2/qa/questions/my',
path: '/my',
request: 'getDiscussList',
dataJson: {
limit: 10,
offset: 0
......@@ -148,9 +149,8 @@ export default {
*/
goDiscussDetail (e) {
const qid = e.currentTarget.dataset.id
const sid = e.currentTarget.dataset.sid
const cid = e.currentTarget.dataset.cid
this.$router.push({ path: `/app/learn/discuss-detail/${sid}/${cid}/${qid}` })
this.$router.push({ path: `/app/learn/discuss-detail/${cid}/${qid}` })
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论