Pārlūkot izejas kodu

全局im聊天框

yangc 8 gadi atpakaļ
vecāks
revīzija
c118b499ab

+ 7 - 0
components/default/RightBar.vue

@@ -108,6 +108,9 @@
         } else {
           return {enName: this.user.data.userName + '(个人账户)'}
         }
+      },
+      tab () {
+        return this.$store.state.chat.tab.tab.data
       }
     },
     mounted () {
@@ -185,7 +188,11 @@
           let iTop = (window.screen.availHeight - 30 - 780) / 2
           // 获得窗口的水平位置
           let iLeft = (window.screen.availWidth - 10 - 1030) / 2
+          if (this.tab.close) {
+            this.tab.close()
+          }
           let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
+          this.$store.dispatch('chat/setChatTab', {tab: newTab})
           this.$http.get('/basic/enterprise/' + this.enterprise.uu + '/info')
             .then(response => {
               let obj = {}

+ 7 - 0
components/store/common/StoreHeader.vue

@@ -91,6 +91,9 @@ export default {
     },
     isFocus () {
       return this.$store.state.shop.storeInfo.focusList.data
+    },
+    tab () {
+      return this.$store.state.chat.tab.tab.data
     }
   },
   methods: {
@@ -125,7 +128,11 @@ export default {
         let iTop = (window.screen.availHeight - 30 - 780) / 2
         // 获得窗口的水平位置
         let iLeft = (window.screen.availWidth - 10 - 1030) / 2
+        if (this.tab.close) {
+          this.tab.close()
+        }
         let newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')
+        this.$store.dispatch('chat/setChatTab', {tab: newTab})
         this.$http.get('/basic/enterprise/' + this.storeInfo.enUU + '/info')
           .then(response => {
             let obj = {}

+ 6 - 0
store/chat.js

@@ -0,0 +1,6 @@
+export const actions = {
+  setChatTab ({ commit }, params = {}) {
+    console.log(params)
+    commit('tab/GET_TABLE_SUCCESS', params.tab)
+  }
+}

+ 13 - 0
store/chat/tab.js

@@ -0,0 +1,13 @@
+export const state = () => ({
+  tab: {
+    fetching: false,
+    data: []
+  }
+})
+
+export const mutations = {
+  GET_TABLE_SUCCESS (state, result) {
+    state.tab.fetching = false
+    state.tab.data = result
+  }
+}