1 line
202 KiB
JavaScript
1 line
202 KiB
JavaScript
|
"use strict";(self["webpackChunkmining_pool"]=self["webpackChunkmining_pool"]||[]).push([[259],{4447:function(t,e,s){var i=s(3999)["default"];Object.defineProperty(e,"B",{value:!0}),e.A=void 0;var a=i(s(17713));e.A={name:"Announcements",mixins:[a.default]}},4710:function(t,e,s){Object.defineProperty(e,"B",{value:!0}),e.A=void 0,s(44114),s(18111),s(22489),s(20116),s(7588),s(61701),s(18237),s(13579);var i=s(51775),a=s(92500);e.A={name:"CustomerServiceChat",data(){return{searchText:"",inputMessage:"",currentContactId:null,previewVisible:!1,previewImageUrl:"",contacts:[],messages:{},messagesLoading:!1,sending:!1,loadingRooms:!0,stompClient:null,wsConnected:!1,userEmail:"",userType:2,loadingHistory:!1,userViewHistory:!1,userScrolled:!1,history7Params:{id:"",roomId:"",userType:2,email:""},historyAllParams:{id:"",roomId:"",userType:2},receiveUserType:"",manualCreatedRooms:[],chatRooms:[],isWebSocketConnected:!1,connectionStatus:"disconnected",isLoadingMoreContacts:!1,lastContactTime:null,showScrollButton:!1,visibilityHandler:null,reconnectTimer:null,maxReconnectAttempts:5,reconnectInterval:5e3,reconnectAttempts:0,isHandlingError:!1,lastErrorTime:0,lastActivityTime:Date.now(),activityCheckInterval:null,activityEvents:null,activityHandler:null,connectionVerifyTimer:null,connectionVerifyTimeout:6e4,isConnectionVerified:!1,heartbeatInterval:null,heartbeatTimeout:3e4,lastHeartbeatTime:0,connectionCheckInterval:null,connectionCheckTimeout:6e4,hasMoreHistory:!0,noMoreHistoryMessage:"",networkStatus:"online",token:""}},computed:{filteredContacts(){return this.searchText?this.contacts.filter((t=>t.name.toLowerCase().includes(this.searchText.toLowerCase()))):this.contacts},currentContact(){return this.contacts.find((t=>t.roomId===this.currentContactId))},currentMessages(){return this.messages[this.currentContactId]||[]}},watch:{token:{handler(t){t||(console.log("token已过期,断开所有窗口连接"),localStorage.setItem("cs_disconnect_all",Date.now().toString()),this.disconnectWebSocket())},deep:!0,immediate:!0}},created(){try{let t=localStorage.getItem("userEmail");this.userEmail=JSON.parse(t),window.addEventListener("setItem",(()=>{let t=localStorage.getItem("userEmail");this.userEmail=JSON.parse(t)})),this.fetchRoomList(),this.loadManualCreatedRooms(),console.log("mounted userEmail=",t,"parsed=",this.userEmail),this.initWebSocket()}catch(t){console.error("初始化失败:",t)}},mounted(){this.fetchRoomList();let t=localStorage.getItem("userEmail");this.userEmail=JSON.parse(t);let e=localStorage.getItem("token");this.token=JSON.parse(e),window.addEventListener("setItem",(()=>{let t=localStorage.getItem("userEmail");this.userEmail=JSON.parse(t);let e=localStorage.getItem("token");this.token=JSON.parse(e)})),window.addEventListener("online",this.handleNetworkChange),window.addEventListener("offline",this.handleNetworkChange),this.$nextTick((()=>{this.$refs.messageContainer&&this.$refs.messageContainer.addEventListener("scroll",this.handleScroll)})),this.$nextTick((()=>{const t=document.querySelector(".cs-contacts");t&&t.addEventListener("scroll",this.handleContactListScroll)})),this.visibilityHandler=()=>{"visible"===document.visibilityState?(console.log("🔍 客服页面重新可见,执行连接状态检查"),this.updateLastActivityTime(),this.performConnectionCheck(),"connected"===this.connectionStatus&&this.isWebSocketConnected?(console.log("✅ 客服页面可见,连接状态正常"),this.heartbeatInterval||this.startHeartbeat(),this.connectionCheckInterval||this.startConnectionCheck()):(console.log("🔄 客服页面可见,检测到连接异常,开始重连"),this.checkAndReconnect())):console.log("📱 客服页面变为隐藏状态")},document.addEventListener("visibilitychange",this.visibilityHandler),this.startActivityCheck(),this.activityEvents=["mousedown","mousemove","keypress","scroll","touchstart","click"],this.activityHandler=()=>{this.updateLastActivityTime()},this.activityEvents.forEach((t=>{document.addEventListener(t,this.activityHandler,!0)})),window.addEventListener("storage",this.handleStorageChange)
|