| 1 |
- require('../../common/vendor.js');(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["bundle/pages/service/service"],{"1c19":function(e,t,n){e.exports={red_theme:"#FF2C3C",orange_theme:"#f7971e",pink_theme:"#fa444d",gold_theme:"#e0a356",blue_theme:"#2f80ed",green_theme:"#2ec840"}},2194:function(e,t,n){"use strict";n.r(t);var o=n("6850"),i=n.n(o);for(var r in o)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(r);t["default"]=i.a},"4b07":function(e,t,n){"use strict";n.r(t);var o=n("ee15"),i=n("2194");for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);n("50af");var s=n("828b"),a=Object(s["a"])(i["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],void 0);t["default"]=a.exports},"50af":function(e,t,n){"use strict";var o=n("1c19"),i=n.n(o);i.a},6850:function(e,t,n){"use strict";(function(e){var o=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=o(n("7eb4")),r=o(n("af34")),s=o(n("34cf")),a=o(n("ee10")),c=o(n("2f3b")),u=n("e585"),f=n("7398"),d=n("9ac1"),l=(n("8f59"),{components:{emoji:function(){Promise.all([n.e("bundle/common/vendor"),n.e("bundle/components/emoji/emoji")]).then(function(){return resolve(n("178d"))}.bind(null,n)).catch(n.oe)}},data:function(){return{pageStatus:"loading",scrollTop:"",intoView:"",page:1,msg:"",socket:{},kefu:{},showEmoji:!1,recoreds:[],errorMsg:"",goodsInfo:{},isError:!1,showGoods:!1,showIndex:-1}},computed:{timeFormat:function(){var e=this;return function(t,n){var o=(0,d.timeFormatChat)(t.create_time_stamp);return n&&t.create_time_stamp-e.recoreds[n-1].create_time_stamp<300&&!t.show_time&&(o=""),o}},replaceEmoji:function(){return function(e){return e.replace(/\[em-([a-z_]+)\]/g,'<span class="em em-$1"></span>')}}},watch:{kefu:function(e){e.id&&this.setTitle(e.nickname)}},methods:{init:function(){var e=this;this.socket=new c.default(this.appConfig.ws_domain,{token:this.$store.getters.token,type:"user",terminal:this.$store.state.app.client}),this.socket.addEvent("connect",(function(){e.setTitle("连接中...")})),this.socket.addEvent("open",(function(){e.setTitle(e.kefu.nickname),e.isError=!1})),this.socket.addEvent("message",(function(t){switch(t.event){case"login":e.loginEvent(t.data);break;case"chat":e.chatEvent(t.data);break;case"transfer":e.transferEvent(t.data);break;case"error":e.errorEvent(t.data);break}})),this.socket.addEvent("error",(function(t){e.setTitle("连接失败")}))},showTips:function(t){var n=this;e.showModal({title:"温馨提示",content:"客服未配置正确,请稍后再试",success:function(e){(e.confirm||e.cancel)&&n.$Router.back()}})},getConfig:function(){return(0,u.apiChatConfig)().then((function(e){return Promise.resolve(e)})).catch((function(e){return Promise.reject(e)}))},getData:function(){var e=this;return(0,a.default)(i.default.mark((function t(){return i.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.getConfig();case 3:return t.sent,t.next=6,e.getChatRecord();case 6:if(e.getGoods(),e.scrollToBottom(),e.kefu.id){t.next=11;break}return e.setTitle("客服不在线"),t.abrupt("return");case 11:e.socket.connect(),t.next=18;break;case 14:t.prev=14,t.t0=t["catch"](0),console.log("err=>系统客服异常",t.t0),e.showTips(t.t0);case 18:case"end":return t.stop()}}),t,null,[[0,14]])})))()},getGoods:function(){var e=this,t=this.$Route.query,n=t.goods_id,o=t.type,i=t.activity_id;n&&(0,u.apiChatGoods)({goods_id:n,type:o,activity_id:i}).then((function(t){e.goodsInfo=t,e.kefu.id&&(e.showGoods=!0)}))},previewImage:function(t){e.previewImage({urls:[t]})},uploadFile:function(){var t=this;return(0,a.default)(i.default.mark((function n(){var o,r,a,c,u;return i.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return n.next=2,e.chooseImage({count:1});case 2:if(o=n.sent,r=(0,s.default)(o,2),a=r[0],c=r[1],!a){n.next=8;break}return n.abrupt("return");case 8:return e.showLoading({title:"上传中..."}),n.prev=9,n.next=12,(0,f.uploadFile)(c.tempFilePaths[0]);case 12:u=n.sent,t.send(u.url,2),e.hideLoading(),n.next=21;break;case 17:n.prev=17,n.t0=n["catch"](9),t.$toast({title:"上传失败,请稍后再试"}),e.hideLoading();case 21:case"end":return n.stop()}}),n,null,[[9,17]])})))()},sendText:function(){this.msg&&(this.send(this.msg,1),this.msg="")},sendGoods:function(){this.showGoods=!1;var e=this.$Route.query,t=e.goods_id,n=e.type,o=e.activity_id;this.send({goods_id:t,type:n,activity_id:o},3)},getChatRecord:function(){var e=this;return(0,a.default)(i.default.mark((function t(){var n,o,s,a,c,f,d;return i.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(o=e.page,s=e.pageStatus,"finish"!=s){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,(0,u.apiChatRecord)({page_no:o});case 5:a=t.sent,c=0,e.page++,f=a.kefu,d=a.record,e.kefu=f,e.showIndex=d.lists.length,e.recoreds.length&&(c=e.recoreds[0].id,e.recoreds[0].show_time=!0),(n=e.recoreds).unshift.apply(n,(0,r.default)(d.lists)),e.$nextTick((function(){d.more||(e.pageStatus="finish"),e.scrollToItem(c),e.showIndex=-1}));case 14:case"end":return t.stop()}}),t)})))()},send:function(e,t){this.socket.send({event:"chat",data:{msg:e,msg_type:t,to_id:this.kefu.id,to_type:"kefu"}})},handleEmojiShow:function(){var e=this;this.showEmoji=!this.showEmoji,this.showEmoji&&setTimeout((function(){e.scrollToBottom()}),300)},scrollToupper:function(){this.getChatRecord()},scrollToBottom:function(){var e=this;this.intoView="bottom",this.$nextTick((function(){e.intoView=""}))},scrollToItem:function(e){var t=this;this.intoView="chat-item_".concat(e),this.$nextTick((function(){t.intoView=""}))},handleEmojiInput:function(e){this.msg=this.msg+e},chatEvent:function(t){var n=this;this.isError=!1,"kefu"==t.from_type&&e.vibrateLong({success:function(){console.log("success")}}),this.recoreds.push(t),this.$nextTick((function(){(0,f.getRect)("#bottom").then((function(e){e.bottom<1e3&&n.scrollToItem(t.id)}))}))},errorEvent:function(e){var t=this;this.errorMsg=e.msg,this.isError=!0,this.$nextTick((function(){t.scrollToBottom()}))},loginEvent:function(e){this.socket.send({event:"user_online",data:{kefu_id:this.kefu.id}})},transferEvent:function(e){this.kefu=e},setTitle:function(t){e.setNavigationBarTitle({title:t})}},onLoad:function(){var e=this;return(0,a.default)(i.default.mark((function t(){return i.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:e.scrollToupper=(0,f.debounce)(e.scrollToupper,500,e),e.init(),e.getData();case 3:case"end":return t.stop()}}),t)})))()},onUnload:function(){this.socket.close()},onReady:function(){}});t.default=l}).call(this,n("df3c")["default"])},c80e:function(e,t,n){"use strict";(function(e,t){var o=n("47a9");n("b46f");o(n("3240"));var i=o(n("4b07"));e.__webpack_require_UNI_MP_PLUGIN__=n,t(i.default)}).call(this,n("3223")["default"],n("df3c")["createPage"])},ee15:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){return o}));var o={uLoading:function(){return n.e("components/uview-ui/components/u-loading/u-loading").then(n.bind(null,"527f"))},price:function(){return n.e("components/price/price").then(n.bind(null,"1266"))},uIcon:function(){return n.e("components/uview-ui/components/u-icon/u-icon").then(n.bind(null,"1340"))},uImage:function(){return n.e("components/uview-ui/components/u-image/u-image").then(n.bind(null,"566d"))}},i=function(){var e=this,t=e.$createElement,n=(e._self._c,e.__map(e.recoreds,(function(t,n){var o=e.__get_orig(t),i=1==t.type?e.timeFormat(t,n):null,r=1==t.type&&i?e.timeFormat(t,n):null,s=1==t.type?e.$getImageUri(t.from_avatar):null,a=1==t.type&&1==t.msg_type?e.replaceEmoji(t.msg):null,c=1==t.type&&2==t.msg_type?e.$getImageUri(t.msg):null,u=1==t.type&&2==t.msg_type?e.$getImageUri(t.msg):null,f=1==t.type&&3==t.msg_type?e.$getImageUri(t.goods.image):null;return{$orig:o,m0:i,m1:r,m2:s,m3:a,m4:c,m5:u,m6:f}})));e._isMounted||(e.e0=function(t){e.showEmoji=!1},e.e1=function(t){e.showGoods=!1},e.e2=function(t){e.showGoods=!1}),e.$mp.data=Object.assign({},{$root:{l0:n}})},r=[]}},[["c80e","common/runtime","common/vendor","bundle/common/vendor"]]]);
|