提交 a46280ad authored 作者: pengxiaohui's avatar pengxiaohui

feat: 增加签到功能

上级 88878544
...@@ -326,6 +326,8 @@ export default class PlayerAction extends BaseACTION { ...@@ -326,6 +326,8 @@ export default class PlayerAction extends BaseACTION {
updateCourseHomework (sid, cid, obj) { return Player.updateCourseHomework(sid, cid, obj).then(res => res) } updateCourseHomework (sid, cid, obj) { return Player.updateCourseHomework(sid, cid, obj).then(res => res) }
/* 提交课程考核 */ /* 提交课程考核 */
updateSurveyAnswer (obj) { return Player.updateSurveyAnswer(obj).then(res => res) } updateSurveyAnswer (obj) { return Player.updateSurveyAnswer(obj).then(res => res) }
/* 签到 */
signIn (id) { return Player.signIn(id).then(res => res) }
/* 获取当前最新直播提醒 */ /* 获取当前最新直播提醒 */
getNewLiveMsg () { return Player.getNewLiveMsg().then(res => res) } getNewLiveMsg () { return Player.getNewLiveMsg().then(res => res) }
/* 获取手机直播列表 */ /* 获取手机直播列表 */
......
...@@ -112,6 +112,11 @@ export default class PlayerAPI extends BaseAPI { ...@@ -112,6 +112,11 @@ export default class PlayerAPI extends BaseAPI {
updateSurveyAnswer = obj => updateSurveyAnswer = obj =>
this.post('/api/lms-ep/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } }) this.post('/api/lms-ep/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } })
/**
* 签到
*/
signIn = (id = '') => this.post(`/api/lms-ep/v2/education/lives/sign/${id}`, {})
/** /**
* 手机端 获取实时最新直播接口 * 手机端 获取实时最新直播接口
*/ */
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<div class="live-msg"> <div class="live-msg">
<div class="txt">直播提醒:</div> <div class="txt">直播提醒:</div>
<div class="txt">您的直播课程 《{{ newLiveMsg.course_name }}》 将于 {{ newLiveMsg.live.start_time }} 开始</div> <div class="txt">您的直播课程 《{{ newLiveMsg.course_name }}》 将于 {{ newLiveMsg.live.start_time }} 开始</div>
<el-button class="in-btn" type="primary" size="small" round @click="goLive">进入直播</el-button> <el-button v-if="[-1, 0].includes(newLiveMsg.live.sign_status)" class="in-btn" type="primary" size="small" round @click="handleSignIn(newLiveMsg.live.sign_status)">签到</el-button>
<el-button v-else class="in-btn" type="primary" size="small" round @click="goLive">进入直播</el-button>
</div> </div>
</template> </template>
<!-- <div class="con-title">{{ $t('pages.learn.course.title') }}</div> --> <!-- <div class="con-title">{{ $t('pages.learn.course.title') }}</div> -->
...@@ -161,6 +162,13 @@ export default { ...@@ -161,6 +162,13 @@ export default {
} }
}, },
methods: { methods: {
handleSignIn(status) {
if (status === -1) {
this.$message.error('直播未开始,请提前10分钟进入签到')
} else if (status === 0) {
this.fetchSignIn()
}
},
// 是否可以打开课程详情 // 是否可以打开课程详情
canOpenCourse(courseId) { canOpenCourse(courseId) {
if (this.userInfo.is_open_course) { if (this.userInfo.is_open_course) {
...@@ -278,6 +286,24 @@ export default { ...@@ -278,6 +286,24 @@ export default {
.catch(e => { .catch(e => {
this.$message.error(e.message) this.$message.error(e.message)
}) })
},
fetchSignIn() {
const id = this.newLiveMsg.live.id || ''
cAction.Player.signIn(id)
.then(res => {
const { code, status } = res
if (code === 0) {
if (status === 1) {
this.$message.success('签到成功')
} else if (status === 2) {
this.$message.success('课程已开始,您已迟到,请于课后补看错过视频')
}
this.getLatestLive()
}
})
.catch(e => {
this.$message.error(e.message || '签到失败')
})
} }
} }
} }
......
...@@ -88,7 +88,14 @@ ...@@ -88,7 +88,14 @@
> >
{{ item1.name }} {{ item1.name }}
<template v-if="[5, 8].includes(item1.type)"> <template v-if="[5, 8].includes(item1.type)">
<div class="time">{{ item1.live.start_time }} {{ item1.live.statusStr }}</div> <div class="time" v-if="item1.type === 5">
<template>
{{ item1.live.start_time }} {{ item1.live.statusStr }}
<el-button v-if="[-1, 0].includes(item1.live.sign_status)" class="in-btn" type="primary" size="mini" round @click="handleSignIn(item1.live.sign_status)">签到</el-button>
<el-tag v-if="[3, 5].includes(item1.live.live_status) && [2, 3].includes(item1.live.sign_status)" type="danger" size="small">{{item1.live.sign_status === 2 ? '迟到' : '漏签'}}</el-tag>
</template>
</div>
<div class="time" v-else>{{ item1.live.start_time }} {{ item1.live.statusStr }}</div>
</template> </template>
<template v-else> <template v-else>
<div class="time">{{ item1.time }}</div> <div class="time">{{ item1.time }}</div>
...@@ -599,6 +606,13 @@ export default { ...@@ -599,6 +606,13 @@ export default {
this.resizeRoot() this.resizeRoot()
}, },
methods: { methods: {
handleSignIn(item) {
if (item.sign_status === -1) {
this.$message.error('直播未开始,请提前10分钟进入签到')
} else {
this.fetchSignIn(item.id)
}
},
handleClick(tab, event) { handleClick(tab, event) {
/* console.log(tab, event) */ /* console.log(tab, event) */
}, },
...@@ -940,6 +954,23 @@ export default { ...@@ -940,6 +954,23 @@ export default {
const r = window.location.search.substr(1).match(reg) const r = window.location.search.substr(1).match(reg)
if (r != null) return unescape(r[2]) if (r != null) return unescape(r[2])
return null return null
},
fetchSignIn(id) {
cAction.Player.signIn(id)
.then(res => {
const { code, status } = res
if (code === 0) {
if (status === 1) {
this.$message.success('签到成功')
} else if (status === 2) {
this.$message.success('课程已开始,您已迟到,请于课后补看错过视频')
}
this.updatePages()
}
})
.catch(e => {
this.$message.error(e.message || '签到失败')
})
} }
} }
} }
......
...@@ -8,14 +8,17 @@ ...@@ -8,14 +8,17 @@
<div class="logout" @click="logout">{{ $t('components.learnSysLayout.sideBar.outLogin') }}</div> <div class="logout" @click="logout">{{ $t('components.learnSysLayout.sideBar.outLogin') }}</div>
</div> </div>
</div> </div>
<div class="hint" v-if="latest" @click="onClick(latest.live, latest.course_id)"> <div class="hint" v-if="latest">
<div class="left"> <div class="left">
<div class="left-1">{{ $t('live.liveReminder') }}</div> <div class="left-1">{{ $t('live.liveReminder') }}</div>
<div class="left-2"> <div class="left-2">
{{ latest.course_name }}{{ $t('live.startTime', { time: latest.live.start_time }) }} {{ latest.course_name }}{{ $t('live.startTime', { time: latest.live.start_time }) }}
</div> </div>
</div> </div>
<div class="right">{{ $t('live.goLive') }}</div> <div v-if="[-1, 0].includes(latest.live.sign_status)" class="right" @click="onClick(latest.live, latest.course_id)">
<el-tag size="small" @click.stop="handleSignIn(latest.live)"> </el-tag>
</div>
<div v-else class="right" @click="onClick(latest.live, latest.course_id)">{{ $t('live.goLive') }}</div>
</div> </div>
<div class="tips">{{ $t('live.replayTips') }}</div> <div class="tips">{{ $t('live.replayTips') }}</div>
<div class="live-list"> <div class="live-list">
...@@ -27,7 +30,11 @@ ...@@ -27,7 +30,11 @@
<div class="live-item-content"> <div class="live-item-content">
<div class="live-item-content__title">{{ subitem.topic }}</div> <div class="live-item-content__title">{{ subitem.topic }}</div>
<div class="live-item-content__time">{{ subitem.start_time }}</div> <div class="live-item-content__time">{{ subitem.start_time }}</div>
<div class="live-item-content__status">{{ calcTimeText(subitem) }}</div> <div class="live-item-content__status">
{{ calcTimeText(subitem) }}
<el-tag v-if="[-1, 0].includes(subitem.sign_status)" style="float:right;" size="small" @click.stop="handleSignIn(subitem)"> </el-tag>
<el-tag v-if="[3, 5].includes(subitem.live_status) && [2, 3].includes(subitem.sign_status)" type="danger" style="float:right;" size="small">{{subitem.sign_status === 2 ? '迟到' : '漏签'}}</el-tag>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -67,6 +74,13 @@ export default { ...@@ -67,6 +74,13 @@ export default {
} }
}, },
methods: { methods: {
handleSignIn(item) {
if (item.sign_status === -1) {
this.$message.error('直播未开始,请提前10分钟进入签到')
} else {
this.fetchSignIn(item.id)
}
},
/* 退出登录 - 跳转方法 */ /* 退出登录 - 跳转方法 */
logout() { logout() {
cAction.Other.outLogin() cAction.Other.outLogin()
...@@ -239,6 +253,24 @@ export default { ...@@ -239,6 +253,24 @@ export default {
result = this.$t('live.watchReplay') result = this.$t('live.watchReplay')
} }
return result return result
},
fetchSignIn(id) {
cAction.Player.signIn(id)
.then(res => {
const { code, status } = res
if (code === 0) {
if (status === 1) {
this.$message.success('签到成功')
} else if (status === 2) {
this.$message.success('课程已开始,您已迟到,请于课后补看错过视频')
}
this.getNewLiveMsg()
this.getLiveList()
}
})
.catch(e => {
this.$message.error(e.message || '签到失败')
})
} }
}, },
mounted() { mounted() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论