kefu/h5/static/js/pages-index-history.13aed2d...

1 line
17 KiB
JavaScript
Raw Normal View History

2024-12-10 02:50:12 +00:00
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-index-history"],{"0ed4":function(e,t,n){"use strict";n.r(t);var a=n("400a"),i=n.n(a);for(var r in a)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(r);t["default"]=i.a},1130:function(e,t,n){"use strict";n.r(t);var a=n("70af"),i=n("dd9f");for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);n("1b78");var s=n("f0c5"),o=Object(s["a"])(i["default"],a["b"],a["c"],!1,null,"3bfce485",null,!1,a["a"],void 0);t["default"]=o.exports},"18df":function(e,t,n){"use strict";n("7a82");var a=n("4ea4").default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=a(n("53ca"));n("e9c4"),n("99af"),n("14d9");var r=a(n("81b7")),s=a(n("1f61")),o=a(n("3242")),u=getApp(),c={data:function(){return{title:"Hello",baseUrl:getApp().globalData.baseUrl,wsBaseUrl:getApp().globalData.wsBaseUrl,visitors:[],token:"",kefu:null,timer:null,wsOpen:!1,noticeContent:"通知: 无",avatarList:[{url:"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png"},{url:"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png"},{url:"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png"}],visitor_name:"",visitor_message:"",entTags:[],visitorTag:null,page:1,total:0,pageSize:10,showSearch:!1}},onShow:function(){var e=uni.getStorageSync("app");e&&(this.token=e.token);var t=uni.getStorageSync("domain");t&&(this.baseUrl=t.domain,this.wsBaseUrl=r.default.getWsUrl(t.domain)),this.checkAuth(),this.getTags()},onLoad:function(e){e.client_ip&&(this.visitor_name=e.client_ip)},onPullDownRefresh:function(){console.log("refresh"),this.getNewOnlineUser(1,!0),setTimeout((function(){uni.stopPullDownRefresh()}),1e3)},methods:{initSocket:function(){u.globalData.socketObj?u.globalData.socketObj.isConnect||u.globalData.socketObj.initSocket():(u.globalData.socketObj=new o.default(this.wsBaseUrl+"?token="+this.token,60),u.globalData.socketObj.initSocket())},kefuInfo:function(){var e=this;uni.request({url:e.baseUrl+"/kefu/kefuinfo?token="+e.token,method:"get",header:{"Content-Type":"application/x-www-form-urlencoded"},success:function(t){e.kefu=t.data.result,e.getNewOnlineUser(e.page,!0)}})},onlineIntime:function(){var e=this,t=this,n=null;uni.connectSocket({url:this.wsBaseUrl+"?token="+this.token}),uni.onSocketClose((function(e){clearInterval(n),console.log("WebSocket 连接断开")})),uni.onSocketOpen((function(e){console.log("WebSocket 连接已打开");var t={type:"ping",data:""};n=setInterval((function(){uni.sendSocketMessage({data:JSON.stringify(t)})}),5e3)})),uni.onSocketMessage((function(n){var a=JSON.parse(n.data);switch(a.type){case"userOnline":r.default.playVoice(),t.showNoticeBar(a.data.username+"来了");break;case"userOffline":t.showNoticeBar(a.data.name+"离线");break;case"message":e.recvMessage(a.data);break}}))},recvMessage:function(e){this.visitors=s.default.receiveMessage(this.visitors,e),this.showNoticeBar(e.name+":"+e.content),"yes"!=e.is_kefu&&r.default.playVoice()},getNewOnlineUser:function(e,t){var n=this,a=this.baseUrl,i={page:e,pagesize:15,token:n.token,kefuName:"3"==n.kefu.role_id?n.kefu.name:"",visitorName:n.visitor_name,visitorMessage:n.visitor_message,visitorTag:n.visitorTag};uni.request({url:a+"/kefu/visitorList",method:"GET",data:i,success:function(e){if(e.data.result.list){n.total=e.data.result.count,n.pageSize=e.data.result.pagesize,t&&(n.visitors=[]);for(var a=e.data.result.list,i=0;i<a.length;i++)a[i].avator=r.default.getImageUrl(a[i].avator,n.baseUrl),a[i].last_message=r.default.replaceHtml(a[i].last_message).substr(0,26);0==n.visitors.length?n.visitors=a:n.visitors=n.visitors.concat(n.visitors,a),n.visitors=n.removeRepeat(n.visitors)}}})},changePage:function(e){(e.type="next")&&this.page++,(e.type="prev")&&this.page--,(e.type="current")&&(this.page=e.current),this.getNewOnlineUser(this.page,!0)},chatVisitor:function(e,t){uni.navigateTo({url:"/pages/index/detail?visitor_id="+t})},showNoticeBar:function(e){this.