import{_ as e,b as a,aG as r,aI as o,z as t,d as u,e as l,f as s,w as i,k as m,i as d,o as n,h as p,j as h,N as g,m as c}from"./index-CxGmch-J.js";import{_ as f}from"./next-watermark.B0wpWeDX.js";import{_ as k}from"./image-upload.Dhz4jHDi.js";import{_ as I}from"./head-image.DN8AEIH3.js";import{a as N,_ as b,b as w}from"./uni-forms.DkKKTD6Z.js";import"./uni-icons.C7m4sqJM.js";const G=e({data:()=>({group:{},rules:{name:{rules:[{required:!0,errorMessage:"请输入群聊名称"}]}}}),methods:{submit(){this.group.id?this.modifyGroup():this.createNewGroup()},onUnloadImageSuccess(e,a){this.group.headImage=a.data.originUrl,this.group.headImageThumb=a.data.originUrl},modifyGroup(){this.$http({url:"/group/modify",method:"PUT",data:this.group}).then((e=>{this.groupStore.updateGroup(e),a({title:"修改群聊信息成功",icon:"none"}),setTimeout((()=>{let e=r();e[e.length-2].$vm.loadGroupInfo(),o()}),1e3)}))},createNewGroup(){let e={...this.group};e.remarkNickName||(e.remarkNickName=this.userStore.userInfo.nickName),this.$http({url:"/group/create",method:"POST",data:e}).then((e=>{this.groupStore.addGroup(e),a({title:"群聊创建成功，快邀请小伙伴进群吧",icon:"none",duration:1500}),setTimeout((()=>{t({url:"/pages/group/group-info?id="+e.id})}),1500)}))},loadGroupInfo(e){this.$http({url:`/group/find/${e}`,method:"GET"}).then((e=>{this.group=e,this.chatStore.updateChatFromGroup(e),this.groupStore.updateGroup(e)}))},initNewGroup(){let e=this.userStore.userInfo;this.group={name:`${e.userName}创建的群聊`,headImage:e.headImage,headImageThumb:e.headImageThumb,ownerId:this.userStore.userInfo.id}}},computed:{isOwner(){return this.userStore.userInfo.id==this.group.ownerId}},onLoad(e){e.id?this.loadGroupInfo(e.id):this.initNewGroup()}},[["render",function(e,a,r,o,t,G){const S=u(l("next-watermark"),f),_=d,y=g,V=u(l("image-upload"),k),T=u(l("head-image"),I),U=u(l("uni-forms-item"),N),x=u(l("uni-easyinput"),b),j=u(l("uni-forms"),w),O=c;return 1==e.userStore.userInfo.type?(n(),s(_,{key:0,class:"page group-edit"},{default:i((()=>[p(_,null,{default:i((()=>[p(S,{watermark:String(e.userStore.watermark)},null,8,["watermark"])])),_:1}),p(j,{ref:"form",modelValue:t.group,rules:t.rules,"validate-trigger":"bind","label-position":"top","label-width":"100%"},{default:i((()=>[p(U,{label:"群聊头像:",name:"headImage"},{default:i((()=>[G.isOwner?(n(),s(V,{key:0,onSuccess:G.onUnloadImageSuccess},{default:i((()=>[p(y,{src:t.group.headImageThumb,class:"group-image"},null,8,["src"])])),_:1},8,["onSuccess"])):m("",!0),G.isOwner?m("",!0):(n(),s(T,{key:1,name:t.group.showGroupName,url:t.group.headImageThumb,size:200},null,8,["name","url"]))])),_:1}),p(U,{label:"群聊名称:",name:"name",required:!0},{default:i((()=>[p(x,{type:"text",modelValue:t.group.name,"onUpdate:modelValue":a[0]||(a[0]=e=>t.group.name=e),disabled:!G.isOwner,placeholder:"请输入群聊名称"},null,8,["modelValue","disabled"])])),_:1}),p(U,{label:"群聊备注:",name:"remarkGroupName"},{default:i((()=>[p(x,{modelValue:t.group.remarkGroupName,"onUpdate:modelValue":a[1]||(a[1]=e=>t.group.remarkGroupName=e),type:"text",placeholder:t.group.name},null,8,["modelValue","placeholder"])])),_:1}),p(U,{label:"我在本群的昵称:",name:"remarkNickName"},{default:i((()=>[p(x,{modelValue:t.group.remarkNickName,"onUpdate:modelValue":a[2]||(a[2]=e=>t.group.remarkNickName=e),type:"text",placeholder:e.userStore.userInfo.nickName},null,8,["modelValue","placeholder"])])),_:1}),p(U,{label:"群公告:",name:"notice"},{default:i((()=>[p(x,{type:"textarea",modelValue:t.group.notice,"onUpdate:modelValue":a[3]||(a[3]=e=>t.group.notice=e),disabled:!G.isOwner,placeholder:"请输入群公告"},null,8,["modelValue","disabled"])])),_:1})])),_:1},8,["modelValue","rules"]),p(O,{type:"primary",onClick:a[4]||(a[4]=e=>G.submit())},{default:i((()=>[h("提交")])),_:1})])),_:1})):m("",!0)}],["__scopeId","data-v-2d07d95c"]]);export{G as default};
