Commit ee74ac5c by chenxianqi

updatecode

parent f64ed92d
......@@ -28,6 +28,7 @@ func Run() {
orm.RegisterModel(new(models.KnowledgeBase))
orm.RegisterModel(new(models.Robot))
orm.RegisterModel(new(models.Message))
orm.RegisterModel(new(models.MessageHistory))
orm.RegisterModel(new(models.System))
orm.RegisterModel(new(models.Shortcut))
orm.RegisterModel(new(models.Contact))
......
......@@ -11,7 +11,7 @@ package models
// 7 pong 对方正在输入中
// 8 end 结束消息
// 9 timeout 超时会话关闭
// 10 cancel 撤回消息(暂时还没做预留先)
// 10 cancel 撤回消息
// 11 contacts 用户列表(客服端)
// 12 welcome 欢迎语
// 13 system 系统消息
......@@ -24,6 +24,7 @@ type Message struct {
BizType string `orm:"type(char);column(biz_type)" json:"biz_type"` // 消息类型
Version string `orm:"default(0);type(char);column(version)" json:"version"` // 版本号,预留暂时无用
Timestamp int64 `orm:"type(bigint);column(timestamp)" json:"timestamp"` // 服务端消息消息时间
Sequence int64 `orm:"type(bigint);column(sequence)" json:"sequence"` // 消息入库时间
Key int64 `orm:"type(bigint);column(key)" json:"key"` // key
TransferAccount int64 `orm:"type(bigint);column(transfer_account)" json:"transfer_account"` // 转接到客户的账号
Platform int64 `orm:"type(bigint);column(platform)" json:"platform"` // 此消息来自哪个平台(即渠道)
......
package models
// MessageHistory struct
// BizType 消息类型 先以字符串形式声明吧
// 1 video 视频
// 2 text 文本
// 3 photo 图片
// 4 transfer 转接
// 5 knowledge 知识内容
// 6 handshake 用户请求与握手
// 7 pong 对方正在输入中
// 8 end 结束消息
// 9 timeout 超时会话关闭
// 10 cancel 撤回消息
// 11 contacts 用户列表(客服端)
// 12 welcome 欢迎语
// 13 system 系统消息
// 14 search_knowledge 检索关键词知识库消息
// 15 key 消息key
type MessageHistory struct {
ID int64 `orm:"auto;pk;column(id)" json:"id"` // 消息ID
FromAccount int64 `orm:"type(bigint);column(from_account)" json:"from_account"` // 发送人账号
ToAccount int64 `orm:"type(bigint);column(to_account)" json:"to_account"` // 接收人账号
BizType string `orm:"type(char);column(biz_type)" json:"biz_type"` // 消息类型
Version string `orm:"default(0);type(char);column(version)" json:"version"` // 版本号,预留暂时无用
Timestamp int64 `orm:"type(bigint);column(timestamp)" json:"timestamp"` // 服务端消息消息时间
Sequence int64 `orm:"type(bigint);column(sequence)" json:"sequence"` // 消息入库时间
Key int64 `orm:"type(bigint);column(key)" json:"key"` // key
TransferAccount int64 `orm:"type(bigint);column(transfer_account)" json:"transfer_account"` // 转接到客户的账号
Platform int64 `orm:"type(bigint);column(platform)" json:"platform"` // 此消息来自哪个平台(即渠道)
Payload string `orm:"null;type(text);column(payload)" json:"payload"` // 消息内容
Read int `orm:"default(0);column(read)" json:"read"` // 是否已读消息0已读1未读
}
......@@ -43,4 +43,4 @@
top:0 !important;
min-height: inherit!important;
left:0 !important; right:0 !important; bottom:0 !important; margin: auto !important;
}</style><link href=css/chunk-5853fee7.c946f43e.css rel=prefetch><link href=css/chunk-5abde09c.21a06077.css rel=prefetch><link href=css/chunk-5e6009ff.86cb9867.css rel=prefetch><link href=css/chunk-fc784ea6.548345db.css rel=prefetch><link href=js/chunk-5853fee7.2146cb38.js rel=prefetch><link href=js/chunk-5abde09c.95818801.js rel=prefetch><link href=js/chunk-5e6009ff.ea6c5b91.js rel=prefetch><link href=js/chunk-fc784ea6.1fe629b4.js rel=prefetch><link href=css/app.19de1655.css rel=preload as=style><link href=css/chunk-vendors.5cea36ab.css rel=preload as=style><link href=js/app.4b73fc40.js rel=preload as=script><link href=js/chunk-vendors.a823ad66.js rel=preload as=script><link href=css/chunk-vendors.5cea36ab.css rel=stylesheet><link href=css/app.19de1655.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.a823ad66.js></script><script src=js/app.4b73fc40.js></script></body></html>
\ No newline at end of file
}</style><link href=css/chunk-5853fee7.c946f43e.css rel=prefetch><link href=css/chunk-5abde09c.21a06077.css rel=prefetch><link href=css/chunk-5e6009ff.86cb9867.css rel=prefetch><link href=css/chunk-fc784ea6.548345db.css rel=prefetch><link href=js/chunk-5853fee7.2146cb38.js rel=prefetch><link href=js/chunk-5abde09c.95818801.js rel=prefetch><link href=js/chunk-5e6009ff.1088ebcb.js rel=prefetch><link href=js/chunk-fc784ea6.1fe629b4.js rel=prefetch><link href=css/app.19de1655.css rel=preload as=style><link href=css/chunk-vendors.5cea36ab.css rel=preload as=style><link href=js/app.2783e17d.js rel=preload as=script><link href=js/chunk-vendors.a823ad66.js rel=preload as=script><link href=css/chunk-vendors.5cea36ab.css rel=stylesheet><link href=css/app.19de1655.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.a823ad66.js></script><script src=js/app.2783e17d.js></script></body></html>
\ No newline at end of file
(function(e){function t(t){for(var a,r,c=t[0],i=t[1],u=t[2],l=0,f=[];l<c.length;l++)r=c[l],Object.prototype.hasOwnProperty.call(o,r)&&o[r]&&f.push(o[r][0]),o[r]=0;for(a in i)Object.prototype.hasOwnProperty.call(i,a)&&(e[a]=i[a]);d&&d(t);while(f.length)f.shift()();return s.push.apply(s,u||[]),n()}function n(){for(var e,t=0;t<s.length;t++){for(var n=s[t],a=!0,r=1;r<n.length;r++){var c=n[r];0!==o[c]&&(a=!1)}a&&(s.splice(t--,1),e=i(i.s=n[0]))}return e}var a={},r={app:0},o={app:0},s=[];function c(e){return i.p+"js/"+({}[e]||e)+"."+{"chunk-5853fee7":"2146cb38","chunk-5abde09c":"95818801","chunk-5e6009ff":"ea6c5b91","chunk-fc784ea6":"1fe629b4"}[e]+".js"}function i(t){if(a[t])return a[t].exports;var n=a[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.e=function(e){var t=[],n={"chunk-5853fee7":1,"chunk-5abde09c":1,"chunk-5e6009ff":1,"chunk-fc784ea6":1};r[e]?t.push(r[e]):0!==r[e]&&n[e]&&t.push(r[e]=new Promise((function(t,n){for(var a="css/"+({}[e]||e)+"."+{"chunk-5853fee7":"c946f43e","chunk-5abde09c":"21a06077","chunk-5e6009ff":"86cb9867","chunk-fc784ea6":"548345db"}[e]+".css",o=i.p+a,s=document.getElementsByTagName("link"),c=0;c<s.length;c++){var u=s[c],l=u.getAttribute("data-href")||u.getAttribute("href");if("stylesheet"===u.rel&&(l===a||l===o))return t()}var f=document.getElementsByTagName("style");for(c=0;c<f.length;c++){u=f[c],l=u.getAttribute("data-href");if(l===a||l===o)return t()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=t,d.onerror=function(t){var a=t&&t.target&&t.target.src||o,s=new Error("Loading CSS chunk "+e+" failed.\n("+a+")");s.code="CSS_CHUNK_LOAD_FAILED",s.request=a,delete r[e],d.parentNode.removeChild(d),n(s)},d.href=o;var p=document.getElementsByTagName("head")[0];p.appendChild(d)})).then((function(){r[e]=0})));var a=o[e];if(0!==a)if(a)t.push(a[2]);else{var s=new Promise((function(t,n){a=o[e]=[t,n]}));t.push(a[2]=s);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=c(e);var f=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(d);var n=o[e];if(0!==n){if(n){var a=t&&("load"===t.type?"missing":t.type),r=t&&t.target&&t.target.src;f.message="Loading chunk "+e+" failed.\n("+a+": "+r+")",f.name="ChunkLoadError",f.type=a,f.request=r,n[1](f)}o[e]=void 0}};var d=setTimeout((function(){u({type:"timeout",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=a,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)i.d(n,a,function(t){return e[t]}.bind(null,a));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i.oe=function(e){throw console.error(e),e};var u=window["webpackJsonp"]=window["webpackJsonp"]||[],l=u.push.bind(u);u.push=t,u=u.slice();for(var f=0;f<u.length;f++)t(u[f]);var d=l;s.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},4678:function(e,t,n){var a={"./af":"2bfb","./af.js":"2bfb","./ar":"8e73","./ar-dz":"a356","./ar-dz.js":"a356","./ar-kw":"423e","./ar-kw.js":"423e","./ar-ly":"1cfd","./ar-ly.js":"1cfd","./ar-ma":"0a84","./ar-ma.js":"0a84","./ar-sa":"8230","./ar-sa.js":"8230","./ar-tn":"6d83","./ar-tn.js":"6d83","./ar.js":"8e73","./az":"485c","./az.js":"485c","./be":"1fc1","./be.js":"1fc1","./bg":"84aa","./bg.js":"84aa","./bm":"a7fa","./bm.js":"a7fa","./bn":"9043","./bn.js":"9043","./bo":"d26a","./bo.js":"d26a","./br":"6887","./br.js":"6887","./bs":"2554","./bs.js":"2554","./ca":"d716","./ca.js":"d716","./cs":"3c0d","./cs.js":"3c0d","./cv":"03ec","./cv.js":"03ec","./cy":"9797","./cy.js":"9797","./da":"0f14","./da.js":"0f14","./de":"b469","./de-at":"b3eb","./de-at.js":"b3eb","./de-ch":"bb71","./de-ch.js":"bb71","./de.js":"b469","./dv":"598a","./dv.js":"598a","./el":"8d47","./el.js":"8d47","./en-SG":"cdab","./en-SG.js":"cdab","./en-au":"0e6b","./en-au.js":"0e6b","./en-ca":"3886","./en-ca.js":"3886","./en-gb":"39a6","./en-gb.js":"39a6","./en-ie":"e1d3","./en-ie.js":"e1d3","./en-il":"7333","./en-il.js":"7333","./en-nz":"6f50","./en-nz.js":"6f50","./eo":"65db","./eo.js":"65db","./es":"898b","./es-do":"0a3c","./es-do.js":"0a3c","./es-us":"55c9","./es-us.js":"55c9","./es.js":"898b","./et":"ec18","./et.js":"ec18","./eu":"0ff2","./eu.js":"0ff2","./fa":"8df4","./fa.js":"8df4","./fi":"81e9","./fi.js":"81e9","./fo":"0721","./fo.js":"0721","./fr":"9f26","./fr-ca":"d9f8","./fr-ca.js":"d9f8","./fr-ch":"0e49","./fr-ch.js":"0e49","./fr.js":"9f26","./fy":"7118","./fy.js":"7118","./ga":"5120","./ga.js":"5120","./gd":"f6b4","./gd.js":"f6b4","./gl":"8840","./gl.js":"8840","./gom-latn":"0caa","./gom-latn.js":"0caa","./gu":"e0c5","./gu.js":"e0c5","./he":"c7aa","./he.js":"c7aa","./hi":"dc4d","./hi.js":"dc4d","./hr":"4ba9","./hr.js":"4ba9","./hu":"5b14","./hu.js":"5b14","./hy-am":"d6b6","./hy-am.js":"d6b6","./id":"5038","./id.js":"5038","./is":"0558","./is.js":"0558","./it":"6e98","./it-ch":"6f12","./it-ch.js":"6f12","./it.js":"6e98","./ja":"079e","./ja.js":"079e","./jv":"b540","./jv.js":"b540","./ka":"201b","./ka.js":"201b","./kk":"6d79","./kk.js":"6d79","./km":"e81d","./km.js":"e81d","./kn":"3e92","./kn.js":"3e92","./ko":"22f8","./ko.js":"22f8","./ku":"2421","./ku.js":"2421","./ky":"9609","./ky.js":"9609","./lb":"440c","./lb.js":"440c","./lo":"b29d","./lo.js":"b29d","./lt":"26f9","./lt.js":"26f9","./lv":"b97c","./lv.js":"b97c","./me":"293c","./me.js":"293c","./mi":"688b","./mi.js":"688b","./mk":"6909","./mk.js":"6909","./ml":"02fb","./ml.js":"02fb","./mn":"958b","./mn.js":"958b","./mr":"39bd","./mr.js":"39bd","./ms":"ebe4","./ms-my":"6403","./ms-my.js":"6403","./ms.js":"ebe4","./mt":"1b45","./mt.js":"1b45","./my":"8689","./my.js":"8689","./nb":"6ce3","./nb.js":"6ce3","./ne":"3a39","./ne.js":"3a39","./nl":"facd","./nl-be":"db29","./nl-be.js":"db29","./nl.js":"facd","./nn":"b84c","./nn.js":"b84c","./pa-in":"f3ff","./pa-in.js":"f3ff","./pl":"8d57","./pl.js":"8d57","./pt":"f260","./pt-br":"d2d4","./pt-br.js":"d2d4","./pt.js":"f260","./ro":"972c","./ro.js":"972c","./ru":"957c","./ru.js":"957c","./sd":"6784","./sd.js":"6784","./se":"ffff","./se.js":"ffff","./si":"eda5","./si.js":"eda5","./sk":"7be6","./sk.js":"7be6","./sl":"8155","./sl.js":"8155","./sq":"c8f3","./sq.js":"c8f3","./sr":"cf1e","./sr-cyrl":"13e9","./sr-cyrl.js":"13e9","./sr.js":"cf1e","./ss":"52bd","./ss.js":"52bd","./sv":"5fbd","./sv.js":"5fbd","./sw":"74dc","./sw.js":"74dc","./ta":"3de5","./ta.js":"3de5","./te":"5cbb","./te.js":"5cbb","./tet":"576c","./tet.js":"576c","./tg":"3b1b","./tg.js":"3b1b","./th":"10e8","./th.js":"10e8","./tl-ph":"0f38","./tl-ph.js":"0f38","./tlh":"cf75","./tlh.js":"cf75","./tr":"0e81","./tr.js":"0e81","./tzl":"cf51","./tzl.js":"cf51","./tzm":"c109","./tzm-latn":"b53d","./tzm-latn.js":"b53d","./tzm.js":"c109","./ug-cn":"6117","./ug-cn.js":"6117","./uk":"ada2","./uk.js":"ada2","./ur":"5294","./ur.js":"5294","./uz":"2e8c","./uz-latn":"010e","./uz-latn.js":"010e","./uz.js":"2e8c","./vi":"2921","./vi.js":"2921","./x-pseudo":"fd7e","./x-pseudo.js":"fd7e","./yo":"7f33","./yo.js":"7f33","./zh-cn":"5c3a","./zh-cn.js":"5c3a","./zh-hk":"49ab","./zh-hk.js":"49ab","./zh-tw":"90ea","./zh-tw.js":"90ea"};function r(e){var t=o(e);return n(t)}function o(e){if(!n.o(a,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return a[e]}r.keys=function(){return Object.keys(a)},r.resolve=o,e.exports=r,r.id="4678"},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var a=n("2b0e"),r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[e.isShowPageLoading?n("div",{staticClass:"mini-im-loading",class:{"pc-mini-im-loading":!e.isMobile}},[n("mt-spinner",{attrs:{type:"triple-bounce",color:"#26a2ff"}})],1):e._e(),n("router-view")],1)},o=[],s=(n("8e6e"),n("ac6a"),n("456d"),n("28a5"),n("bd86")),c=n("2f62");function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){Object(s["a"])(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var l={name:"app",data:function(){return{}},computed:u({},Object(c["b"])(["isShowPageLoading","userAccount","isArtificial","isMobile","artificialAccount","robotAccount","platform","userLocal","uid","uid"])),created:function(){var e=this;this.getLocal(),setTimeout((function(){e.handelUrl(),e.runApp()}),500),this.onCheckIsOutSession()},methods:{runApp:function(){var e=this,t=this.$mimcInstance.getLocalCacheUser();t&&null!=this.userAccount&&this.userAccount!=t.id&&0!=this.userAccount&&localStorage.clear(),this.$mimcInstance.init({type:0,address:this.userLocal,uid:this.uid||0,platform:this.platform,account_id:this.userAccount||0},(function(t){if(e.upLastActivity(),e.$store.dispatch("onGetCompanyInfo"),e.$store.dispatch("onGetConfigs"),e.$store.dispatch("onGetWorkorderTypes"),e.$store.dispatch("onGetWorkorders"),t){e.$store.commit("updateState",{userAccount:t.id,userInfo:t});var n=e.$mimcInstance.robot;localStorage.setItem("robot_"+n.id,JSON.stringify(n)),e.$store.commit("updateState",{robotAccount:n.id,robotInfo:n});var a=function t(){null!=e.$mimcInstance.user&&e.$mimcInstance.user.isLogin()?e.artificialAccount||(console.log("握手消息"),e.$mimcInstance.sendMessage("handshake",e.robotAccount,"")):setTimeout((function(){return t()}),1e3)};a()}else setTimeout((function(){return e.runApp()}),1e3)}))},handelUrl:function(){var e,t,n,a,r,o,s,c,i=this.$route.query;i&&i.c&&localStorage.clear();var u=this.queryToJson(localStorage.getItem("urlQuery"));u&&(i=Object.assign({},u,i)),i&&("0"==i.h&&(e=!1),"0"==i.m&&(t=!1,e=!1),i.u&&(n=parseInt(i.u)),i.p&&(c=parseInt(i.p)),i.uid&&(a=parseInt(i.uid)),"0"==i.r?(r=!0,o=parseInt(i.a)):s=parseInt(i.a));var l=localStorage.getItem("isArtificial"),f=localStorage.getItem("artificialAccount");"true"==l&&(r=!0,o=parseInt(f)),this.$store.commit("updateState",{isShowHeader:e,isMobile:t,userAccount:n,uid:a,isArtificial:r,artificialAccount:o,robotAccount:s,platform:c})},queryToJson:function(e){if(!e||""==e)return null;var t=e.substr(1,e.length).split("&");if(!t)return null;for(var n={},a=0;a<t.length;a++){var r=t[a].split("=");n[r[0]]=r[1]}return n},getLocal:function(){this.$store.dispatch("onGetLocal",this.$store.state.AmapAPPKey)},upLastActivity:function(){var e=this;this.onCheckIsOutSession();var t=this.$mimcInstance.getLocalCacheUser();t&&this.$store.dispatch("onUpdateLastActivity"),this.isArtificial&&localStorage.setItem("artificialTime",Date.now()),setTimeout((function(){return e.upLastActivity()}),6e4)},onCheckIsOutSession:function(){var e=localStorage.getItem("artificialTime");e&&(e=parseInt(e),Date.now()>e+6e5&&this.$store.commit("updateState",{isArtificial:!1,artificialAccount:null}))}}},f=l,d=(n("7faf"),n("2877")),p=Object(d["a"])(f,r,o,!1,null,null,null),m=p.exports,h=n("d1d4"),b=n.n(h),g=n("8c4f");a["default"].use(g["a"]);var j=new g["a"]({base:"",routes:[{path:"/",redirect:"/index"},{path:"/index",name:"index",component:function(){return n.e("chunk-5e6009ff").then(n.bind(null,"e0a0"))}},{path:"/workorder",name:"workorder",component:function(){return n.e("chunk-5853fee7").then(n.bind(null,"fb09"))}},{path:"/workorder/create",name:"workorder_create",component:function(){return n.e("chunk-5abde09c").then(n.bind(null,"ede1"))}},{path:"/workorder/detail/:id",name:"workorder_detail",component:function(){return n.e("chunk-fc784ea6").then(n.bind(null,"4033"))}}]}),k=j,v=n("bc3a"),y=n.n(v),w={onGetMessages:function(e,t){var n=20;y.a.post("/public/messages",{timestamp:t.timestamp,page_size:n}).then((function(a){var r=[],o=a.data.data.list||[];(o.length<n||0==o.length)&&e.commit("updateState",{isLoadMorEnd:!0}),r=0==t.oldMsg.length&&o.length>0?a.data.data.list:o.length>0?o.concat(t.oldMsg):t.oldMsg,e.commit("updateState",{messages:r}),t.callback&&t.callback()})).catch((function(e){console.log(e)}))},onGetLocal:function(e,t){y.a.get("https://restapi.amap.com/v3/ip?key="+t).then((function(t){t.data.province&&e.commit("updateState",{userLocal:t.data.province+t.data.city})})).catch((function(e){console.error(e)}))},onCleanRead:function(){y.a.get("/public/clean_read/")},onUpdateLastActivity:function(){y.a.get("/public/activity/")},onToggleWindow:function(e,t){y.a.put("/public/window/",{window:t})},onGetCompanyInfo:function(e){y.a.get("/public/company").then((function(t){e.commit("updateState",{companyInfo:t.data.data})})).catch((function(e){console.error(e)}))},onGetConfigs:function(e){y.a.get("/public/configs").then((function(t){e.commit("updateState",{configs:t.data.data})}))},onGetWorkorderTypes:function(e){y.a.get("/public/workorder/types").then((function(t){e.commit("updateState",{workorderTypes:t.data.data})}))},onGetWorkorders:function(e){y.a.get("/public/workorders").then((function(t){e.commit("updateState",{workorders:t.data.data})}))}},_={updateState:function(e,t){var n=e;for(var a in t)void 0!=t[a]&&(n[a]=t[a]);e=n}},M=(n("4917"),{platform:function(e){return e.platform},isArtificial:function(e){return e.isArtificial},isShowHeader:function(e){return e.isShowHeader},isMobile:function(e){return e.isMobile},uid:function(e){return e.uid},userAccount:function(e){return e.userAccount},artificialAccount:function(e){return e.artificialAccount},robotInfo:function(e){return e.robotInfo},robotAccount:function(e){return e.robotAccount},isLoadMorEnd:function(e){return e.isLoadMorEnd},messages:function(e){return e.messages||[]},userLocal:function(e){return e.userLocal},isLoadMorLoading:function(e){return e.isLoadMorLoading},userInfo:function(e){return e.userInfo},companyInfo:function(e){return e.companyInfo},configs:function(e){return e.configs},isIOS:function(){return!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)},isSafari:function(){return navigator.userAgent.indexOf("Safari")>-1&&navigator.userAgent.indexOf("Chrome")<1},isJudgeBigScreen:function(){var e=!1,t=window.screen.height/window.screen.width,n=window.screen.height==window.screen.availHeight?1.8:1.65;return t>n&&(e=!0),e},isShowPageLoading:function(e){return e.isShowPageLoading},workorders:function(e){return e.workorders},workorderTypes:function(e){return e.workorderTypes}}),I={platform:5,isShowPageLoading:!1,isShowHeader:!0,isMobile:!0,isArtificial:!1,uid:0,userAccount:0,artificialAccount:null,robotInfo:null,robotAccount:null,messages:[],isLoadMorEnd:!1,userLocal:"",AmapAPPKey:"73ef1dc5c5ea086e7330b95aede42953",isLoadMorLoading:!1,userInfo:{},companyInfo:null,configs:{},workorders:[],workorderTypes:[]};a["default"].use(c["a"]);var S=new c["a"].Store({state:I,getters:M,mutations:_,actions:w}),A=(n("394c"),n("76a0")),L=n.n(A),C=(n("aa35"),n("7f7f"),n("cea2")),T=n("c1df"),O={install:function(e,t){e.prototype.$myMethod=function(){console.log(t)},e.prototype.$formatUnixDate=function(e,t){return T(parseInt(e+"000")).format(t)},e.prototype.$formatFromNowDate=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"YYYY-MM-DD HH:mm";return T().format("YYYYMMDD")==T(parseInt(e+"000")).format("YYYYMMDD")?"今天 "+T(parseInt(e+"000")).format("HH:mm"):T(parseInt(e+"000")).format(t)},e.prototype.$formatDate=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"YYYY-MM-DD HH:mm:ss";return T(parseInt(e+"000")).format(t)},e.prototype.$robotNickname=function(e){for(var t,n=this.$store.getters.robots,a=0;a<n.length;a++)n[a].id==e&&(t=n[a].nickname);return t},e.prototype.$uploadFile=function(e){var t=e.mode,n=e.secret,a=e.file,r=e.percent,o=e.success,s=e.fail,c=null,i=parseInt(1e4*Math.random()*(new Date).getTime())+a.name.substr(a.name.lastIndexOf("."));if(1==t){var u=new FormData;u.append("file",a),u.append("file_name",i),y.a.post("/public/upload",u).then((function(e){o&&o(e.data.data)})).catch((function(e){s&&s(e)}))}else if(2==t){var l={quality:.92,noCompressIfLarger:!0,maxWidth:1500};C["compressImage"](a,l).then((function(e){var t=C["upload"](e.dist,i,n,{},{mimeType:null});c=t.subscribe({next:function(e){r&&r(e)},error:function(){var e=new FormData;e.append("fileType","image"),e.append("fileName","file"),e.append("key",i),e.append("token",n),e.append("file",a),y.a.post("https://upload.qiniup.com",e).then((function(){o&&o(i)})).catch((function(e){s&&s(e)}))},complete:function(e){o&&o(e.key)}})}))}return c}}},D=O,Y=(n("6b54"),{install:function(e,t){console.log(t),e.MimcInstance=e.prototype.$mimcInstance={user:null,robot:null,platform:5,fetchMIMCTokenResult:null,_receiveP2PMsgCallback:null,_statusChangeCallback:null,_serverAckCallback:null,_disconnectCallback:null,init:function(e,t){this.platform=e.platform,this.fetchMIMCToken(e,t)},getLocalCacheUser:function(){var e=localStorage.getItem("user");return e?JSON.parse(e):null},fetchMIMCToken:function(e,t){var n=this;y.a.post("/public/register",e).then((function(e){n.fetchMIMCTokenResult=e.data.data.token,localStorage.setItem("user",JSON.stringify(e.data.data.user)),localStorage.setItem("Token",e.data.data.user.token),console.log("MIMC初始化成功"),n.getRobot((function(){t&&t(e.data.data.user)})),n.login()})).catch((function(e){t&&t(null),console.log(e)}))},getRobot:function(e){var t=this;y.a.get("/public/robot/"+this.platform).then((function(n){t.robot=n.data.data,e&&e()})).catch((function(e){console.log("mimc初始化失败,请刷新重试",e)}))},pushMessage:function(e){var t=this;y.a.post("/public/message/push",{msgType:"NORMAL_MSG",payload:e}).then((function(n){console.log(n.data),200!=n.data["code"]&&setTimeout((function(){return t.pushMessage(e)}),300)})).catch((function(){setTimeout((function(){return t.pushMessage(e)}),300)}))},login:function(e){var t=this;try{var n=this.fetchMIMCTokenResult;this.user=new MIMCUser(n.data.appId,n.data.appAccount,"666"),this.user.registerP2PMsgHandler((function(e){var n=JSON.parse(window.Base64.decode(e.getPayload()));t._receiveP2PMsgCallback&&t._receiveP2PMsgCallback(n)})),this.user.registerFetchToken((function(){return n})),this.user.registerStatusChange((function(e,n,a,r){t._statusChangeCallback&&t._statusChangeCallback(e,n,a,r)})),this.user.registerServerAckHandler((function(e,n,a,r){t._serverAckCallback&&t._serverAckCallback(e,n,a,r)})),this.user.registerDisconnHandler((function(){t._disconnectCallback&&t._disconnectCallback()})),this.user.login(),window.mimcInstance=this,e&&e(),console.log("MIMC登录成功")}catch(a){console.log("MIMC登录失败"),setTimeout((function(){t.login()}),1e3)}},logout:function(){this.user&&(this.user.logout(),this.user=null)},addEventListener:function(e,t){switch(e){case"receiveP2PMsg":this._receiveP2PMsgCallback=t;break;case"statusChange":this._statusChangeCallback=t;break;case"serverAck":this._serverAckCallback=t;break;case"disconnect":this._disconnectCallback=t;break}},sendMessage:function(e,t){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.user){var r={from_account:parseInt(this.fetchMIMCTokenResult.data.appAccount),to_account:parseInt(t),biz_type:e,version:"0",timestamp:parseInt(((new Date).getTime()+" ").substr(0,10)),key:(new Date).getTime(),read:0,platform:this.platform,transfer_account:0,payload:a+""},o=window.Base64.encode(JSON.stringify(r));return"contacts"!=e&&"pong"!=e&&"welcome"!=e&&"handshake"!=e&&"search_knowledge"!=e&&this.pushMessage(window.Base64.encode(o)),setTimeout((function(){n.user.sendMessage(t.toString(),o)}),150),r}Object(A["Toast"])({message:"服务异常,请刷新重试!"})},createLocalMessage:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r={from_account:parseInt(this.fetchMIMCTokenResult.data.appAccount),to_account:parseInt(t),biz_type:e,version:"0",platform:this.platform,timestamp:parseInt(((new Date).getTime()+" ").substr(0,10)),key:(new Date).getTime(),read:0,transfer_account:parseInt(a),payload:n+""};return r}}}}),P=Y,$={months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY年MM月DD日",LLL:"YYYY年MM月DD日Ah点mm分",LLLL:"YYYY年MM月DD日ddddAh点mm分",l:"YYYY-M-D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},meridiemParse:/凌晨|早上|上午|中午|下午|晚上/,meridiemHour:function(e,t){return 12===e&&(e=0),"凌晨"===t||"早上"===t||"上午"===t?e:"下午"===t||"晚上"===t?e+12:e>=11?e:e+12},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1130?"上午":n<1230?"中午":n<1800?"下午":"晚上"},calendar:{sameDay:"[今天]LT",nextDay:"[明天]LT",nextWeek:"[下]ddddLT",lastDay:"[昨天]LT",lastWeek:"[上]ddddLT",sameElse:"L"},dayOfMonthOrdinalParse:/\d{1,2}(日|月|周)/,ordinal:function(e,t){switch(t){case"d":case"D":case"DDD":return e+"日";case"M":return e+"月";case"w":case"W":return e+"周";default:return e}},relativeTime:{future:"%s内",past:"%s前",s:"几秒",ss:"%d秒",m:"1分钟",mm:"%d分钟",h:"1小时",hh:"%d小时",d:"1天",dd:"%d天",M:"1个月",MM:"%d个月",y:"1年",yy:"%d年"},week:{dow:1,doy:4}},z=n("c1df");z.locale("zh-cn",$),y.a.defaults.baseURL="/api",y.a.interceptors.request.use((function(e){if(-1!=e.url.indexOf("https://restapi.amap.com/v3/ip"))return e;var t=localStorage.getItem("Token")||"";return e.headers=Object.assign({},{Token:t},e.headers),e}),(function(e){return console.log(e),Promise.reject(e)}));var H={clickToCloseNonZoomable:!1,fullscreenEl:!1};a["default"].use(b.a,H),a["default"].use(D),a["default"].use(P),a["default"].use(L.a),a["default"].config.productionTip=!1,new a["default"]({router:k,store:S,render:function(e){return e(m)}}).$mount("#app")},"7faf":function(e,t,n){"use strict";var a=n("8fba"),r=n.n(a);r.a},"8fba":function(e,t,n){}});
//# sourceMappingURL=app.4b73fc40.js.map
\ No newline at end of file
(function(e){function t(t){for(var a,r,c=t[0],i=t[1],u=t[2],l=0,f=[];l<c.length;l++)r=c[l],Object.prototype.hasOwnProperty.call(o,r)&&o[r]&&f.push(o[r][0]),o[r]=0;for(a in i)Object.prototype.hasOwnProperty.call(i,a)&&(e[a]=i[a]);d&&d(t);while(f.length)f.shift()();return s.push.apply(s,u||[]),n()}function n(){for(var e,t=0;t<s.length;t++){for(var n=s[t],a=!0,r=1;r<n.length;r++){var c=n[r];0!==o[c]&&(a=!1)}a&&(s.splice(t--,1),e=i(i.s=n[0]))}return e}var a={},r={app:0},o={app:0},s=[];function c(e){return i.p+"js/"+({}[e]||e)+"."+{"chunk-5853fee7":"2146cb38","chunk-5abde09c":"95818801","chunk-5e6009ff":"1088ebcb","chunk-fc784ea6":"1fe629b4"}[e]+".js"}function i(t){if(a[t])return a[t].exports;var n=a[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.e=function(e){var t=[],n={"chunk-5853fee7":1,"chunk-5abde09c":1,"chunk-5e6009ff":1,"chunk-fc784ea6":1};r[e]?t.push(r[e]):0!==r[e]&&n[e]&&t.push(r[e]=new Promise((function(t,n){for(var a="css/"+({}[e]||e)+"."+{"chunk-5853fee7":"c946f43e","chunk-5abde09c":"21a06077","chunk-5e6009ff":"86cb9867","chunk-fc784ea6":"548345db"}[e]+".css",o=i.p+a,s=document.getElementsByTagName("link"),c=0;c<s.length;c++){var u=s[c],l=u.getAttribute("data-href")||u.getAttribute("href");if("stylesheet"===u.rel&&(l===a||l===o))return t()}var f=document.getElementsByTagName("style");for(c=0;c<f.length;c++){u=f[c],l=u.getAttribute("data-href");if(l===a||l===o)return t()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=t,d.onerror=function(t){var a=t&&t.target&&t.target.src||o,s=new Error("Loading CSS chunk "+e+" failed.\n("+a+")");s.code="CSS_CHUNK_LOAD_FAILED",s.request=a,delete r[e],d.parentNode.removeChild(d),n(s)},d.href=o;var p=document.getElementsByTagName("head")[0];p.appendChild(d)})).then((function(){r[e]=0})));var a=o[e];if(0!==a)if(a)t.push(a[2]);else{var s=new Promise((function(t,n){a=o[e]=[t,n]}));t.push(a[2]=s);var u,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=c(e);var f=new Error;u=function(t){l.onerror=l.onload=null,clearTimeout(d);var n=o[e];if(0!==n){if(n){var a=t&&("load"===t.type?"missing":t.type),r=t&&t.target&&t.target.src;f.message="Loading chunk "+e+" failed.\n("+a+": "+r+")",f.name="ChunkLoadError",f.type=a,f.request=r,n[1](f)}o[e]=void 0}};var d=setTimeout((function(){u({type:"timeout",target:l})}),12e4);l.onerror=l.onload=u,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=a,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)i.d(n,a,function(t){return e[t]}.bind(null,a));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i.oe=function(e){throw console.error(e),e};var u=window["webpackJsonp"]=window["webpackJsonp"]||[],l=u.push.bind(u);u.push=t,u=u.slice();for(var f=0;f<u.length;f++)t(u[f]);var d=l;s.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},4678:function(e,t,n){var a={"./af":"2bfb","./af.js":"2bfb","./ar":"8e73","./ar-dz":"a356","./ar-dz.js":"a356","./ar-kw":"423e","./ar-kw.js":"423e","./ar-ly":"1cfd","./ar-ly.js":"1cfd","./ar-ma":"0a84","./ar-ma.js":"0a84","./ar-sa":"8230","./ar-sa.js":"8230","./ar-tn":"6d83","./ar-tn.js":"6d83","./ar.js":"8e73","./az":"485c","./az.js":"485c","./be":"1fc1","./be.js":"1fc1","./bg":"84aa","./bg.js":"84aa","./bm":"a7fa","./bm.js":"a7fa","./bn":"9043","./bn.js":"9043","./bo":"d26a","./bo.js":"d26a","./br":"6887","./br.js":"6887","./bs":"2554","./bs.js":"2554","./ca":"d716","./ca.js":"d716","./cs":"3c0d","./cs.js":"3c0d","./cv":"03ec","./cv.js":"03ec","./cy":"9797","./cy.js":"9797","./da":"0f14","./da.js":"0f14","./de":"b469","./de-at":"b3eb","./de-at.js":"b3eb","./de-ch":"bb71","./de-ch.js":"bb71","./de.js":"b469","./dv":"598a","./dv.js":"598a","./el":"8d47","./el.js":"8d47","./en-SG":"cdab","./en-SG.js":"cdab","./en-au":"0e6b","./en-au.js":"0e6b","./en-ca":"3886","./en-ca.js":"3886","./en-gb":"39a6","./en-gb.js":"39a6","./en-ie":"e1d3","./en-ie.js":"e1d3","./en-il":"7333","./en-il.js":"7333","./en-nz":"6f50","./en-nz.js":"6f50","./eo":"65db","./eo.js":"65db","./es":"898b","./es-do":"0a3c","./es-do.js":"0a3c","./es-us":"55c9","./es-us.js":"55c9","./es.js":"898b","./et":"ec18","./et.js":"ec18","./eu":"0ff2","./eu.js":"0ff2","./fa":"8df4","./fa.js":"8df4","./fi":"81e9","./fi.js":"81e9","./fo":"0721","./fo.js":"0721","./fr":"9f26","./fr-ca":"d9f8","./fr-ca.js":"d9f8","./fr-ch":"0e49","./fr-ch.js":"0e49","./fr.js":"9f26","./fy":"7118","./fy.js":"7118","./ga":"5120","./ga.js":"5120","./gd":"f6b4","./gd.js":"f6b4","./gl":"8840","./gl.js":"8840","./gom-latn":"0caa","./gom-latn.js":"0caa","./gu":"e0c5","./gu.js":"e0c5","./he":"c7aa","./he.js":"c7aa","./hi":"dc4d","./hi.js":"dc4d","./hr":"4ba9","./hr.js":"4ba9","./hu":"5b14","./hu.js":"5b14","./hy-am":"d6b6","./hy-am.js":"d6b6","./id":"5038","./id.js":"5038","./is":"0558","./is.js":"0558","./it":"6e98","./it-ch":"6f12","./it-ch.js":"6f12","./it.js":"6e98","./ja":"079e","./ja.js":"079e","./jv":"b540","./jv.js":"b540","./ka":"201b","./ka.js":"201b","./kk":"6d79","./kk.js":"6d79","./km":"e81d","./km.js":"e81d","./kn":"3e92","./kn.js":"3e92","./ko":"22f8","./ko.js":"22f8","./ku":"2421","./ku.js":"2421","./ky":"9609","./ky.js":"9609","./lb":"440c","./lb.js":"440c","./lo":"b29d","./lo.js":"b29d","./lt":"26f9","./lt.js":"26f9","./lv":"b97c","./lv.js":"b97c","./me":"293c","./me.js":"293c","./mi":"688b","./mi.js":"688b","./mk":"6909","./mk.js":"6909","./ml":"02fb","./ml.js":"02fb","./mn":"958b","./mn.js":"958b","./mr":"39bd","./mr.js":"39bd","./ms":"ebe4","./ms-my":"6403","./ms-my.js":"6403","./ms.js":"ebe4","./mt":"1b45","./mt.js":"1b45","./my":"8689","./my.js":"8689","./nb":"6ce3","./nb.js":"6ce3","./ne":"3a39","./ne.js":"3a39","./nl":"facd","./nl-be":"db29","./nl-be.js":"db29","./nl.js":"facd","./nn":"b84c","./nn.js":"b84c","./pa-in":"f3ff","./pa-in.js":"f3ff","./pl":"8d57","./pl.js":"8d57","./pt":"f260","./pt-br":"d2d4","./pt-br.js":"d2d4","./pt.js":"f260","./ro":"972c","./ro.js":"972c","./ru":"957c","./ru.js":"957c","./sd":"6784","./sd.js":"6784","./se":"ffff","./se.js":"ffff","./si":"eda5","./si.js":"eda5","./sk":"7be6","./sk.js":"7be6","./sl":"8155","./sl.js":"8155","./sq":"c8f3","./sq.js":"c8f3","./sr":"cf1e","./sr-cyrl":"13e9","./sr-cyrl.js":"13e9","./sr.js":"cf1e","./ss":"52bd","./ss.js":"52bd","./sv":"5fbd","./sv.js":"5fbd","./sw":"74dc","./sw.js":"74dc","./ta":"3de5","./ta.js":"3de5","./te":"5cbb","./te.js":"5cbb","./tet":"576c","./tet.js":"576c","./tg":"3b1b","./tg.js":"3b1b","./th":"10e8","./th.js":"10e8","./tl-ph":"0f38","./tl-ph.js":"0f38","./tlh":"cf75","./tlh.js":"cf75","./tr":"0e81","./tr.js":"0e81","./tzl":"cf51","./tzl.js":"cf51","./tzm":"c109","./tzm-latn":"b53d","./tzm-latn.js":"b53d","./tzm.js":"c109","./ug-cn":"6117","./ug-cn.js":"6117","./uk":"ada2","./uk.js":"ada2","./ur":"5294","./ur.js":"5294","./uz":"2e8c","./uz-latn":"010e","./uz-latn.js":"010e","./uz.js":"2e8c","./vi":"2921","./vi.js":"2921","./x-pseudo":"fd7e","./x-pseudo.js":"fd7e","./yo":"7f33","./yo.js":"7f33","./zh-cn":"5c3a","./zh-cn.js":"5c3a","./zh-hk":"49ab","./zh-hk.js":"49ab","./zh-tw":"90ea","./zh-tw.js":"90ea"};function r(e){var t=o(e);return n(t)}function o(e){if(!n.o(a,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return a[e]}r.keys=function(){return Object.keys(a)},r.resolve=o,e.exports=r,r.id="4678"},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var a=n("2b0e"),r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[e.isShowPageLoading?n("div",{staticClass:"mini-im-loading",class:{"pc-mini-im-loading":!e.isMobile}},[n("mt-spinner",{attrs:{type:"triple-bounce",color:"#26a2ff"}})],1):e._e(),n("router-view")],1)},o=[],s=(n("8e6e"),n("ac6a"),n("456d"),n("28a5"),n("bd86")),c=n("2f62");function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){Object(s["a"])(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var l={name:"app",data:function(){return{}},computed:u({},Object(c["b"])(["isShowPageLoading","userAccount","isArtificial","isMobile","artificialAccount","robotAccount","platform","userLocal","uid","uid"])),created:function(){var e=this;this.getLocal(),setTimeout((function(){e.handelUrl(),e.runApp()}),500),this.onCheckIsOutSession()},methods:{runApp:function(){var e=this,t=this.$mimcInstance.getLocalCacheUser();t&&null!=this.userAccount&&this.userAccount!=t.id&&0!=this.userAccount&&localStorage.clear(),this.$mimcInstance.init({type:0,address:this.userLocal,uid:this.uid||0,platform:this.platform,account_id:this.userAccount||0},(function(t){if(e.upLastActivity(),e.$store.dispatch("onGetCompanyInfo"),e.$store.dispatch("onGetConfigs"),e.$store.dispatch("onGetWorkorderTypes"),e.$store.dispatch("onGetWorkorders"),t){e.$store.commit("updateState",{userAccount:t.id,userInfo:t});var n=e.$mimcInstance.robot;localStorage.setItem("robot_"+n.id,JSON.stringify(n)),e.$store.commit("updateState",{robotAccount:n.id,robotInfo:n});var a=function t(){null!=e.$mimcInstance.user&&e.$mimcInstance.user.isLogin()?e.artificialAccount||(console.log("握手消息"),e.$mimcInstance.sendMessage("handshake",e.robotAccount,"")):setTimeout((function(){return t()}),1e3)};a()}else setTimeout((function(){return e.runApp()}),1e3)}))},handelUrl:function(){var e,t,n,a,r,o,s,c,i=this.$route.query;i&&i.c&&localStorage.clear();var u=this.queryToJson(localStorage.getItem("urlQuery"));u&&(i=Object.assign({},u,i)),i&&("0"==i.h&&(e=!1),"0"==i.m&&(t=!1,e=!1),i.u&&(n=parseInt(i.u)),i.p&&(c=parseInt(i.p)),i.uid&&(a=parseInt(i.uid)),"0"==i.r?(r=!0,o=parseInt(i.a)):s=parseInt(i.a));var l=localStorage.getItem("isArtificial"),f=localStorage.getItem("artificialAccount");"true"==l&&(r=!0,o=parseInt(f)),this.$store.commit("updateState",{isShowHeader:e,isMobile:t,userAccount:n,uid:a,isArtificial:r,artificialAccount:o,robotAccount:s,platform:c})},queryToJson:function(e){if(!e||""==e)return null;var t=e.substr(1,e.length).split("&");if(!t)return null;for(var n={},a=0;a<t.length;a++){var r=t[a].split("=");n[r[0]]=r[1]}return n},getLocal:function(){this.$store.dispatch("onGetLocal",this.$store.state.AmapAPPKey)},upLastActivity:function(){var e=this;this.onCheckIsOutSession();var t=this.$mimcInstance.getLocalCacheUser();t&&this.$store.dispatch("onUpdateLastActivity"),this.isArtificial&&localStorage.setItem("artificialTime",Date.now()),setTimeout((function(){return e.upLastActivity()}),6e4)},onCheckIsOutSession:function(){var e=localStorage.getItem("artificialTime");e&&(e=parseInt(e),Date.now()>e+6e5&&this.$store.commit("updateState",{isArtificial:!1,artificialAccount:null}))}}},f=l,d=(n("7faf"),n("2877")),p=Object(d["a"])(f,r,o,!1,null,null,null),m=p.exports,h=n("d1d4"),b=n.n(h),g=n("8c4f");a["default"].use(g["a"]);var j=new g["a"]({base:"",routes:[{path:"/",redirect:"/index"},{path:"/index",name:"index",component:function(){return n.e("chunk-5e6009ff").then(n.bind(null,"e0a0"))}},{path:"/workorder",name:"workorder",component:function(){return n.e("chunk-5853fee7").then(n.bind(null,"fb09"))}},{path:"/workorder/create",name:"workorder_create",component:function(){return n.e("chunk-5abde09c").then(n.bind(null,"ede1"))}},{path:"/workorder/detail/:id",name:"workorder_detail",component:function(){return n.e("chunk-fc784ea6").then(n.bind(null,"4033"))}}]}),k=j,v=n("bc3a"),y=n.n(v),w={onGetMessages:function(e,t){var n=20;y.a.post("/public/messages",{timestamp:t.timestamp,page_size:n}).then((function(a){var r=[],o=a.data.data.list||[];(o.length<n||0==o.length)&&e.commit("updateState",{isLoadMorEnd:!0}),r=0==t.oldMsg.length&&o.length>0?a.data.data.list:o.length>0?o.concat(t.oldMsg):t.oldMsg,e.commit("updateState",{messages:r}),t.callback&&t.callback()})).catch((function(e){console.log(e)}))},onGetLocal:function(e,t){y.a.get("https://restapi.amap.com/v3/ip?key="+t).then((function(t){t.data.province&&e.commit("updateState",{userLocal:t.data.province+t.data.city})})).catch((function(e){console.error(e)}))},onCleanRead:function(){y.a.get("/public/clean_read/")},onUpdateLastActivity:function(){y.a.get("/public/activity/")},onToggleWindow:function(e,t){y.a.put("/public/window/",{window:t})},onGetCompanyInfo:function(e){y.a.get("/public/company").then((function(t){e.commit("updateState",{companyInfo:t.data.data})})).catch((function(e){console.error(e)}))},onGetConfigs:function(e){y.a.get("/public/configs").then((function(t){e.commit("updateState",{configs:t.data.data})}))},onGetWorkorderTypes:function(e){y.a.get("/public/workorder/types").then((function(t){e.commit("updateState",{workorderTypes:t.data.data})}))},onGetWorkorders:function(e){y.a.get("/public/workorders").then((function(t){e.commit("updateState",{workorders:t.data.data})}))}},_={updateState:function(e,t){var n=e;for(var a in t)void 0!=t[a]&&(n[a]=t[a]);e=n}},M=(n("4917"),{platform:function(e){return e.platform},isArtificial:function(e){return e.isArtificial},isShowHeader:function(e){return e.isShowHeader},isMobile:function(e){return e.isMobile},uid:function(e){return e.uid},userAccount:function(e){return e.userAccount},artificialAccount:function(e){return e.artificialAccount},robotInfo:function(e){return e.robotInfo},robotAccount:function(e){return e.robotAccount},isLoadMorEnd:function(e){return e.isLoadMorEnd},messages:function(e){return e.messages||[]},userLocal:function(e){return e.userLocal},isLoadMorLoading:function(e){return e.isLoadMorLoading},userInfo:function(e){return e.userInfo},companyInfo:function(e){return e.companyInfo},configs:function(e){return e.configs},isIOS:function(){return!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)},isSafari:function(){return navigator.userAgent.indexOf("Safari")>-1&&navigator.userAgent.indexOf("Chrome")<1},isJudgeBigScreen:function(){var e=!1,t=window.screen.height/window.screen.width,n=window.screen.height==window.screen.availHeight?1.8:1.65;return t>n&&(e=!0),e},isShowPageLoading:function(e){return e.isShowPageLoading},workorders:function(e){return e.workorders},workorderTypes:function(e){return e.workorderTypes}}),I={platform:5,isShowPageLoading:!1,isShowHeader:!0,isMobile:!0,isArtificial:!1,uid:0,userAccount:0,artificialAccount:null,robotInfo:null,robotAccount:null,messages:[],isLoadMorEnd:!1,userLocal:"",AmapAPPKey:"73ef1dc5c5ea086e7330b95aede42953",isLoadMorLoading:!1,userInfo:{},companyInfo:null,configs:{},workorders:[],workorderTypes:[]};a["default"].use(c["a"]);var S=new c["a"].Store({state:I,getters:M,mutations:_,actions:w}),A=(n("394c"),n("76a0")),L=n.n(A),C=(n("aa35"),n("7f7f"),n("cea2")),T=n("c1df"),O={install:function(e,t){e.prototype.$myMethod=function(){console.log(t)},e.prototype.$formatUnixDate=function(e,t){return T(parseInt(e+"000")).format(t)},e.prototype.$formatFromNowDate=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"YYYY-MM-DD HH:mm";return T().format("YYYYMMDD")==T(parseInt(e+"000")).format("YYYYMMDD")?"今天 "+T(parseInt(e+"000")).format("HH:mm"):T(parseInt(e+"000")).format(t)},e.prototype.$formatDate=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"YYYY-MM-DD HH:mm:ss";return T(parseInt(e+"000")).format(t)},e.prototype.$robotNickname=function(e){for(var t,n=this.$store.getters.robots,a=0;a<n.length;a++)n[a].id==e&&(t=n[a].nickname);return t},e.prototype.$uploadFile=function(e){var t=e.mode,n=e.secret,a=e.file,r=e.percent,o=e.success,s=e.fail,c=null,i=parseInt(1e4*Math.random()*(new Date).getTime())+a.name.substr(a.name.lastIndexOf("."));if(1==t){var u=new FormData;u.append("file",a),u.append("file_name",i),y.a.post("/public/upload",u).then((function(e){o&&o(e.data.data)})).catch((function(e){s&&s(e)}))}else if(2==t){var l={quality:.92,noCompressIfLarger:!0,maxWidth:1500};C["compressImage"](a,l).then((function(e){var t=C["upload"](e.dist,i,n,{},{mimeType:null});c=t.subscribe({next:function(e){r&&r(e)},error:function(){var e=new FormData;e.append("fileType","image"),e.append("fileName","file"),e.append("key",i),e.append("token",n),e.append("file",a),y.a.post("https://upload.qiniup.com",e).then((function(){o&&o(i)})).catch((function(e){s&&s(e)}))},complete:function(e){o&&o(e.key)}})}))}return c}}},D=O,Y=(n("6b54"),{install:function(e,t){console.log(t),e.MimcInstance=e.prototype.$mimcInstance={user:null,robot:null,platform:5,fetchMIMCTokenResult:null,_receiveP2PMsgCallback:null,_statusChangeCallback:null,_serverAckCallback:null,_disconnectCallback:null,init:function(e,t){this.platform=e.platform,this.fetchMIMCToken(e,t)},getLocalCacheUser:function(){var e=localStorage.getItem("user");return e?JSON.parse(e):null},fetchMIMCToken:function(e,t){var n=this;y.a.post("/public/register",e).then((function(e){n.fetchMIMCTokenResult=e.data.data.token,localStorage.setItem("user",JSON.stringify(e.data.data.user)),localStorage.setItem("Token",e.data.data.user.token),console.log("MIMC初始化成功"),n.getRobot((function(){t&&t(e.data.data.user)})),n.login()})).catch((function(e){t&&t(null),console.log(e)}))},getRobot:function(e){var t=this;y.a.get("/public/robot/"+this.platform).then((function(n){t.robot=n.data.data,e&&e()})).catch((function(e){console.log("mimc初始化失败,请刷新重试",e)}))},pushMessage:function(e){var t=this;y.a.post("/public/message/push",{msgType:"NORMAL_MSG",payload:e}).then((function(n){console.log(n.data),200!=n.data["code"]&&setTimeout((function(){return t.pushMessage(e)}),300)})).catch((function(){setTimeout((function(){return t.pushMessage(e)}),300)}))},login:function(e){var t=this;try{var n=this.fetchMIMCTokenResult;this.user=new MIMCUser(n.data.appId,n.data.appAccount,"666"),this.user.registerP2PMsgHandler((function(e){var n=JSON.parse(window.Base64.decode(e.getPayload()));t._receiveP2PMsgCallback&&t._receiveP2PMsgCallback(n)})),this.user.registerFetchToken((function(){return n})),this.user.registerStatusChange((function(e,n,a,r){t._statusChangeCallback&&t._statusChangeCallback(e,n,a,r)})),this.user.registerServerAckHandler((function(e,n,a,r){t._serverAckCallback&&t._serverAckCallback(e,n,a,r)})),this.user.registerDisconnHandler((function(){t._disconnectCallback&&t._disconnectCallback()})),this.user.login(),window.mimcInstance=this,e&&e(),console.log("MIMC登录成功")}catch(a){console.log("MIMC登录失败"),setTimeout((function(){t.login()}),1e3)}},logout:function(){this.user&&(this.user.logout(),this.user=null)},addEventListener:function(e,t){switch(e){case"receiveP2PMsg":this._receiveP2PMsgCallback=t;break;case"statusChange":this._statusChangeCallback=t;break;case"serverAck":this._serverAckCallback=t;break;case"disconnect":this._disconnectCallback=t;break}},sendMessage:function(e,t){var n=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.user){var r={from_account:parseInt(this.fetchMIMCTokenResult.data.appAccount),to_account:parseInt(t),biz_type:e,version:"0",timestamp:parseInt(((new Date).getTime()+" ").substr(0,10)),key:(new Date).getTime(),read:0,platform:this.platform,transfer_account:0,payload:a+""},o=window.Base64.encode(JSON.stringify(r));return"contacts"!=e&&"pong"!=e&&"welcome"!=e&&"handshake"!=e&&"search_knowledge"!=e&&this.pushMessage(window.Base64.encode(o)),setTimeout((function(){n.user.sendMessage(t.toString(),o)}),150),r}Object(A["Toast"])({message:"服务异常,请刷新重试!"})},createLocalMessage:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r={from_account:parseInt(this.fetchMIMCTokenResult.data.appAccount),to_account:parseInt(t),biz_type:e,version:"0",platform:this.platform,timestamp:parseInt(((new Date).getTime()+" ").substr(0,10)),key:(new Date).getTime(),read:0,transfer_account:parseInt(a),payload:n+""};return r}}}}),P=Y,$={months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY年MM月DD日",LLL:"YYYY年MM月DD日Ah点mm分",LLLL:"YYYY年MM月DD日ddddAh点mm分",l:"YYYY-M-D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},meridiemParse:/凌晨|早上|上午|中午|下午|晚上/,meridiemHour:function(e,t){return 12===e&&(e=0),"凌晨"===t||"早上"===t||"上午"===t?e:"下午"===t||"晚上"===t?e+12:e>=11?e:e+12},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1130?"上午":n<1230?"中午":n<1800?"下午":"晚上"},calendar:{sameDay:"[今天]LT",nextDay:"[明天]LT",nextWeek:"[下]ddddLT",lastDay:"[昨天]LT",lastWeek:"[上]ddddLT",sameElse:"L"},dayOfMonthOrdinalParse:/\d{1,2}(日|月|周)/,ordinal:function(e,t){switch(t){case"d":case"D":case"DDD":return e+"日";case"M":return e+"月";case"w":case"W":return e+"周";default:return e}},relativeTime:{future:"%s内",past:"%s前",s:"几秒",ss:"%d秒",m:"1分钟",mm:"%d分钟",h:"1小时",hh:"%d小时",d:"1天",dd:"%d天",M:"1个月",MM:"%d个月",y:"1年",yy:"%d年"},week:{dow:1,doy:4}},z=n("c1df");z.locale("zh-cn",$),y.a.defaults.baseURL="/api",y.a.interceptors.request.use((function(e){if(-1!=e.url.indexOf("https://restapi.amap.com/v3/ip"))return e;var t=localStorage.getItem("Token")||"";return e.headers=Object.assign({},{Token:t},e.headers),e}),(function(e){return console.log(e),Promise.reject(e)}));var H={clickToCloseNonZoomable:!1,fullscreenEl:!1};a["default"].use(b.a,H),a["default"].use(D),a["default"].use(P),a["default"].use(L.a),a["default"].config.productionTip=!1,new a["default"]({router:k,store:S,render:function(e){return e(m)}}).$mount("#app")},"7faf":function(e,t,n){"use strict";var a=n("8fba"),r=n.n(a);r.a},"8fba":function(e,t,n){}});
//# sourceMappingURL=app.2783e17d.js.map
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
package services
import (
"encoding/base64"
"kefu_server/models"
"strconv"
"time"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
......@@ -18,6 +18,7 @@ type MessageRepositoryInterface interface {
GetReadCount(uid int64) (int64, error)
ClearRead(uid int64) (int64, error)
DeleteWhiteMessage(uids []int) int
MoveMessageToHistory() int64
Cancel(fromAccount int64, toAccount int64, key int64) error
}
......@@ -55,6 +56,15 @@ func (r *MessageRepository) Add(message *models.Message) (int64, error) {
return row, err
}
// GetReadCount message read count
func (r *MessageRepository) GetReadCount(uid int64) (int64, error) {
count, err := r.q.Filter("to_account", uid).Filter("read", 1).Count()
if err != nil {
logs.Warn("Add add a message------------", err)
}
return count, err
}
// ClearRead Clear message read
func (r *MessageRepository) ClearRead(uid int64) (int64, error) {
index, err := r.q.Filter("to_account", uid).Update(orm.Params{
......@@ -66,19 +76,32 @@ func (r *MessageRepository) ClearRead(uid int64) (int64, error) {
return index, err
}
// GetReadCount message read count
func (r *MessageRepository) GetReadCount(uid int64) (int64, error) {
count, err := r.q.Filter("to_account", uid).Filter("read", 1).Count()
// MoveMessageToHistory move message history table
func (r *MessageRepository) MoveMessageToHistory() int64 {
fields := "`from_account`,`to_account`,`biz_type`,`version`,`timestamp`,`sequence`,`key`,`transfer_account`,`platform`,`payload`,`read`"
timestampMax := time.Now().Unix() - int64(60*60*24*1) // 30 day
res, err := r.o.Raw("INSERT INTO message_history("+fields+") SELECT "+fields+" FROM message WHERE timestamp < ?", timestampMax).Exec()
if err != nil {
logs.Warn("Add add a message------------", err)
logs.Warn("MoveMessageToHistory move message history table1------------", err)
}
return count, err
rows, _ := res.RowsAffected()
if rows > 0 {
r.q.Filter("timestamp__lt", timestampMax).Delete()
}
if err != nil {
logs.Warn("MoveMessageToHistory move message history table2------------", err)
}
return rows
}
// Delete delete a message
func (r *MessageRepository) Delete(removeRequestDto models.RemoveMessageRequestDto) (int64, error) {
res, err := r.o.Raw("DELETE FROM `message` WHERE from_account = ? AND to_account = ? AND `key` = ?", removeRequestDto.FromAccount, removeRequestDto.ToAccount, removeRequestDto.Key).Exec()
row, _ := res.RowsAffected()
if row == 0 {
r.o.Raw("DELETE FROM `message_history` WHERE from_account = ? AND to_account = ? AND `key` = ?", removeRequestDto.FromAccount, removeRequestDto.ToAccount, removeRequestDto.Key).Exec()
}
if err != nil {
logs.Warn("Delete delete a message------------", err)
return 0, err
......@@ -110,7 +133,7 @@ func (r *MessageRepository) GetUserMessages(messagePaginationDto models.MessageP
start = 0
}
if messageCount.Count > 0 {
_, err := r.o.Raw("SELECT * FROM `message` WHERE (`to_account` = ? OR `from_account` = ?) AND `timestamp` < ? ORDER BY `timestamp` ASC LIMIT ?,?", uid, uid, timestamp, start, end).QueryRows(&messages)
_, err := r.o.Raw("SELECT * FROM `message` WHERE (`to_account` = ? OR `from_account` = ?) AND `timestamp` < ? ORDER BY `sequence` ASC LIMIT ?,?", uid, uid, timestamp, start, end).QueryRows(&messages)
if err != nil {
logs.Warn("GetUserMessages get user messages1------------", err)
return nil, err
......@@ -127,10 +150,6 @@ func (r *MessageRepository) GetUserMessages(messagePaginationDto models.MessageP
messagePaginationDto.List = []models.Message{}
messagePaginationDto.Total = 0
}
for index, msg := range messages {
payload, _ := base64.StdEncoding.DecodeString(msg.Payload)
messages[index].Payload = string(payload)
}
return &messagePaginationDto, nil
}
......@@ -169,7 +188,7 @@ func (r *MessageRepository) GetAdminMessages(messagePaginationDto models.Message
}
if msgCount > 0 {
_, err = r.o.Raw("SELECT * FROM `message` WHERE to_account IN ("+inExp+") AND from_account IN ("+inExp+") AND `timestamp` < ? ORDER BY `timestamp` ASC LIMIT ?,?", accounts, accounts, messagePaginationDto.Timestamp, start, end).QueryRows(&messages)
_, err = r.o.Raw("SELECT * FROM `message` WHERE to_account IN ("+inExp+") AND from_account IN ("+inExp+") AND `timestamp` < ? ORDER BY `sequence` ASC LIMIT ?,?", accounts, accounts, messagePaginationDto.Timestamp, start, end).QueryRows(&messages)
if err != nil {
logs.Warn("GetMessages get one service message list2------------", err)
return nil, err
......@@ -186,9 +205,5 @@ func (r *MessageRepository) GetAdminMessages(messagePaginationDto models.Message
messagePaginationDto.List = []models.Message{}
messagePaginationDto.Total = 0
}
for index, msg := range messages {
payload, _ := base64.StdEncoding.DecodeString(msg.Payload)
messages[index].Payload = string(payload)
}
return &messagePaginationDto, nil
}
......@@ -19,4 +19,5 @@ func clearUser() {
return nil
})
toolbox.AddTask("clearUser", clearUserTk)
}
......@@ -9,4 +9,7 @@ func Run() {
// ClearUser
clearUser()
// moveMessage
moveMessage()
}
package task
import (
"kefu_server/services"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/toolbox"
)
// moveMessage tk
func moveMessage() {
// moveMessage day at 5 am
moveMessageTk := toolbox.NewTask("moveMessage", "0 0 05 * * * ", func() error {
length := services.GetMessageRepositoryInstance().MoveMessageToHistory()
logs.Info("定时迁移了", length, "条消息记录到历史表~")
return nil
})
toolbox.AddTask("moveMessage", moveMessageTk)
}
......@@ -115,10 +115,10 @@ export default {
self.$store.commit("onChangeMimcUser", self.$mimcInstance.user)
})
}else if(self.$store.getters.adminInfo.online != 0){
setTimeout(() => self.watchLogin(), 1000)
setTimeout(() => self.watchLogin(), 2000)
}
}catch(err){
setTimeout(() => this.watchLogin(), 1000)
setTimeout(() => this.watchLogin(), 2000)
}
},
},
......
......@@ -328,6 +328,7 @@ export default {
if(!status){
this.$store.dispatch('ON_GET_ME').then(()=>{
if(this.adminInfo.online != 0){
this.onLongTraining()
this.init();
}
})
......@@ -340,9 +341,11 @@ export default {
// 监听连接断开
this.$mimcInstance.addEventListener("disconnect", () => {
console.log("链接断开!")
this.isLogin = false;
this.onLongTraining()
var adminInfo = this.adminInfo
if(adminInfo.online != 0){
this.adminInfo = null;
this.$store.commit("onChangeAdminInfo", null)
this.init();
}else{
adminInfo.online = 0
......@@ -350,6 +353,16 @@ export default {
}
})
},
// onLongTraining
onLongTraining(){
if(this.$mimcInstance.user.isLogin()) return
console.log("长轮训获取新消息..")
// 获取聊天记录
this.$store.dispatch('ON_GET_CONTACTS')
this.getMessageRecord()
this.scrollIntoBottom()
setTimeout(()=> this.onLongTraining(), 2000)
},
// 刷新鼠标动态 mousemove
onMousemoveEvent(){
// 以下其他浏览器的聊天高度
......@@ -756,15 +769,19 @@ export default {
"account": account
})
.then(response => {
let messages = response.data.data.list
for(var i=0; i<messages.length; i++){
messages[i].payload = window.Base64.decode(messages[i].payload)
}
this.getMessageRecordLoading = false
if(response.data.data.list.length < this.getMessageRecordPageSize){
if(messages.length < this.getMessageRecordPageSize){
this.isMessageEnd = true
}
if(this.messageRecord.list.length == 0 || timestamp == 0){
this.$store.commit("onChangeMessageRecord", response.data.data)
this.scrollIntoBottom()
}else{
response.data.data.list = response.data.data.list.concat(this.messageRecord.list)
response.data.data.list = messages.concat(this.messageRecord.list)
this.$store.commit("onChangeMessageRecord", response.data.data)
}
setTimeout(()=>this.$previewRefresh(), 1000)
......
......@@ -14,6 +14,9 @@ export default {
.then(response => {
let newMessage = [];
let messages = response.data.data.list || [];
for(var i=0; i<messages.length; i++){
messages[i].payload = window.Base64.decode(messages[i].payload)
}
if (messages.length < pageSize || messages.length == 0) {
context.commit('updateState', { isLoadMorEnd: true })
}
......
......@@ -382,7 +382,18 @@ export default {
}
})
console.log("重新登录中...");
console.log(this.$mimcInstance.user.isLogin())
},
// onLongTraining
onLongTraining(){
if(!this.isShowTopLoading) return
// 长轮训获取新消息
console.log("长轮训获取新消息..")
this.$store.dispatch("onGetMessages", {
timestamp: 0,
oldMsg: [],
callback: () => this.scrollIntoBottom()
});
setTimeout(()=> this.onLongTraining(), 2000)
},
// handelEvent
handelEvent() {
......@@ -397,6 +408,7 @@ export default {
this.$mimcInstance.user.logout()
this.isShowTopLoading = true;
this.userLogin()
this.onLongTraining()
});
// 状态发生变化
......@@ -407,6 +419,7 @@ export default {
this.isShowTopLoading = false;
}else{
this.userLogin()
this.onLongTraining()
}
console.log("状态发生变化", bindResult, errType, errReason, errDesc);
}
......@@ -567,7 +580,7 @@ export default {
localMessage["percent"] = 0;
localMessage.isShowCancel = true;
setTimeout(() => {
localMessage.isShowCancel = false;
this.updateMessageHideCancel(localMessage)
}, 10000);
self.messages.push(self.handlerMessage(localMessage));
var cacheMsg = Object.assign({}, localMessage);
......@@ -699,6 +712,17 @@ export default {
this.sendTextMessage();
this.$refs.textarea.focus();
},
// 更新消息
updateMessageHideCancel(message){
let messages = this.$store.getters.messages
for(var i =0; i<messages.length; i++){
if(message.key == messages[i].key){
messages[i].isShowCancel = false
break
}
}
this.$store.commit("updateState", { messages });
},
// 发送文本消息
sendTextMessage() {
// 当前用户是否上线
......@@ -716,7 +740,9 @@ export default {
chatValue
);
message.isShowCancel = true;
setTimeout(() => (message.isShowCancel = false), 10000);
setTimeout(() =>{
this.updateMessageHideCancel(message)
}, 10000);
this.messagesPushMemory(message);
this.chatValue = "";
this.handshakeKeywordList = [];
......
......@@ -22,6 +22,7 @@ func MessageInto(message models.Message) {
// message create time
message.Timestamp = time.Now().Unix()
message.Sequence = time.Now().UnixNano()
// content内容转base64
message.Payload = base64.StdEncoding.EncodeToString([]byte(message.Payload))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment