jiuyiUniapp/jiuyi/unpackage/dist/build/web/assets/TUIKit-components-TUIContac...

2 lines
29 KiB
JavaScript
Raw Normal View History

2024-12-18 15:46:27 +08:00
import{b5 as t,r as e,b9 as a,o as l,c as n,u as i,B as o,a as u,E as c,O as s,b as r,_ as d,y as v,z as p,b4 as h,b7 as C,I as m,m as I,a6 as S,w as f,e as T,d as y,s as g,t as k,co as E,F as U,q as _,an as b}from"./index-CH9-aFWw.js";import{R as D,E as R,z as O,o as L,i as P,g as A,T as w,J as N,d as M,a as x,I as F,K as Y,W as G,Q as B,X as V}from"./index.C_XD_DK3.js";import{i as j}from"./index.DzsMB11z.js";import"./adapter-vue.FAvEd_HK.js";import{_ as K,e as H}from"./edit.B9Urilbg.js";import{b as W}from"./index.BcNTMUDJ.js";import{b as $,d as q}from"./lodash.CBwPAxVQ.js";import{_ as J}from"./_plugin-vue_export-helper.BCo6x5W8.js";import{d as X}from"./down-icon.DejhYoTd.js";import{r as z}from"./right-icon.-uAfiCH7.js";import{A as Q}from"./index.DHwyKTWe.js";import{c as Z,d as tt,e as et}from"./constant.BaYkq7sJ.js";class at{constructor(){D.registerService(R.TUIContact.SERVICE.NAME,this),this.onCallParamsMap=new Map,this.onCallCallbackMap=new Map,this.constants=R}static getInstance(){return at.instance||(at.instance=new at),at.instance}getOnCallParams(t){return this.onCallParamsMap.get(t)}getOnCallCallback(t){return this.onCallCallbackMap.get(t)}async onCall(t,e,a){var l;this.onCallParamsMap.set(t,e),this.onCallCallbackMap.set(t,a),t===R.TUIContact.SERVICE.METHOD.SELECT_FRIEND&&(O.update(L.CUSTOM,"isShowSelectFriendComponent",!0),P&&(null==(l=j)||l.reLaunch({url:"/TUIKit/components/TUIContact/index"})))}}const lt=t({__name:"index",setup(t){const o=at.getInstance(),u=o.constants,c=e(!1),s=e([]),r=e([]),d=e(null),v=e({isRadio:!1,isNeedSearch:!1,title:""});a((()=>{const t=o.getOnCallParams(u.TUIContact.SERVICE.METHOD.SELECT_FRIEND);var e;v.value.title=t.title,v.value.isRadio=t.isRadio,v.value.isNeedSearch=t.isNeedSearch,t.isNeedSearch&&(e=t.isNeedSearch,d.value=D.getService(u.TUISearch.SERVICE.NAME),d.value?c.value=e:console.warn("请添加 TUISearch 组件")),A.getFriendList().then((t=>{s.value=t.data.map((t=>t.profile)),r.value=s.value})).catch((t=>{console.warn("getFriendList error:",t)}))}));const p=t=>{O.update(L.CUSTOM,"isShowSelectFriendComponent",!1);const e=o.getOnCallCallback(u.TUIContact.SERVICE.METHOD.SELECT_FRIEND);e&&e(t)},h=()=>{w({message:N.t("TUIGroup.该用户不存在"),type:M.ERROR}),r.value=[...s.value]},C=async t=>{if(!t)return r.value=s.value;try{const e=await d.value.searchUser(t);if(!e.data[0])return h();r.value=e.data;const a=s.value.filter((t=>t.userID===e.data[0].userID));s.value=a.length?s.value:[...s.value,...r.value]}catch(e){return h()}};return(t,e)=>(l(),n(K,{isRadio:i(v).isRadio,isNeedSearch:i(v).isNeedSearch,title:i(v).title,userList:i(r),onSearch:C,onComplete:p},null,8,["isRadio","isNeedSearch","title","userList"]))}}),nt=J(t({__name:"index",setup(t){const a=N.t("TUIContact.输入ID"),n=e(!1),I=e(""),S=e({user:{label:"联系人",list:[]},group:{label:"群聊",list:[]}}),f=$((function(t){n.value=t}),200),T=async()=>{I.value&&(D.callService({serviceName:R.TUISearch.SERVICE.NAME,method:R.TUISearch.SERVICE.METHOD.SEARCH_USER,params:{userID:I.value}}).then((t=>{S.value.user.list=t.data})).catch((t=>{S.value.user.list=[],console.warn("search user error",t)})),D.callService({serviceName:R.TUISearch.SERVICE.NAME,method:R.TUISearch.SERVICE.METHOD.SEARCH_GROUP,params:{groupID:I.value}}).then((t=>{S.value.group.list=[t.data.group]})).catch((t=>{S.value.group.list=[],console.warn("search group error",t)})))};return o((()=>S.value),(()=>{O.update(L.CUSTOM,"currentContactSearchResult",S.value)}),{deep:!0,immediate:!0}),o((()=>n.value),(()=>{O.update(L.CUSTOM,"currentContactSearchingStatus",n.value),n.value&&(I.value="",S.value.user.list=[],S.value.group.list=[])}),{deep:!0,immediate:!0}),j.updateContactSearch=T,j.closeSearching=()=>{n.value=!1},(t,e)=>{const o=m;return l(),u("div",{class:c(["tui-contact-search",!i(x)&&"tui-contact-search-h5"])},[i(n)&&i(x)?p("",!0):(l(),u("div",{key:0,class:c(["tui-contact-search-header",!i(x)&&"tui-contact-search-h5-header",i(n)&&"tui-contact-searching-h5-header"]),onClick:e[1]||(e[1]=t=>i(f)(!0))},[s("div",{class:c(["tui-contact-search-header-icon",!i(x)&&"tui-con