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.
jiaojiu/dist/js/chunk-2ecb4718.89d81ee7.js

2 lines
6.7 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2ecb4718"],{"498a":function(t,s,e){"use strict";var n=e("23e7"),i=e("58a8").trim,o=e("c8d2");n({target:"String",proto:!0,forced:o("trim")},{trim:function(){return i(this)}})},"4ab9":function(t,s,e){},"57a7":function(t,s,e){"use strict";e.r(s);var n=function(){var t=this,s=t.$createElement,n=t._self._c||s;return n("div",{attrs:{id:"chat"}},[n("NavBar",{staticClass:"nav-bar"},[n("div",{staticClass:"back",attrs:{slot:"left"},on:{click:t.backClick},slot:"left"},[n("img",{attrs:{src:e("5aa0"),alt:""}})]),n("div",{staticClass:"title",attrs:{slot:"center"},slot:"center"},[t._v("在线聊天("+t._s(t.num)+")")])]),n("Scroll",{ref:"scroll",staticClass:"content",attrs:{"probe-type":3,"pull-up-load":!0},on:{pullingUp:t.loadMore,pullingDown:t.pullingDown}},[n("ul",t._l(t.lists,(function(s,e){return n("li",{key:"message"+e},[0==s.size?n("div",{staticClass:"minienter"},[t._v(" "+t._s(s.name)+"进入群聊 ")]):3==s.size?n("div",{staticClass:"minienter"},[t._v(" "+t._s(s.name)+"退出群聊 ")]):1==s.size?n("div",{staticClass:"minemsg"},[n("div",[n("img",{attrs:{src:t.getAvatar(s.uid),alt:""}})]),n("div",{staticClass:"mine-bottom"},[n("div",{staticClass:"namefont"},[t._v(" "+t._s(s.name)+" "),n("span",[t._v(t._s(t.formdata(s.date))+" ")])]),n("div",{staticClass:"msg"},[t._v(t._s(s.message))])])]):n("div",{staticClass:"othermsg"},[n("div",[n("img",{attrs:{src:t.getAvatar(s.uid),alt:""}})]),n("div",{staticClass:"mine-bottom"},[n("div",{staticClass:"namefont"},[t._v(" "+t._s(s.name)+" "),n("span",[t._v(t._s(t.formdata(s.date))+" ")])]),n("div",{staticClass:"msg"},[t._v(t._s(s.message))])])])])})),0)]),n("div",{staticClass:"showcomment"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.message,expression:"message"}],attrs:{type:"text",maxlength:"20",id:"inputInfo"},domProps:{value:t.message},on:{blur:function(s){return t.forbidMove()},input:function(s){s.target.composing||(t.message=s.target.value)}}}),n("span",{on:{click:function(s){return t.send()}}},[t._v("发送")])])],1)},i=[],o=(e("b0c0"),e("498a"),e("a7ac")),r=e("8d33"),l={name:"DetailChat",components:{NavBar:o["a"],Scroll:r["a"]},data:function(){return{content:"",message:"",lists:[],ws:{},name:"",num:0,isshow:!0,isme:!1,roomid:1,uid:"",handle:{},token:""}},updated:function(){},created:function(){this.token=window.localStorage.getItem("token"),this.token||this.$router.push("/login")},methods:{forbidMove:function(){document.querySelector("#inputInfo").scrollIntoView(!1)},formdata:function(t){return this.$moment(t).fromNow()},getAvatar:function(t){return"http://47.108.153.30:8001/users/"+t+"/avatar"},backClick:function(){this.ws.close(),this.$router.back()},loadMore:function(){this.$refs.scroll.refresh()},pullingDown:function(){var t=this;this.pullingdown=!0,setTimeout((function(){t.pullingdown=!1,t.$refs.scroll.finishPullDown()}),300)},init:function(){this.ws=new WebSocket("ws://47.108.153.30:8002/"),this.ws.onopen=this.onOpen,this.ws.onmessage=this.onMessage,this.ws.onclose=this.onClose,this.ws.onerror=this.onError},enter:function(){""===this.name.trim()&&this.$router.push("/login"),this.init(),this.isShow=!1},onOpen:function(){this.ws.send(JSON.stringify({event:"enter",message:this.name,roomid:this.roomid,uid:this.uid,date:new Date}))},onMessage:function(t){var s=this;if(!this.isShow){var e=JSON.parse(t.data);switch(e.event){case"enter":e.size=0,this.lists.push(e);break;case"out":e.size=3,this.lists.push(e);break;case"heartbeat":this.ws.send(JSON.stringify({event:"heartbeat",message:"pong"}));break;default:e.name!==this.name&&(e.size=2,this.lists.push(e))}this.num=e.num,this.$nextTick((function(){var t=document.querySelectorAll("li");if(t[t.length-1].offsetTop+49>s.$refs.scroll.$el.clientHeight){var e=t[t.length-1].offsetTop+49-s.$refs.scroll.$el.clientHeight;s.$refs.scroll.scrollTo(0,-e,100),s.$refs.scroll.refresh()}}),0)}},onClose:function(){this.ws.close()},onError:function(){var t=this;setTimeout((function(){t.init()}),1e3)},send:function(){var t=this,s={name:this.name,message:this.message,size:1,date:new Date,uid:this.uid};this.lists.push(s),this.$nextTick((function(){var s=document.querySelectorAll("li");if(s[s.length-1].offsetTop+49>t.$refs.scroll.$el.clientHeight){var e=s[s.length-1].offsetTop+49-t.$refs.scroll.$el.clientHeight;t.$refs.scroll.scrollTo(0,-e,100),t.$refs.scroll.refresh()}}),0),this.ws.send(JSON.stringify({event:"message",message:this.message,name:this.name,uid:this.uid,date:new Date})),this.message=""},checkServer:function(){var t=this;clearTimeout(this.handle),this.handle=setTimeout((function(){t.onClose(),setTimeout((function(){t.init()}),1e3)}),31e3)}},mounted:function(){this.name=window.localStorage.getItem("name"),this.uid=window.localStorage.getItem("userId");var t=this;t.enter()}},a=l,c=(e("7040"),e("2877")),u=Object(c["a"])(a,n,i,!1,null,"8ea6cd00",null);s["default"]=u.exports},"5aa0":function(t,s,e){t.exports=e.p+"img/back.8059563a.svg"},7040:function(t,s,e){"use strict";var n=e("4ab9"),i=e.n(n);i.a},"8d33":function(t,s,e){"use strict";var n=function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("div",{ref:"wrapper",staticClass:"wrapper"},[e("div",{staticClass:"content"},[t._t("default")],2)])},i=[],o=(e("a9e3"),e("f40f")),r={name:"Scroll",props:{probeType:{type:Number,default:0},pullUpLoad:{type:Boolean,default:!1},pullDownLoad:{type:Boolean,default:!1}},data:function(){return{scroll:null}},mounted:function(){var t=this;this.$nextTick((function(){t.scroll=new o["a"](t.$refs.wrapper,{click:!0,probeType:t.probeType,pullUpLoad:{threshold:80,stop:80},useTransition:!1,pullDownRefresh:{threshold:40,stop:30},disableMouse:!1,disableTouch:!1}),t.scroll.on("scroll",(function(s){t.$emit("scrollw",s)})),t.scroll.on("pullingUp",(function(){t.$emit("pullingUp")})),t.scroll.on("pullingDown",(function(){t.$emit("pullingDown")})),t.scroll.scrollTo(0,0)}))},methods:{scrollTo:function(t,s){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3;this.scroll&&this.scroll.scrollTo(t,s,e)},finishPullUp:function(){this.refresh(),this.scroll&&this.scroll.finishPullUp()},finishPullDown:function(){this.refresh(),this.scroll&&this.scroll.finishPullDown()},refresh:function(){this.scroll&&this.scroll.refresh()},getScrollY:function(){return this.scroll?this.scroll.y:0}}},l=r,a=e("2877"),c=Object(a["a"])(l,n,i,!1,null,"62c7f78a",null);s["a"]=c.exports},b0c0:function(t,s,e){var n=e("83ab"),i=e("9bf2").f,o=Function.prototype,r=o.toString,l=/^\s*function ([^ (]*)/,a="name";n&&!(a in o)&&i(o,a,{configurable:!0,get:function(){try{return r.call(this).match(l)[1]}catch(t){return""}}})},c8d2:function(t,s,e){var n=e("d039"),i=e("5899"),o="…";t.exports=function(t){return n((function(){return!!i[t]()||o[t]()!=o||i[t].name!==t}))}}}]);
//# sourceMappingURL=chunk-2ecb4718.89d81ee7.js.map