You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-fly/static/h5/static/js/pages-index-detail.999a56bf.js

1 line
9.8 KiB

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-index-detail"],{1698:function(t,e,a){"use strict";a("4d63"),a("ac1f"),a("25f0"),a("5319"),a("498a"),Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i={data:function(){return{baseUrl:"https://gofly.sopans.com",wsBaseUrl:"wss://gofly.sopans.com/ws_kefu",messages:[],messageContent:"",sendDisabled:!1,token:"",visitor_id:"",visitor_name:"",kefu_name:"",isDisabled:!1,area:"",showArea:!1,scrollSize:2,faceTitles:["[微笑]","[嘻嘻]","[哈哈]","[可爱]","[可怜]","[挖鼻]","[吃惊]","[害羞]","[挤眼]","[闭嘴]","[鄙视]","[爱你]","[泪]","[偷笑]","[亲亲]","[生病]","[太开心]","[白眼]","[右哼哼]","[左哼哼]","[嘘]","[衰]","[委屈]","[吐]","[哈欠]","[抱抱]","[怒]","[疑问]","[馋嘴]","[拜拜]","[思考]","[汗]","[困]","[睡]","[钱]","[失望]","[酷]","[色]","[哼]","[鼓掌]","[晕]","[悲伤]","[抓狂]","[黑线]","[阴险]","[怒骂]","[互粉]","[心]","[伤心]","[猪头]","[熊猫]","[兔子]","[ok]","[耶]","[good]","[NO]","[赞]","[来]","[弱]","[草泥马]","[神马]","[囧]","[浮云]","[给力]","[围观]","[威武]","[奥特曼]","[礼物]","[钟]","[话筒]","[蜡烛]","[蛋糕]"],noticeContent:""}},onLoad:function(t){var e=uni.getStorageSync("app");e&&(this.token=e.token,this.kefu_name=e.kefu_name),this.visitor_id=t.visitor_id,this.checkAuth(),this.getVisitor(),this.getMessages()},methods:{getVisitor:function(){var t=this.baseUrl,e=this;uni.request({url:t+"/visitor?visitorId="+this.visitor_id+"&token="+e.token,method:"GET",success:function(t){var a=t.data.code;200==a&&(e.visitor_name=t.data.result.name,1==t.data.result.status?uni.setNavigationBarTitle({title:"[在线]:"+e.visitor_name}):uni.setNavigationBarTitle({title:"[离线]:"+e.visitor_name}))}})},getMessages:function(){uni.showLoading({title:"加载中..."});var t=this.baseUrl,e=this;uni.request({url:t+"/2/messages?visitor_id="+this.visitor_id,method:"GET",success:function(t){uni.hideLoading();var a=t.data.result;for(var i in a)a[i]["content"]=e.replaceContent(a[i]["content"],e.baseUrl);console.log(a),e.messages=a,setTimeout((function(){e.pageScrollToBottom()}),2e3),e.onlineIntime()}})},checkAuth:function(){var t=this;uni.request({url:t.baseUrl+"/userinfo?token="+t.token,method:"GET",success:function(t){var e=t.data.code;200!=e&&uni.navigateTo({url:"/pages/index/login"})}})},onlineIntime:function(){var t=this;console.log(this.wsBaseUrl+"?token="+this.token),uni.connectSocket({url:this.wsBaseUrl+"?token="+this.token}),uni.onSocketClose((function(t){console.log("WebSocket 连接断开")})),uni.onSocketOpen((function(t){console.log("WebSocket 连接已打开");var e={type:"ping",data:""};setInterval((function(){uni.sendSocketMessage({data:JSON.stringify(e)})}),5e3)})),uni.onSocketMessage((function(e){var a=JSON.parse(e.data);switch(a.type){case"message":t.recvMessage(a.data);break;case"inputing":if(a.data.from!=t.visitor_id)return;""==a.data.content?uni.setNavigationBarTitle({title:"[在线]:"+t.visitor_name}):uni.setNavigationBarTitle({title:"[输入]:"+a.data.content});break;case"userOffline":if(t.showNoticeBar(a.data.name+"离线"),a.data.uid!=t.visitor_id)return;uni.setNavigationBarTitle({title:"[离线]:"+t.visitor_name});break;case"userOnline":if(t.showNoticeBar(a.data.username+"来了"),a.data.uid!=t.visitor_id)return;uni.setNavigationBarTitle({title:"[在线]:"+t.visitor_name});break}}))},recvMessage:function(t){var e=this;if(t.id==this.visitor_id){t.mes_type="yes"==t.is_kefu?"kefu":"visitor",t.content=e.replaceContent(t.content,e.baseUrl);var a=this.messages;a.push(t),this.messages=a,e.pageScrollToBottom(),uni.setNavigationBarTitle({title:"[在线]:"+e.visitor_name}),this.showNotice(t.name+":"+t.content)}},pageScrollToBottom:function(){this.$nextTick((function(){uni.pageScrollTo({scrollTop:1e17})}))},placeFace:function(){for(var t=[],e=0;e<this.faceTitles.length;e++)t[this.faceTitles[e]]="/static/images/face/"+e+".gif";return t},replaceContent:function(t,e){"undefined"==typeof e&&(e="");var a=this.placeFace();return t=(t||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;").replace(/face\[([^\s\[\]]+?)\]/g,(function(t){var i=t.replace(/^face/g,"");return'<img alt="'+i+'" title="'+i+'" src="'+e+a[i]+'">'})).replace(/img\[([^\s\[\]]+?)\]/g,(function(t){var a=t.replace(/^img\[/g,"").replace(/\]/g,"");return'<img @click="bigPic("'+e+a+'",true)" src="'+e+a+'" style="max-width: 100%"/></div>'})).replace(/file\[([^\s\[\]]+?)\]/g,(function(t){var e=t.replace(/^file\[/g,"").replace(/\]/g,"");return'<div class="folderBtn" onclick="window.open(\''+e+'\')" style="font-size:25px;"/></div>'})).replace(/\[([^\s\[\]]+?)\]+link\[([^\s\[\]]+?)\]/g,(function(t){var e=t.replace(/link\[.*?\]/g,"").replace(/\[|\]/g,""),a=t.replace(/^\[([^\s\[\]]+?)\]+link\[/g,"").replace(/\]/g,"");return'<a href="javascript:void(0)" onclick="window.open(\''+a+"')\" />【"+e+"】</a>"})).replace(/\n/g,"<br>"),t},bigPic:function(t,e){e&&window.open(t)},chatToUser:function(){var t=this;this.messageContent=this.messageContent.trim("\r\n"),""!=this.messageContent&&"\r\n"!=this.messageContent&&""!=this.currentGuest?t.isDisabled||(uni.showLoading({title:"发送中..."}),t.isDisabled=!0,uni.request({url:t.baseUrl+"/2/message",method:"POST",header:{"Content-Type":"application/x-www-form-urlencoded"},data:{from_id:t.kefu_name,to_id:t.visitor_id,content:t.messageContent,type:"kefu"},success:function(e){t.isDisabled=!1,uni.hideLoading();var a=e.data.code;200!=a?uni.showModal({content:e.data.msg}):(t.messageContent="",t.pageScrollToBottom())}})):uni.showModal({content:"内容不能为空"})},showNotice:function(t){},showNoticeBar:function(t){var e=this;e.noticeContent=t,setTimeout((function(){e.noticeContent=""}),3e3)}}};e.default=i},1736:function(t,e,a){"use strict";a.r(e);var i=a("1698"),n=a.n(i);for(var o in i)"default"!==o&&function(t){a.d(e,t,(function(){return i[t]}))}(o);e["default"]=n.a},"264f":function(t,e,a){"use strict";a.r(e);var i=a("f286"),n=a("1736");for(var o in n)"default"!==o&&function(t){a.d(e,t,(function(){return n[t]}))}(o);a("7752");var s,r=a("f0c5"),c=Object(r["a"])(n["default"],i["b"],i["c"],!1,null,"7a7080c2",null,!1,i["a"],s);e["default"]=c.exports},7752:function(t,e,a){"use strict";var i=a("a2d1"),n=a.n(i);n.a},a2d1:function(t,e,a){var i=a("d3f6");"string"===typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);var n=a("4f06").default;n("37d0e36f",i,!0,{sourceMap:!1,shadowMode:!1})},d3f6:function(t,e,a){var i=a("24fb");e=i(!1),e.push([t.i,".flyAvatar[data-v-7a7080c2]{display:inline-block;box-sizing:border-box;text-align:center;color:#fff;background:#c0c4cc;width:40px;height:40px;line-height:40px;border-radius:50%;margin-top:5px}.chatUser[data-v-7a7080c2]{line-height:24px;font-size:12px;white-space:nowrap;color:#999;text-align:left}.chatLittle[data-v-7a7080c2]{width:12.5%;float:left}.chatBig[data-v-7a7080c2]{width:87.5%;float:right}.chatBox[data-v-7a7080c2]{padding:0 4px}.chatBoxMe .chatContent[data-v-7a7080c2]{float:right;background-color:#98e165;border:1px solid #91d760}.chatBoxMe .chatContent[data-v-7a7080c2]:after{border-top-color:#98e165}.chatBoxMe .chatLittle[data-v-7a7080c2]{width:12.5%;float:right;text-align:right}.chatBoxMe .chatUser[data-v-7a7080c2]{text-align:right}.chatBoxMe .chatContent[data-v-7a7080c2]:after{left:auto;right:-10px}.chatContent[data-v-7a7080c2]{background-color:#a6d4f2;color:#000;border:1px solid #98c7e6;padding:8px 15px;word-break:break-all;position:relative;border-radius:5px;display:inline-block;margin-left:4px}.chatBoxMe .chatContent[data-v-7a7080c2]{margin-right:4px}.chatTime[data-v-7a7080c2]{text-align:center;color:#bbb;margin:5px 0;font-size:12px}.chatArea[data-v-7a7080c2]{float:left;width:70%;height:50px;margin:4px 0 0 4px;border-color:#c0c4cc;padding:1px 5px;background:#fff;border-radius:4px}.btnArea[data-v-7a7080c2]{width:20%;float:right;margin-top:15px}.visitorFaceBox[data-v-7a7080c2]{position:absolute;bottom:70px}.chatBoxSend[data-v-7a7080c2]{background:#f5f5f5;position:fixed;bottom:0;left:0;width:100%;height:70px}.chatContext[data-v-7a7080c2]{width:100%;text-align:left;position:relative;padding-bottom:75px}.clear[data-v-7a7080c2]{clear:both}",""]),t.exports=e},f286:function(t,e,a){"use strict";var i;a.d(e,"b",(function(){return n})),a.d(e,"c",(function(){return o})),a.d(e,"a",(function(){return i}));var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("v-uni-view",{staticClass:"chatContext"},[a("v-uni-view",{staticClass:"chatBox"},[t._l(t.messages,(function(e){return a("v-uni-view",{class:{chatBoxMe:"kefu"==e.mes_type}},[a("v-uni-view",{staticClass:"chatTime",class:{chatTimeHide:0==e.show_time}},[t._v(t._s(e.time))]),a("v-uni-view",{staticClass:"chatLittle"},[a("v-uni-image",{staticClass:"flyAvatar",attrs:{src:t.baseUrl+e.avator}})],1),a("v-uni-view",{staticClass:"chatBig"},[a("v-uni-view",{staticClass:"chatUser"},[t._v(t._s(e.name))]),a("v-uni-view",{staticClass:"chatContent",domProps:{innerHTML:t._s(e.content)}})],1),a("v-uni-view",{staticClass:"clear"})],1)})),a("v-uni-view",{directives:[{name:"show",rawName:"v-show",value:0==t.messages.length,expression:"messages.length==0"}],staticClass:"flyNotice"},[t._v("暂无消息记录")]),a("v-uni-view",{directives:[{name:"show",rawName:"v-show",value:t.noticeContent,expression:"noticeContent"}],staticClass:"flyNoticeBar"},[t._v(t._s(t.noticeContent))])],2),a("v-uni-view",{staticClass:"chatBoxSend"},[a("v-uni-textarea",{staticClass:"chatArea",attrs:{placeholder:"请输入信息"},nativeOn:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.chatToUser(e)}},model:{value:t.messageContent,callback:function(e){t.messageContent=e},expression:"messageContent"}}),a("v-uni-view",{staticClass:"btnArea"},[a("v-uni-button",{attrs:{type:"primary",size:"mini"},on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.chatToUser.apply(void 0,arguments)}}},[t._v("发送")])],1)],1)],1)},o=[]}}]);