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

课程讨论模块提取

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