瀏覽代碼

Merge branch 'master' of http://svn.ouj.com:3000/eos_sicbo/chat

dmy 5 年之前
父節點
當前提交
c091bbe54d

+ 2 - 0
_src/api/index.js

@@ -1,3 +1,4 @@
+import base from './modules/base'
 import user from './modules/user'
 import group from './modules/group'
 import person from './modules/person'
@@ -7,6 +8,7 @@ import http from './http'
 
 export default {
   host: http.host,
+  base,
   user,
   group,
   person,

+ 25 - 0
_src/api/modules/base.js

@@ -0,0 +1,25 @@
+import axios from '../http'
+
+export default {
+  /**
+   * 申请群认证
+   */
+  groupAuth (data) {
+    return axios.request({
+      url: 'default/groupAuth',
+      method: 'post',
+      needLogin: true,
+      data
+    })
+  },
+  /**
+   * 问题反馈
+   */
+  feedback () {
+    return axios.request({
+      url: 'default/tick ',
+      method: 'post',
+      needLogin: true
+    })
+  }
+}

+ 0 - 12
_src/api/modules/group.js

@@ -329,18 +329,6 @@ export default {
   },
   /**
    * @param {Object} data
-   * @param {String} data.group_id
-   */
-  groupAuth (data) {
-    return axios.request({
-      url: 'group/auth',
-      method: 'post',
-      needLogin: true,
-      data
-    })
-  },
-  /**
-   * @param {Object} data
    * @param {Stirng} data.keyword
   */
   searchMember (data) {

+ 4 - 24
_src/components/chatGroudMgr/index.vue

@@ -53,11 +53,13 @@ import Vue from 'vue'
 import { Button, MessageBox } from 'element-ui'
 import { mapState } from 'vuex'
 import API from '@/api'
+import { addPanelSessionMixin } from '@/mixins/index'
 
 Vue.component(Button.name, Button)
 
 export default {
   name: 'chatGroudMgr',
+  mixins: [addPanelSessionMixin],
   computed: {
     ...mapState({
       curGroupId: state => state.curSession,
@@ -100,37 +102,15 @@ export default {
         })
     },
     addGroupAuth () {
-      API.group.groupAuth({
+      API.base.groupAuth({
         group_id: this.curGroupId
       }).then(({ data }) => {
         let serverId = data.data.serverId
-        // let serverId = 11
         let sessionId = this.userId > serverId
           ? `${serverId}-${this.userId}`
           : `${this.userId}-${serverId}`
 
-        // 先判断serverId有没有在sessionList
-        let isInSession = this.sessionList.some(v => {
-          return v.session_id == sessionId
-        })
-
-        if (!isInSession) {
-          // 没有就加入一个会话
-          API.user.getOtherInfo({
-            target_id: serverId
-          }).then(({ data }) => {
-            let userInfo = data.data
-            let obj = {
-              cover_photo: userInfo.cover_photo,
-              is_group: '0',
-              name: userInfo.nick_name,
-              session_id: sessionId,
-              unread: 0
-            }
-            this.$store.commit('addSessionItem', obj)
-          })
-        }
-
+        this.addPanelSession(serverId, sessionId)
         this.$store.commit('changeSessionId', sessionId)
         this.$router.push({ path: `/pm/${sessionId}` })
       })

+ 23 - 5
_src/components/panel/panel.vue

@@ -18,13 +18,13 @@
       <div class="panel-setting">
         <div :class="['panel-nav-icon',{'active':isShowSetting}]" @click.stop="toggleLoginOut()"></div>
         <ul :class="['menu',{'active':isShowSetting}]">
-          <li class="item"  @click.stop="handleLoginOut">
+          <!-- <li class="item"  @click.stop="handleLoginOut">
             <i class="icon-mute icon-mute0"></i>关闭声音
           </li>
           <li class="item"  @click.stop="handleLoginOut">
             <i class="icon-msg icon-msg0"></i>关闭消息
-          </li>
-          <li class="item"  @click.stop="handleLoginOut">
+          </li> -->
+          <li class="item"  @click.stop="handleFeedback">
             <i class="icon-feedback"></i>意见反馈
           </li>
           <li class="item"  @click.stop="handleLoginOut">
@@ -70,11 +70,12 @@
 <script>
 import { mapState } from 'vuex'
 import sessionItem from './sessionItem'
-import { searchUserMixin } from '@/mixins'
+import { searchUserMixin, addPanelSessionMixin } from '@/mixins'
+import API from '@/api'
 
 export default {
   name: 'panel',
-  mixins: [searchUserMixin],
+  mixins: [searchUserMixin, addPanelSessionMixin],
   data () {
     return {
       isShowSetting: false
@@ -82,6 +83,7 @@ export default {
   },
   computed: {
     ...mapState({
+      userId: state => state.userId,
       sessionList: state => state.chat.sessionList,
       userInfo: state => state.userInfo
     })
@@ -98,6 +100,22 @@ export default {
       this.$store.dispatch('doScatterLogout')
       this.$store.commit('chatAppLogin', false)
       this.$store.commit('toApp', false)
+      this.isShowSetting = false
+    },
+    handleFeedback () {
+      API.base.feedback({
+        group_id: this.curGroupId
+      }).then(({ data }) => {
+        let serverId = data.data.serverId
+        let sessionId = this.userId > serverId
+          ? `${serverId}-${this.userId}`
+          : `${this.userId}-${serverId}`
+
+        this.addPanelSession(serverId, sessionId)
+        this.$store.commit('changeSessionId', sessionId)
+        this.$router.push({ path: `/pm/${sessionId}` })
+        this.isShowSetting = false
+      })
     }
   },
   async created () {

+ 29 - 0
_src/mixins/index.js

@@ -323,3 +323,32 @@ export const chatInputMixin = {
     }
   }
 }
+
+//
+export const addPanelSessionMixin = {
+  methods: {
+    addPanelSession (serverId, sessionId) {
+      // 先判断serverId有没有在sessionList
+      let isInSession = this.sessionList.some(v => {
+        return v.session_id == sessionId
+      })
+
+      if (!isInSession) {
+        // 没有就加入一个会话
+        api.user.getOtherInfo({
+          target_id: serverId
+        }).then(({ data }) => {
+          let userInfo = data.data
+          let obj = {
+            cover_photo: userInfo.cover_photo,
+            is_group: '0',
+            name: userInfo.nick_name,
+            session_id: sessionId,
+            unread: 0
+          }
+          this.$store.commit('addSessionItem', obj)
+        })
+      }
+    }
+  }
+}

+ 8 - 4
_src/store/module/group/actions.js

@@ -516,6 +516,10 @@ const actions = {
       let channel = _data.channel
       let data = _data.data
       let muteList = rootGetters.muteList // 免打扰列表
+      let unreadNum = 1
+      rootState.chat.sessionList.forEach((item) => {
+        unreadNum += Number(item.unread)
+      })
 
       // 群聊
       if (channel.match('chat:group')) {
@@ -527,11 +531,11 @@ const actions = {
           if (rootState.curSession === data.group_id) {
             dispatch('getNewMsg', { newMsg: true })
             commit('addUnreadNums')
-            noticeManager.changeTitle()
+            noticeManager.changeTitle(unreadNum)
           } else {
             if (!isMute) {
               noticeManager.showNotification(data)
-              noticeManager.changeTitle()
+              noticeManager.changeTitle(unreadNum)
             }
           }
         }
@@ -594,11 +598,11 @@ const actions = {
           if (rootGetters.otherUserId == data.from) {
             dispatch('getPrivateNewMsg')
             commit('addUnreadNums')
-            noticeManager.changeTitle()
+            noticeManager.changeTitle(unreadNum)
           } else {
             if (!isMute) {
               noticeManager.showNotification(data)
-              noticeManager.changeTitle()
+              noticeManager.changeTitle(unreadNum)
             }
           }
         }

+ 12 - 2
_src/util/util.js

@@ -354,6 +354,7 @@ export function scrollMsgIntoView (node, offsetTop, targetNode) {
 }
 
 export var noticeManager = {
+  tabTimer: null, // tab切换定时器
   askPermission () {
     return new Promise((resolve, reject) => {
       if (!('Notification' in window)) {
@@ -398,9 +399,18 @@ export var noticeManager = {
       }, 3500)
     })
   },
-  changeTitle () {
+  changeTitle (num) {
     if (document.hidden) {
-      document.title = 'MeeChat (你有新消息)'
+      let title = num ? `MeeChat (你有${num}新消息)` : `MeeChat`
+
+      document.title = title
+
+      if (num) {
+        if (this.tabTimer) clearTimeout(this.tabTimer)
+        this.tabTimer = setTimeout(() => {
+          document.title = `MeeChat`
+        }, 1000)
+      }
     }
   }
 }