|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="join-wrap">
|
|
|
- <div class="join-main-box">
|
|
|
+ <div class="join-main-box" v-show="!isJoin">
|
|
|
<p class="join-title">
|
|
|
<span>
|
|
|
{{$t('cusMgt.join.title')}}
|
|
@@ -30,24 +30,36 @@
|
|
|
{{$t('cusMgt.join.joinBtn')}}
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div v-show="isJoin" class="join-main-box">
|
|
|
+ <p class="join-title">
|
|
|
+ <span>
|
|
|
+ {{$t('cusMgt.join.title')}}
|
|
|
+ </span>
|
|
|
+ </p>
|
|
|
+ <Icon type="md-checkmark-circle-outline" color="#19be6b" size="120"/>
|
|
|
+ <p class="success-tips">{{$t('cusMgt.join.hasJoin')}}</p>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+import jwtDecode from 'jwt-decode'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ isJoin: false,
|
|
|
tId: '',
|
|
|
tName: '',
|
|
|
listId: '',
|
|
|
listName: '',
|
|
|
cusName: '',
|
|
|
- tmid: ''
|
|
|
+ code: '',
|
|
|
+ userId: ''
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
joinList(stulist) {
|
|
|
if (stulist) {
|
|
|
- stulist.tmids.push(this.tmid)
|
|
|
+ stulist.tmids.push(this.userId)
|
|
|
this.$api.courseMgmt.upsertStulist({
|
|
|
scope: 'private',
|
|
|
stuList: stulist
|
|
@@ -55,6 +67,7 @@ export default {
|
|
|
res => {
|
|
|
if (!res.error) {
|
|
|
this.$Message.success(this.$t('cusMgt.join.joinOk'))
|
|
|
+ this.isJoin = true
|
|
|
} else {
|
|
|
this.$Message.error(this.$t('cusMgt.join.joinErr'))
|
|
|
}
|
|
@@ -76,9 +89,12 @@ export default {
|
|
|
}
|
|
|
this.$api.courseMgmt.findListSummary(params).then(
|
|
|
res => {
|
|
|
- if (!res.error && res.stulist && res.stulist.length) {
|
|
|
- console.log(res)
|
|
|
- this.joinList(res.stulist[0])
|
|
|
+ if (!res.error && res.stuList && res.stuList.length) {
|
|
|
+ if (res.stuList[0].tmids.includes(this.userId)) {
|
|
|
+ this.isJoin = true
|
|
|
+ } else {
|
|
|
+ this.joinList(res.stuList[0])
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$Message.error(this.$t('cusMgt.join.getListErr'))
|
|
|
}
|
|
@@ -95,16 +111,50 @@ export default {
|
|
|
this.listId = this.$route.query.listId //名单id
|
|
|
this.listName = this.$route.query.listName //名单
|
|
|
this.cusName = this.$route.query.cusName //课程名称
|
|
|
- if (!this.listId || !this.tId) {
|
|
|
+ this.code = this.$route.query.code //登录成功返回的code
|
|
|
+ if (!this.listId || !this.tId || !this.code) {
|
|
|
this.$Modal.error({
|
|
|
title: this.$t('cusMgt.join.errorTile'),
|
|
|
content: this.$t('cusMgt.join.errorContent')
|
|
|
})
|
|
|
+ } else {
|
|
|
+ //获取登录信息
|
|
|
+ let srvAdr = this.$store.state.config.srvAdr
|
|
|
+ let host = srvAdr == 'Global' ? this.$store.state.config.Global.coreAPIUrl : this.$store.state.config.China.coreAPIUrl
|
|
|
+ let clientId = srvAdr == 'Global' ? this.$store.state.config.Gloabl.clientID : this.$store.state.config.China.clientID
|
|
|
+ this.$api.service.getToken(host, {
|
|
|
+ grant_type: "authorization_code",
|
|
|
+ client_id: clientId,
|
|
|
+ code: this.code
|
|
|
+ }).then(
|
|
|
+ res => {
|
|
|
+ if (!res.error) {
|
|
|
+ let tokenData = jwtDecode(res.id_token)
|
|
|
+ if (tokenData) {
|
|
|
+ this.userId = tokenData.sub
|
|
|
+ console.log(this.userId)
|
|
|
+ } else {
|
|
|
+ this.$Message.error('登录信息解析失败')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$Message.error('用户信息获取失败')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ this.$Message.error('用户信息获取失败')
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
<style scoped lang="less">
|
|
|
+.success-tips{
|
|
|
+ color: white;
|
|
|
+ font-size: 16px;
|
|
|
+ margin-top: 20px;
|
|
|
+}
|
|
|
.join-wrap {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
@@ -115,6 +165,7 @@ export default {
|
|
|
background-image: url("../../assets/image/bak_light.jpg");
|
|
|
}
|
|
|
.join-btn {
|
|
|
+ cursor: pointer;
|
|
|
width: 100%;
|
|
|
margin: auto;
|
|
|
margin-top: 60px;
|