"use strict";var $=Object.defineProperty,L=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var v=(s,l,d)=>l in s?$(s,l,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[l]=d,I=(s,l)=>{for(var d in l||(l={}))x.call(l,d)&&v(s,d,l[d]);if(T)for(var d of T(l))G.call(l,d)&&v(s,d,l[d]);return s},f=(s,l)=>L(s,_(l));var e=require("../../../../common/vendor.js"),C=require("../../../../store/index.js"),y=require("../../../../common/assets.js");require("../../../../store/modules.js");require("../../../../store/modules/timStore.js");const S=e.defineComponent({name:"Create",props:{},setup(s,l){const d=e.index.$TUIKit.TUIConversationServer,{userInfo:u}=C.store.state.timStore,t=e.reactive({userID:(u==null?void 0:u.userID)||"",inputUserID:"",chooseUserList:[],title:"\u53D1\u8D77\u4F1A\u8BDD",myProfile:{},type:e.index.$TIM.TYPES.CONV_C2C});e.onLoad(o=>{t.title=o&&o.title||"\u53D1\u8D77\u4F1A\u8BDD",t.type=o&&o.type||e.index.$TIM.TYPES.CONV_C2C});const U=o=>{t.inputUserID=o.detail.value,e.index.$TUIKit.getMyProfile().then(r=>{t.myProfile=r.data}).catch(r=>{console.warn("getMyProfile error:",r)})},n=()=>{if(!t.inputUserID)return;const o=[t.inputUserID];e.index.$TUIKit.getUserProfile({userIDList:o}).then(r=>{if(e.index.hideLoading(),r.data.length>0){const i=f(I({},r.data[0]),{isChoose:!1});t.chooseUserList.filter(a=>i.userID===a.userID).length===0&&t.chooseUserList.push(i)}else e.index.showToast({title:"\u641C\u7D22\u7528\u6237\u4E0D\u5B58\u5728",icon:"error"}),t.inputUserID=""}).catch(r=>{e.index.hideLoading()})},h=o=>{const r=t.chooseUserList.map(i=>o.userID==i.userID?f(I({},i),{isChoose:!i.isChoose}):i);t.chooseUserList=r},P=()=>{var r,i;const o=t.chooseUserList.filter(a=>a.isChoose);if(o.length>0)switch(t.type){case e.index.$TIM.TYPES.CONV_C2C:{if(o.length>1){e.index.showToast({title:"\u201C\u53D1\u8D77\u4F1A\u8BDD\u201D\u4EC5\u80FD\u9009\u62E9\u4E00\u4E2A\u7528\u6237",icon:"none"});return}else{const a=`C2C${o[0].userID}`;console.log(a),m(a)}break}case e.index.$TIM.TYPES.GRP_WORK:case e.index.$TIM.TYPES.GRP_PUBLIC:case e.index.$TIM.TYPES.GRP_MEETING:{let a="";o.length>2?a=o.slice(0,3).map(c=>c.nick||c.userID).join(",")||"":a=o.map(c=>c.nick||c.userID).join(",")+"\u3001"+(((r=t.myProfile)==null?void 0:r.nick)||((i=t.myProfile)==null?void 0:i.userID));const p={avatar:"https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",type:t.type,name:a,memberList:o.map(c=>({userID:c.userID,role:c.role,memberCustomField:c.memberCustomField}))};e.index.showLoading({title:"\u7FA4\u7EC4\u521B\u5EFA\u4E2D\u2026"}),e.index.$TUIKit.createGroup(p).then(c=>{e.index.hideLoading();const{groupID:g}=c.data&&c.data.group;if(g){const D=`GROUP${g}`;m(D)}}).catch(c=>{e.index.showToast({title:"\u7FA4\u7EC4\u521B\u5EFA\u5931\u8D25\uFF01"}),e.index.hideLoading()});break}}else e.index.showToast({title:"\u8BF7\u9009\u62E9\u76F8\u5173\u7528\u6237",icon:"none"})},m=o=>{C.store.commit("timStore/setConversationID",o),d.setMessageRead(o),d.getConversationProfile(o).then(r=>{var p;const{conversation:i}=r.data;console.log("create conversation response = ",r),C.store.commit("timStore/setConversation",i);let a="../TUIChat/index";if(o.slice(0,5)==="GROUP"){const{name:c}=i.groupProfile;a=`${a}?conversationName=${c}`}else o.slice(0,3)==="C2C"&&(i.userProfile,a=`${a}?conversationName=${((p=i.userProfile.nick)==null?void 0:p.nick)||i.userProfile.userID}`);e.index.redirectTo({url:a})}).catch(r=>{console.warn("\u83B7\u53D6 group profile \u5F02\u5E38 = ",r)})};return f(I({},e.toRefs(t)),{handleUserIdInput:U,handleGetUserProfileInfo:n,handleChoose:h,handleCreateGroup:P})}});function k(s,l,d,u,t,U){return{a:s.inputUserID,b:e.o((...n)=>s.handleUserIdInput&&s.handleUserIdInput(...n)),c:e.o((...n)=>s.handleGetUserProfileInfo&&s.handleGetUserProfileInfo(...n)),d:e.o((...n)=>s.handleGetUserProfileInfo&&s.handleGetUserProfileInfo(...n)),e:e.f(s.chooseUserList,(n,h,P)=>e.e({a:n.isChoose},n.isChoose?{b:y._imports_0$1}:{},{c:n.avatar||"https://sdk-web-1252463788.cos.ap-hongkong.myqcloud.com/component/TUIKit/assets/avatar_21.png",d:e.t(n.nick),e:e.t(n.userID),f:h,g:e.o(m=>s.handleChoose(n),h)})),f:e.o((...n)=>s.handleCreateGroup&&s.handleCreateGroup(...n))}}var w=e._export_sfc(S,[["render",k],["__scopeId","data-v-0910882b"],["__file","E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages/TUIKit/TUIPages/TUIConversation/create.vue"]]);wx.createPage(w);
