bztang-admin/addons/yun_shop/static/app/js/chunk-5d49da85.371add7b.js

3 lines
16 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5d49da85"],{"0215":function(t,e,n){var a=n("24fb");e=a(!1),e.push([t.i,".content[data-v-1f096c97]{background:#fff}",""]),t.exports=e},"17a0":function(t,e,n){var a=n("0215");a.__esModule&&(a=a.default),"string"===typeof a&&(a=[[t.i,a,""]]),a.locals&&(t.exports=a.locals);var i=n("499e").default;i("32c854a8",a,!0,{sourceMap:!1,shadowMode:!1})},"1da1":function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));n("d3b7");function a(t,e,n,a,i,r,o){try{var c=t[r](o),s=c.value}catch(l){return void n(l)}c.done?e(s):Promise.resolve(s).then(a,i)}function i(t){return function(){var e=this,n=arguments;return new Promise((function(i,r){var o=t.apply(e,n);function c(t){a(o,i,r,c,s,"next",t)}function s(t){a(o,i,r,c,s,"throw",t)}c(void 0)}))}}},"5ff5":function(t,e,n){"use strict";n("17a0")},aab3:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("d-title",[t._v("会话列表")]),t.isEmployee?a("van-tabs",{model:{value:t.pageTabActiveIndex,callback:function(e){t.pageTabActiveIndex=e},expression:"pageTabActiveIndex"}},[a("van-tab",{attrs:{title:"客户聊天"}},[t.chatListPagination.finished&&0==t.employeeChatList.length?a("div",{staticClass:"blank"},[a("img",{attrs:{src:n("22af")}}),a("span",[t._v("还没有记录哦")])]):t._e(),a("div",{staticClass:"content"},[a("van-list",{attrs:{finished:t.employeeChatPagination.finished,showStatusText:!1,"immediate-check":!1},on:{load:t.getEmployeeChatData},model:{value:t.employeeChatPagination.loading,callback:function(e){t.$set(t.employeeChatPagination,"loading",e)},expression:"employeeChatPagination.loading"}},t._l(t.employeeChatList,(function(e){return a("div",{key:e.id,on:{click:function(n){return t.enterEmployeeChatPage(e)}}},[a("ChatListItem",{attrs:{item:e}})],1)})),0)],1)]),a("van-tab",{attrs:{title:"我的聊天"}})],1):t._e(),1==t.pageTabActiveIndex||0==t.isEmployee?[a("div",[t.chatListPagination.finished&&0==t.chatList.length?a("div",{staticClass:"blank"},[a("img",{attrs:{src:n("22af")}}),a("span",[t._v("还没有记录哦")])]):t._e(),a("div",{staticClass:"content"},[a("van-list",{attrs:{finished:t.chatListPagination.finished,showStatusText:!1,"immediate-check":!1},on:{load:t.getChatData},model:{value:t.chatListPagination.loading,callback:function(e){t.$set(t.chatListPagination,"loading",e)},expression:"chatListPagination.loading"}},t._l(t.chatList,(function(e){return a("div",{key:e.id,on:{click:function(n){return t.enterChatPage(e)}}},[a("ChatListItem",{attrs:{item:e}})],1)})),0)],1)])]:t._e()],2)},i=[],r=n("2909"),o=(n("e7e5"),n("d399")),c=n("c7eb"),s=(n("9a83"),n("f564")),l=n("1da1"),u=(n("99af"),n("d3b7"),n("159b"),n("4de4"),n("e9c4"),n("640b")),h=n("f773"),f=null,d=!1,p=0,g=!1,v="plugin.yun-chat.frontend.h5.chat.get-list",y=null,m=null,b={},L=0,w=null,_=11,C=null,x=!1,P={data:function(){return{isLoading:!1,pageTabActiveIndex:0,chatListSets:null,chatList:[],chatListPagination:{pages:1,finished:!1,loading:!1},isEmployee:!1,employeeChatList:[],employeeChatPagination:{pages:1,finished:!1,loading:!1}}},activated:function(){var t=this;return Object(l["a"])(Object(c["a"])().mark((function e(){return Object(c["a"])().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,t.getSetData();case 2:return t.getWebscoketConfig(),t.employeeChatPagination={pages:1,finished:!1,loading:!1},t.getEmployeeChatData(),t.chatListPagination["finished"]=!1,t.chatListPagination["loading"]=!1,t.chatListPagination["pages"]=1,d=!1,e.next=11,t.getChatData();case 11:t.loopGetChatData(),window.onoffline=function(){clearInterval(f),y&&(y.close(),y=null),f=null,x=!0,Object(s["a"])("网络连接异常")},window.ononline=function(){!0===x&&(Object(s["a"])({type:"primary",message:"网络连接恢复"}),t.loopGetChatData(),t.socketInit())};case 14:case"end":return e.stop()}}),e)})))()},deactivated:function(){clearInterval(C),C=null,clearInterval(w),w=null,clearInterval(f),f=null,this.chatList=[],this.chatListPagination={pages:1,finished:!1,loading:!1},this.employeeChatPagination={pages:1,finished:!1,loading:!1},this.employeeChatList=[],y&&(y.close(),y=null)},destroyed:function(){clearInterval(C),C=null,clearInterval(w),w=null,clearInterval(f),f=null,y&&(y.close(),y=null)},methods:{getWebscoketConfig:function(){var t=this;this.isEmployee&&$http.get("plugin.yun-chat.frontend.chat.get-ws-setting").then((function(e){var n=e.data,a=e.result,i=e.msg;a?(b=n.wss_params,m="".concat(b.host,"?appId=").concat(b.appId,"&signature=").concat(b.signature,"&nonceStr=").concat(b.nonceStr,"&timestamp=").concat(b.timestamp,"&clientid=").concat(b.clientid,"&agent_id=").concat(b.agent_id),t.socketInit()):Object(o["a"])(i)}))},getSetData:function(){var t=this;return Object(l["a"])(Object(c["a"])().mark((function e(){return Object(c["a"])().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,n){$http.get("plugin.yun-chat.frontend.h5.chat.get-list-setting",{},"加载中").then((function(a){a.result?(t.chatListSets=a.data,a.data.employee_id>0&&(t.isEmployee=!0),e(a.data)):n(a)})).catch((function(t){return t}))}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))()},getChatData:function(){var t=arguments,e=this;return Object(l["a"])(Object(c["a"])().mark((function n(){var a,i;return Object(c["a"])().wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(a=t.length>0&&void 0!==t[0]&&t[0],d){n.next=4;break}if(!e.chatListPagination.finished&&!e.chatListPagination.loading){n.next=4;break}return n.abrupt("return");case 4:return i=e.chatListPagination.pages,d?i=1:e.chatListPagination.loading=!0,n.next=8,$http.get(v,{page:i}).then((function(t){var n=t.data,i=n.data,c=n.per_page,s=n.current_page,l=n.last_page,u=t.msg,h=t.result;if(e.chatListPagination.loading=!1,e.chatListPagination.finished=!0,0!==h){var f;if(e.chatList.length>0)if(a)i.forEach((function(t){for(var n=!0,a=0;a<e.chatList.length;a++){var i=e.chatList[a];i.id==t.id&&(e.chatList[a].last_chat_content=t.last_chat_content,e.chatList[a].updated_at=t.updated_at,e.chatList[a].un_read_num=t.un_read_num,n=!1)}n&&e.chatList.unshift(t)}));else(f=e.chatList).push.apply(f,Object(r["a"])(i));else e.chatList=i;d?(d=!1,g=!1):(i.length<c||s==l?e.chatListPagination.finished=!0:e.chatListPagination.finished=!1,e.chatListPagination.pages++)}else Object(o["a"])(u)})).catch((function(t){e.employeeChatPagination.loading=!1}));case 8:case"end":return n.stop()}}),n)})))()},loopGetChatData:function(){var t=this;clearInterval(f),f=null,p=0,null===f?f=setInterval((function(){!1===g&&(d=!0,t.getChatData(!0),p++,p>=100&&(clearInterval(f),f=null))}),8e3):p=0},getEmployeeChatData:function(){var t=this;!1===this.isEmployee||this.employeeChatPagination.finished||this.isLoading||(this.isLoading=!0,this.employeeChatPagination.loading=!0,$http.get("plugin.yun-chat.frontend.chat.get-list",{page:this.employeeChatPagination.pages}).then((function(e){var n,a=e.data,i=a.data,c=a.per_page,s=a.current_page,l=a.last_page,u=e.msg,h=e.result;t.employeeChatPagination.loading=!1,t.isLoading=!1,0===h&&Object(o["a"])(u),(i.length<c||s==l)&&(t.employeeChatPagination.finished=!0),(n=t.employeeChatList).push.apply(n,Object(r["a"])(i)),t.employeeChatPagination.pages++})).catch((function(e){t.isLoading=!1,t.employeeChatPagination.loading=!1})))},enterChatPage:function(t){this.$router.push(this.fun.getUrl("chatWindow",{},{groupId:t.group_id,employeeId:t.employee_id,chatType:1}))},enterEmployeeChatPage:function(t){this.$router.push(this.fun.getUrl("chatWindow",{},{user_id:t.uid,chatType:2}))},socketInit:function(){var t=this;null===y&&(y=new WebSocket(m),y.onmessage=function(e){var n=JSON.parse(e.data);if(n.uid){var a=t.employeeChatList.filter((function(t){return t.uid==n["uid"]}));if(a.length>0){switch(a=a[0],n["content_type"]){case 0:a["last_chat_content"]=n["data"];break;case 1:a["last_chat_content"]="[图片]";break;case 2:a["last_chat_content"]="[商品]";break;case 3:a["last_chat_content"]="[订单]";break}a["un_read_num"]++,a["updated_at"]=n["time"];for(var i=!0,r=0;r<t.employeeChatList.length;r++){var o=t.employeeChatList[r];o.id==a.id&&(t.employeeChatList[r].last_chat_content=a.last_chat_content,t.employeeChatList[r].updated_at=a.updated_at,t.employeeChatList[r].un_read_num=a.un_read_num,i=!1)}i&&t.employeeChatList.unshift(a)}}},y.onerror=function(e){y.close(),y=null,L>=_?(clearInterval(w),w=null,Object(s["a"])("网路连接不可用")):t.socketReconnet()},y.onopen=function(){t.checkSocketConnectState()},y.close=function(){clearInterval(C),C=null})},socketReconnet:function(){var t=this;if(null===w)return L>=_?(clearInterval(w),w=null,void Object(s["a"])("网路连接不可用")):void(w=setInterval((function(){L++,t.socketInit()}),5e3))},checkSocketConnectState:function(){var t=this;null===C&&(C=setInterval((function(){y?1==y.readyState?(y.send(JSON.stringify({type:"ping"})),L=0):(clearInterval(C),C=null,y.close(),t.socketReconnet()):(clearInterval(C),C=null)}),5e3))}},components:{DTitle:h["a"],ChatListItem:u["f"]}},k=P,I=(n("5ff5"),n("2877")),E=Object(I["a"])(k,a,i,!1,null,"1f096c97",null);e["default"]=E.exports},c7eb:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));n("a4d3"),n("e01a"),n("d3b7"),n("d28b"),n("3ca3"),n("ddb0"),n("b636"),n("944a"),n("0c47"),n("23dc"),n("d9e2"),n("3410"),n("159b"),n("b0c0"),n("131a"),n("fb6a");var a=n("53ca");function i(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
i=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(E){l=function(t,e,n){return t[e]=n}}function u(t,e,n,a){var i=e&&e.prototype instanceof d?e:d,r=Object.create(i.prototype),o=new P(a||[]);return r._invoke=function(t,e,n){var a="suspendedStart";return function(i,r){if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===i)throw r;return I()}for(n.method=i,n.arg=r;;){var o=n.delegate;if(o){var c=_(o,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var s=h(t,e,n);if("normal"===s.type){if(a=n.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a="completed",n.method="throw",n.arg=s.arg)}}}(t,n,o),r}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(E){return{type:"throw",arg:E}}}t.wrap=u;var f={};function d(){}function p(){}function g(){}var v={};l(v,o,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(k([])));m&&m!==e&&n.call(m,o)&&(v=m);var b=g.prototype=d.prototype=Object.create(v);function L(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function i(r,o,c,s){var l=h(t[r],t,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Object(a["a"])(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,c,s)}),(function(t){i("throw",t,c,s)})):e.resolve(f).then((function(t){u.value=t,c(u)}),(function(t){return i("throw",t,c,s)}))}s(l.arg)}var r;this._invoke=function(t,n){function a(){return new e((function(e,a){i(t,n,e,a)}))}return r=r?r.then(a,a):a()}}function _(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator["return"]&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var a=h(n,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,f;var i=a.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function e(){for(;++a<t.length;)if(n.call(t,a))return e.value=t[a],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return p.prototype=g,l(b,"constructor",g),l(g,"constructor",p),p.displayName=l(g,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,l(t,s,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},L(w.prototype),l(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,a,i,r){void 0===r&&(r=Promise);var o=new w(u(e,n,a,i),r);return t.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},L(b),l(b,s,"Generator"),l(b,o,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var a=e.pop();if(a in t)return n.value=a,n.done=!1,n}return n.done=!0,n}},t.values=k,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function a(n,a){return o.type="throw",o.arg=t,e.next=n,a&&(e.method="next",e.arg=void 0),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i],o=r.completion;if("root"===r.tryLoc)return a("end");if(r.tryLoc<=this.prev){var c=n.call(r,"catchLoc"),s=n.call(r,"finallyLoc");if(c&&s){if(this.prev<r.catchLoc)return a(r.catchLoc,!0);if(this.prev<r.finallyLoc)return a(r.finallyLoc)}else if(c){if(this.prev<r.catchLoc)return a(r.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return a(r.finallyLoc)}}}},abrupt:function(t,e){for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=t,o.arg=e,r?(this.method="next",this.next=r.finallyLoc,f):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),x(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var a=n.completion;if("throw"===a.type){var i=a.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:k(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}}}]);