UNPKG

@tencentcloud/ai-desk-customer-wechat

Version:

AI Desk customer UIKit for wechat mini program

3 lines (2 loc) 2.77 kB
"use strict";const s=require("../../../../../common/vendor.js"),b=require("../../../../adapter-vue.js"),a=require("../../../../@aidesk/uikit-engine/index.js"),k=require("../../../../../common/assets.js"),j=require("../../../../utils/index.js"),m=require("../../../../utils/env.js");Math||$();const $=()=>"../../../common/Icon.js",V=s.defineComponent({__name:"index",emits:["scrollToLatestMessage","scrollNearToBottom"],setup(F,{expose:x,emit:O}){const{ref:o,onMounted:S,onUnmounted:U,computed:y,watch:H}=b.vue,v=O,c=o([]),f=o(""),_=o(0),i=o(0),r=o(!1),d=o(!1),n=o(!1),g=y(()=>i.value?`${i.value}${a.jt.t("TUIChat.条新消息")}`:a.jt.t("TUIChat.回到最新位置"));H(()=>[r.value,d.value],()=>{n.value=r.value||d.value,n.value||l()},{immediate:!0}),S(()=>{a.Kt.watch(a.a.CHAT,{messageList:C,newMessageList:T}),a.Kt.watch(a.a.CONV,{currentConversation:h})}),U(()=>{a.Kt.unwatch(a.a.CHAT,{messageList:C,newMessageList:T}),a.Kt.unwatch(a.a.CONV,{currentConversation:h})});function N(e){var t,u;return((u=j.JSONToObject((t=e.payload)==null?void 0:t.data))==null?void 0:u.businessID)==="user_typing_status"}function C(e){c.value=e||[];const t=c.value[c.value.length-1];d.value=!!(t&&!t._onlineOnlyFlag&&t.time<_.value)}function T(e){Array.isArray(e)&&n.value&&e.forEach(t=>{t&&t.conversationID===f.value&&!t.isDeleted&&!t.isRevoked&&!N(t)&&!t._onlineOnlyFlag&&(i.value+=1)})}function h(e){var t;(e==null?void 0:e.conversationID)!==f.value&&l(),f.value=(e==null?void 0:e.conversationID)||"",_.value=((t=e==null?void 0:e.lastMessage)==null?void 0:t.lastTime)||0}async function q(e){var t,u,w,M,D;if(e.target)try{const{height:p}=await s.T(`#${(t=e.target)==null?void 0:t.id}`,"messageList")||{},I=((u=e.target)==null?void 0:u.scrollHeight)||((w=e.detail)==null?void 0:w.scrollHeight),L=((M=e.target)==null?void 0:M.scrollTop)||((D=e.detail)==null?void 0:D.scrollTop)||0;if(I-L>2*p){r.value=!0;return}I-L<p+20&&v("scrollNearToBottom"),r.value=!1}catch{r.value=!1}}function A(){a.Kt.getData(a.a.CHAT,"messageSource")!==void 0&&a.Kt.update(a.a.CHAT,"messageSource",void 0)}function l(){i.value=0}function B(){A(),l(),v("scrollToLatestMessage")}function K(){n.value&&(n.value=!1,l())}return x({judgeScrollOverOneScreen:q,isScrollButtonVisible:n,hideScrollButton:K}),(e,t)=>s.e$1({a:s.unref(n)},s.unref(n)?s.e$1({b:s.unref(m.isTikTok)},s.unref(m.isTikTok)?{c:s.unref(k.arrowDownIcon)}:{},{d:s.p({width:"15px",height:s.unref(m.isWeChat)?"12px":"15px",file:s.unref(k.arrowDownIcon)}),e:s.unref(g)},s.unref(g)?{f:s.t(s.unref(g))}:{},{g:s.o(B)}):{})}}),E=s._export_sfc(V,[["__scopeId","data-v-cf8ff77b"]]);wx.createComponent(E); //# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/ai-desk-customer-uniapp/components/CustomerServiceChat/message-list/scroll-button/index.js.map