1 |
- "use strict";const e=require("../../common/vendor.js"),o=require("../../sheep/index.js"),t=require("./emoji.js"),s=require("./socket.js");if(require("../../sheep/url/index.js"),require("../../sheep/store/index.js"),require("../../sheep/store/app.js"),require("../../sheep/api/promotion/diy.js"),require("../../sheep/request/index.js"),require("../../sheep/config/index.js"),require("../../sheep/platform/index.js"),require("../../sheep/platform/provider/wechat/index.js"),require("../../sheep/platform/provider/wechat/miniProgram.js"),require("../../sheep/api/member/auth.js"),require("../../sheep/api/member/social.js"),require("../../sheep/api/member/user.js"),require("../../sheep/platform/provider/apple/index.js"),require("../../sheep/platform/share.js"),require("../../sheep/router/index.js"),require("../../sheep/hooks/useModal.js"),require("../../sheep/helper/index.js"),require("../../sheep/helper/test.js"),require("../../sheep/helper/digit.js"),require("../../sheep/api/member/signin.js"),require("../../sheep/helper/throttle.js"),require("../../sheep/platform/pay.js"),require("../../sheep/api/pay/order.js"),require("../../sheep/store/user.js"),require("../../sheep/store/cart.js"),require("../../sheep/api/trade/cart.js"),require("../../sheep/api/pay/wallet.js"),require("../../sheep/api/trade/order.js"),require("../../sheep/api/promotion/coupon.js"),require("../../sheep/store/sys.js"),require("../../sheep/store/modal.js"),require("../../sheep/config/zIndex.js"),!Array){(e.resolveComponent("su-image")+e.resolveComponent("uni-easyinput")+e.resolveComponent("su-fixed")+e.resolveComponent("s-uploader")+e.resolveComponent("su-popup")+e.resolveComponent("s-layout"))()}Math||((()=>"../../sheep/ui/su-image/su-image.js")+i+n+(()=>"../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js")+(()=>"../../sheep/ui/su-fixed/su-fixed.js")+(()=>"../../sheep/components/s-uploader/s-uploader.js")+(()=>"../../sheep/ui/su-popup/su-popup.js")+r+(()=>"../../sheep/components/s-layout/s-layout.js"))();const r=()=>"./components/select-popup.js",i=()=>"./components/goods.js",n=()=>"./components/order.js",a={__name:"index",setup(r){const{socketInit:i,state:n,socketSendMsg:a,formatChatInput:u,socketHistoryList:l,onDrop:m,onPaste:p,getFocus:c,getUserToken:d,showTime:h,formatTime:f}=s.useChatWebSocket(),g=e.toRefs(n).chatList,j=e.toRefs(n).customerServerInfo,v=e.toRefs(n).chatHistoryPagination,w=e.toRefs(n).customerUserInfo,q=e.toRefs(n).socketState,x=o.sheep.$platform.navbar,y=e.computed((()=>o.sheep.$store("app").chat)),{screenHeight:_,safeAreaInsets:S,safeArea:$,screenWidth:T}=o.sheep.$platform.device,b=$.height-44-35-50,M={loadmore:{title:"查看更多",icon:"el-icon-d-arrow-left"},nomore:{title:"没有更多了",icon:""},loading:{title:"加载中... ",icon:"el-icon-loading"}},C=()=>{v.value.page<v.value.lastPage&&l()},k=e.reactive({msg:"",scrollInto:"",showTools:!1,toolsMode:"",showSelect:!1,selectMode:"",chatStyle:{mode:"inner",color:"#F8270F",type:"color",alwaysShow:1,src:"",list:{}}});function I(e){q.value.isConnect?(k.toolsMode&&k.toolsMode!==e||(k.showTools=!k.showTools),k.toolsMode=e,k.showTools||(k.toolsMode="")):o.sheep.$helper.toast(q.value.tip||"您已掉线!请返回重试")}function D(e){k.showTools=!1,k.showSelect=!0,k.selectMode=e}async function L({type:e,data:t}){let s="";switch(e){case"image":const{path:e,fullurl:r}=await o.sheep.$api.app.upload(t.tempFiles[0].path,"default");s={from:"customer",mode:"image",date:(new Date).getTime(),content:{url:r,path:e}};break;case"goods":s={from:"customer",mode:"goods",date:(new Date).getTime(),content:{item:{id:t.goods.id,title:t.goods.title,image:t.goods.image,price:t.goods.price,stock:t.goods.stock}}};break;case"order":s={from:"customer",mode:"order",date:(new Date).getTime(),content:{item:{id:t.id,order_sn:t.order_sn,create_time:t.create_time,pay_fee:t.pay_fee,items:t.items.filter((e=>({goods_id:e.goods_id,goods_title:e.goods_title,goods_image:e.goods_image,goods_price:e.goods_price}))),status_text:t.status_text}}}}s&&(a(s,(()=>{R()})),k.showTools=!1,k.showSelect=!1,k.selectMode="")}function P(){if(!q.value.isConnect)return void o.sheep.$helper.toast(q.value.tip||"您已掉线!请返回重试");if(!k.msg)return;const e={from:"customer",mode:"text",date:(new Date).getTime(),content:{text:k.msg}};a(e,(()=>{R()})),k.showTools=!1,setTimeout((()=>{k.msg=""}),100)}function F(e){let s=e;if("object"!=typeof s){let e=/\[(.+?)\]/g,r=s.match(e);r&&r.forEach((e=>{let r=function(e){for(let o in t.emojiList)if(t.emojiList[o].name===e)return t.emojiList[o].file;return!1}(e);s=s.replace(e,`<img class="chat-img" style="width: 24px;height: 24px;margin: 0 3px;" src="${o.sheep.$url.cdn("/static/img/chat/emoji/"+r)}"/>`)}))}return s}function R(){let e=null;k.scrollInto="",clearTimeout(e),e=setTimeout((()=>{k.scrollInto="scrollBottom"}),100)}return e.onLoad((async()=>{const{error:e}=await d();0===e?i(y.value,(()=>{R()})):q.value.isConnect=!1})),(s,r)=>e.e({a:e.t(e.unref(q).isConnect?e.unref(j).title:"网络已断开,请检查网络后刷新重试"),b:e.unref(x)+"px",c:e.unref(g).length&&e.unref(v).lastPage>1&&M[e.unref(v).loadStatus].title},e.unref(g).length&&e.unref(v).lastPage>1&&M[e.unref(v).loadStatus].title?{d:e.t(M[e.unref(v).loadStatus].title),e:e.n(M[e.unref(v).loadStatus].icon),f:e.o(C)}:{},{g:e.f(e.unref(g),((t,r,i)=>{var u;return e.e({a:"system"!==t.from&&e.unref(h)(t,r)},"system"!==t.from&&e.unref(h)(t,r)?{b:e.t(e.unref(f)(t.date))}:{},{c:"system"===t.from},"system"===t.from?{d:e.t(t.content.text)}:{},{e:"template"===t.mode&&t.content.list.length},"template"===t.mode&&t.content.list.length?{f:e.f(t.content.list,((t,s,r)=>({a:e.t(t.title),b:s,c:e.o((e=>function(e){if(!q.value.isConnect)return void o.sheep.$helper.toast(q.value.tip||"您已掉线!请返回重试");const t={from:"customer",mode:"text",date:(new Date).getTime(),content:{text:e.title},customData:{question_id:e.id}};a(t,(()=>{R()}))}(t)),s)})))}:{},{g:"customer_service"===t.from&&"template"!==t.mode||"customer"===t.from},"customer_service"===t.from&&"template"!==t.mode||"customer"===t.from?e.e({h:"customer_service"===t.from,i:e.unref(o.sheep).$url.cdn(null==(u=null==t?void 0:t.sender)?void 0:u.avatar)||e.unref(o.sheep).$url.static("/static/images/default.png"),j:"customer"===t.from&&r==e.unref(n).chatList.length-1&&0!==e.unref(n).isSendSucces},"customer"===t.from&&r==e.unref(n).chatList.length-1&&0!==e.unref(n).isSendSucces?e.e({k:-1==e.unref(n).isSendSucces},-1==e.unref(n).isSendSucces?{l:e.unref(o.sheep).$url.static("/static/images/loading.png")}:{}):{},{m:"text"===t.mode},"text"===t.mode?{n:F(t.content.text),o:e.o(((...e)=>s.onRichtext&&s.onRichtext(...e)),r),p:e.n(t.from)}:{},{q:"image"===t.mode},"image"===t.mode?{r:"c77a65ff-1-"+i+",c77a65ff-0",s:e.p({isPreview:!0,previewList:[e.unref(o.sheep).$url.cdn(t.content.url)],current:0,src:e.unref(o.sheep).$url.cdn(t.content.url),height:200,width:200,mode:"aspectFill"}),t:e.n(t.from)}:{},{v:"goods"===t.mode},"goods"===t.mode?{w:e.o((s=>e.unref(o.sheep).$router.go("/pages/goods/index",{id:t.content.item.id})),r),x:"c77a65ff-2-"+i+",c77a65ff-0",y:e.p({goodsData:t.content.item})}:{},{z:"order"===t.mode},"order"===t.mode?{A:e.o((s=>e.unref(o.sheep).$router.go("/pages/order/detail",{id:t.content.item.id})),r),B:"c77a65ff-3-"+i+",c77a65ff-0",C:e.p({from:"msg",orderData:t.content.item})}:{},{D:"customer"===t.from,E:e.unref(o.sheep).$url.cdn(e.unref(w).avatar),F:e.n("customer_service"===t.from?"ss-row-left":"customer"===t.from?"ss-row-right":"")}):{},{G:r})})),h:b+"px",i:k.scrollInto,j:b+"px",k:e.o((e=>k.msg=e)),l:e.p({inputBorder:!1,clearable:!1,placeholder:"请输入你要咨询的问题",modelValue:k.msg}),m:e.o((e=>I("emoji"))),n:!k.msg},k.msg?{}:{o:"tools"==k.toolsMode?1:"",p:e.o((e=>I("tools")))},{q:k.msg},k.msg?{r:e.o(P)}:{},{s:e.p({bottom:!0}),t:e.o((e=>k.msg=e)),v:e.p({inputBorder:!1,clearable:!1,placeholder:"请输入你要咨询的问题",modelValue:k.msg}),w:e.o((e=>I("emoji"))),x:!k.msg},k.msg?{}:{y:"tools"==k.toolsMode?1:"",z:e.o((e=>I("tools")))},{A:k.msg},k.msg?{B:e.o(P)}:{},{C:"emoji"==k.toolsMode},"emoji"==k.toolsMode?{D:e.f(e.unref(t.emojiPage),((t,s,r)=>({a:e.f(t,((t,s,r)=>({a:e.unref(o.sheep).$url.cdn(`/static/img/chat/emoji/${t.file}`),b:e.o((e=>function(e){k.msg+=e.name}(t)),t),c:t}))),b:t})))}:{E:e.unref(o.sheep).$url.static("/static/images/image.png"),F:e.o((e=>L({type:"image",data:e}))),G:e.p({"file-mediatype":"image",imageStyles:{width:50,height:50,border:!1}}),H:e.unref(o.sheep).$url.static("/static/images/goods.png"),I:e.o((e=>D("goods"))),J:e.unref(o.sheep).$url.static("/static/images/order.png"),K:e.o((e=>D("order")))},{L:e.o((e=>{k.showTools=!1,k.toolsMode=""})),M:e.p({show:k.showTools}),N:e.o(L),O:e.o((e=>k.showSelect=!1)),P:e.p({mode:k.selectMode,show:k.showSelect}),Q:e.p({title:"客服",navbar:"inner"})})}},u=e._export_sfc(a,[["__scopeId","data-v-c77a65ff"]]);wx.createPage(u);
|