acdr-ui/dist/build/mp-weixin/modules/mall/chat/index.js

2 lines
2.9 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";var e=(e,o,s)=>new Promise(((t,n)=>{var l=e=>{try{c(s.next(e))}catch(o){n(o)}},a=e=>{try{c(s.throw(e))}catch(o){n(o)}},c=e=>e.done?t(e.value):Promise.resolve(e.value).then(l,a);c((s=s.apply(e,o)).next())}));const o=require("../../../common/vendor.js"),s=require("../../../sheep/index.js"),t=require("./util/constants.js"),n=require("../../../sheep/api/infra/file.js"),l=require("../../../sheep/api/promotion/kefu.js"),a=require("../../../sheep/hooks/useWebSocket.js");if(!Array){(o.resolveComponent("s-layout")+o.resolveComponent("layout-default-uni"))()}Math||(r+c+i+u+(()=>"../../../sheep/components/s-layout/s-layout.js"))();const c=()=>"./components/messageList.js",i=()=>"./components/toolsPopup.js",r=()=>"./components/messageInput.js",u=()=>"./components/select-popup.js",p={__name:"index",setup(c){const i=s.sheep.$platform.navbar,r=o.reactive({msg:"",scrollInto:"",showTools:!1,toolsMode:"",showSelect:!1,selectMode:""});function u(){return e(this,null,(function*(){if(r.msg)try{const e={contentType:t.KeFuMessageContentTypeEnum.TEXT,content:r.msg};yield l.KeFuApi.sendKefuMessage(e),yield p.value.refreshMessageList(),r.msg=""}finally{r.showTools=!1}}))}const p=o.ref();function d(){r.showTools=!1,r.toolsMode=""}function h(e){r.msg+=e.name}function m(e){M.value?s.sheep.$helper.toast("您已掉线!请返回重试"):(r.toolsMode&&r.toolsMode!==e||(r.showTools=!r.showTools),r.toolsMode=e,r.showTools||(r.toolsMode=""))}function f(e){r.showTools=!1,r.showSelect=!0,r.selectMode=e}function g(o){return e(this,arguments,(function*({type:e,data:o}){let s;switch(e){case"image":const e=yield n.FileApi.uploadFile(o.tempFiles[0].path);s={contentType:t.KeFuMessageContentTypeEnum.IMAGE,content:e.data};break;case"goods":s={contentType:t.KeFuMessageContentTypeEnum.PRODUCT,content:JSON.stringify(o)};break;case"order":s={contentType:t.KeFuMessageContentTypeEnum.ORDER,content:JSON.stringify(o)}}s&&(yield l.KeFuApi.sendKefuMessage(s),yield p.value.refreshMessageList(),r.showTools=!1,r.showSelect=!1,r.selectMode="")}))}const{options:y}=a.useWebSocket({onConnected:()=>e(this,null,(function*(){})),onMessage:o=>e(this,null,(function*(){const e=o.type;e&&(e!==t.WebSocketMessageTypeConstants.KEFU_MESSAGE_TYPE?t.WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ:yield p.value.refreshMessageList(JSON.parse(o.content)))}))}),M=o.toRefs(y).isReconnecting;return(e,s)=>({a:o.unref(i)+"px",b:o.o(m),c:o.o(u),d:o.o((e=>r.msg=e)),e:o.p({modelValue:r.msg}),f:o.sr(p,"2a8bf5bd-2,2a8bf5bd-1",{k:"messageListRef"}),g:o.o(m),h:o.o(u),i:o.o((e=>r.msg=e)),j:o.p({modelValue:r.msg}),k:o.o(d),l:o.o(h),m:o.o(g),n:o.o(f),o:o.p({"show-tools":r.showTools,"tools-mode":r.toolsMode}),p:o.o(g),q:o.o((e=>r.showSelect=!1)),r:o.p({mode:r.selectMode,show:r.showSelect}),s:o.p({title:o.unref(M)?"会话重连中":"连接客服成功",navbar:"inner"})})}},d=o._export_sfc(p,[["__scopeId","data-v-2a8bf5bd"]]);wx.createPage(d);