diff --git a/src/api/index.js b/src/api/index.js index 4b82e93..6c6798d 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -12,6 +12,7 @@ export default { getUserAllRoleByToken : `users/users/role/getUserAllRoleByToken`, getSchoolIdByToken : `users/users/data/user/getSchoolIdByToken`, deleteProfile : `users/users/userInfo/deleteProfile`, + refreshPageNotification : `nakadai/message/refreshPageNotification`, platformLogList: `nakadai/nakadai/log/platformLogList`, logNotification: `nakadai/nakadai/log/logNotification`, diff --git a/src/layouts/header/index.vue b/src/layouts/header/index.vue index 3d76b27..6b863d0 100644 --- a/src/layouts/header/index.vue +++ b/src/layouts/header/index.vue @@ -74,6 +74,7 @@ import { mapState, mapMutations, mapActions } from "vuex"; import util from "@/libs/util"; import Setting from "@/setting"; +import Bus from '@/libs/bus' export default { data () { return { @@ -119,24 +120,65 @@ export default { } }).catch(res => { }) }, + + + // socket连接成功 + open () { + console.log("socket连接成功"); + }, + // socket连接失败 + error () { + console.log("连接错误"); + }, + // 接收消息 + getMessage (msg) { + console.log("==websocket接收数据=="); + console.log(JSON.parse(msg.data)); + + const { content } = JSON.parse(msg.data) + // 1赛事、2创业、3考核、4模型。-号拼接携带id + if (content == 1) { + Bus.$emit('matchSocket') + } else if (content == 2) { + Bus.$emit('activitySocket') + } else if (content == 4) { + Bus.$emit('modelSocket') + } else { + this.getNotice() + } + }, + // 关闭socket + close () { + console.log("socket已经关闭"); + }, + initSocket ({ id, account }) { + // 实例化socket + // this.socket = new WebSocket(`ws://${Setting.isDev ? '192.168.31.51' : location.host}:9100/nakadai/websocket/${id}/${account}`) + this.socket = new WebSocket(`ws://121.37.12.51:9100/nakadai/websocket/${id}/${account}`) + // 监听socket连接 + this.socket.onopen = this.open; + // 监听socket错误信息 + this.socket.onerror = this.error; + // 监听socket消息 + this.socket.onmessage = this.getMessage; + }, + // 获取消息 getNotice () { - if (!Setting.isDev) { - this.noticeTimer = setInterval(() => { - this.$get(this.api.messageNotificationList, { - type: 2 - }).then(res => { - this.notices = res.notificationList - }).catch(res => { }); - }, 5000) - } + this.$get(this.api.messageNotificationList, { + type: 2 + }).then(res => { + this.notices = res.notificationList + }).catch(res => { }); }, // 前往评论列表 - toComment (item) { + async toComment (item) { + await this.$post(`${this.api.noticeRead}?isRead=1¬ifyId=${item.notifyId}`) // 该通知置为已读 this.$router.push(`/station/preview?courseId=${item.cid}&commentId=${item.commentId}¬ifyId=${item.notifyId}`) }, getUserDetail () { // 获取用户详情 this.$get(this.api.queryUserInfoDetails).then(res => { + this.initSocket(res.result.userAccount) let { hrUserInfo } = res.result if (hrUserInfo) { const { userAvatars, userName, userId } = hrUserInfo diff --git a/src/pages/activity/list/index.vue b/src/pages/activity/list/index.vue index 97ca1ed..07d8107 100644 --- a/src/pages/activity/list/index.vue +++ b/src/pages/activity/list/index.vue @@ -141,11 +141,11 @@ import { mapState, mapMutations } from "vuex"; import { Loading } from "element-ui"; import Setting from "@/setting" import util from "@/libs/util" +import Bus from '@/libs/bus' export default { data () { return { timer: null, - redisTimer: null, token: util.local.get(Setting.tokenKey), statusList: ["待报名", "取消报名", "马上报名", "报名截止", "已结束"], endList: ["报名开始", "报名截止", "报名截止", "项目开始", "项目结束"], @@ -200,14 +200,18 @@ export default { } }, mounted () { + // websocket实时刷新 + Bus.$on('activitySocket', () => { + this.getData() + }) + this.getData() this.$once('hook:beforeDestroy', function () { this.clearTimer() - clearInterval(this.redisTimer) }) }, methods: { - getList () { + getData () { this.clearTimer() const { form } = this const data = { @@ -278,14 +282,6 @@ export default { }) this.timerList = [] }, - getData () { - // this.loadIns = Loading.service() - this.getList() - if (!Setting.isDev) { - clearInterval(this.redisTimer) - this.redisTimer = setInterval(this.getRedis, 1000) - } - }, initData () { this.page = 1 this.getData() diff --git a/src/pages/activity/manage/list/index.vue b/src/pages/activity/manage/list/index.vue index 87e1026..d3e63f8 100644 --- a/src/pages/activity/manage/list/index.vue +++ b/src/pages/activity/manage/list/index.vue @@ -179,6 +179,7 @@ import util from "@/libs/util"; import Setting from "@/setting"; import { mapMutations } from "vuex"; import { Loading } from 'element-ui' +import Bus from '@/libs/bus' export default { data () { return { @@ -249,7 +250,6 @@ export default { playingStages: [] }, timer: null, - redisTimer: null, pickerOptions: { shortcuts: [{ text: '此刻', @@ -287,17 +287,21 @@ export default { } }, mounted () { + // websocket实时刷新 + Bus.$on('activitySocket', () => { + this.getData() + }) + this.getData() this.$once('hook:beforeDestroy', function () { clearInterval(this.timer) - clearInterval(this.redisTimer) }) }, methods: { ...mapMutations('activity', [ 'setPage' ]), - getList () { + getData () { // const load = Loading.service() const { form } = this this.$post(this.api.activityList, { @@ -318,33 +322,12 @@ export default { this.page-- this.getData() } - }).catch(res => { - // load.close() - }) - }, - getData () { - this.getList() + }).catch(res => { }) }, initData () { this.page = 1; this.getData(); }, - // 获取redis缓存 - getRedis () { - this.$post(this.api.getRedisCacheActivity).then(({ data }) => { - if (data) { - localStorage.getItem('activityTimestamp') !== data && this.getList() // 本地缓存跟redis返回的不一样,就查询列表 - localStorage.setItem('activityTimestamp', data) - } - }).catch(res => { }) - }, - getData () { - this.getList() - // if (!Setting.isDev) { - clearInterval(this.redisTimer) - this.redisTimer = setInterval(this.getRedis, 1000) - // } - }, add () { this.$router.push("add"); }, @@ -397,7 +380,7 @@ export default { if (date == "0000-00-00 00:00:00") return "---"; return date; }, - switchOff (val, row) { + async switchOff (val, row) { this.$post(this.api.disabledEventsActivity, { activityId: row.id, isOpen: val, @@ -405,6 +388,8 @@ export default { }).then(res => { }).catch(err => { row.schoolOpen = val ? 0 : 1 }) + + await this.$post(`${this.api.refreshPageNotification}?content=2`) }, } }; diff --git a/src/pages/assessment/list/index.vue b/src/pages/assessment/list/index.vue index 7027242..1aff188 100644 --- a/src/pages/assessment/list/index.vue +++ b/src/pages/assessment/list/index.vue @@ -1,410 +1,510 @@ diff --git a/src/pages/expSystem/backstage/model.vue b/src/pages/expSystem/backstage/model.vue index 796b318..46948b2 100644 --- a/src/pages/expSystem/backstage/model.vue +++ b/src/pages/expSystem/backstage/model.vue @@ -120,6 +120,7 @@ \ No newline at end of file diff --git a/src/pages/product/show/index.vue b/src/pages/product/show/index.vue index 9b22cdf..406b758 100644 --- a/src/pages/product/show/index.vue +++ b/src/pages/product/show/index.vue @@ -37,20 +37,51 @@
-
适用专业:{{ form.goodsRes.professionalName }}
+
+ 适用专业: + +
+ {{ form.goodsRes.professionalName }} +
+
+
适用场景:{{ form.mall.applicationScenario }}
+ class="field"> + 适用场景: +
{{ form.mall.applicationScenario }}
+
匹配课程:{{ form.mall.matchingCourse }}
+ class="field"> + 匹配课程: + +
+ {{ form.mall.matchingCourse }} +
+
+
预计课时:{{ form.mall.courseHours }}
+ class="field"> + 预计课时: +
{{ form.mall.courseHours }}
+
产品类型:{{ form.goodsRes.typeName }}
+ class="field"> + 产品类型: +
{{ form.goodsRes.typeName }}
+