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 m,k as i,i as d,o as n,h as p,j as h,N as g,m as c}from"./index--EfctvOJ.js";import{_ as f}from"./next-watermark.C9RPBMpW.js";import{_ as k}from"./image-upload.BfKu7NpJ.js";import{_ as I}from"./head-image.DGgx_rOw.js";import{a as b,_ as N,b as G}from"./uni-forms.BlUPIWlI.js";import"./uni-icons.5vxwhpmM.js";const w=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.thumbUrl},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,w){const S=u(l("next-watermark"),f),_=d,y=g,V=u(l("image-upload"),k),T=u(l("head-image"),I),x=u(l("uni-forms-item"),b),U=u(l("uni-easyinput"),N),j=u(l("uni-forms"),G),O=c;return 1==e.userStore.userInfo.type?(n(),s(_,{key:0,class:"page group-edit"},{default:m((()=>[p(_,null,{default:m((()=>[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:m((()=>[p(x,{label:"群聊头像:",name:"headImage"},{default:m((()=>[w.isOwner?(n(),s(V,{key:0,onSuccess:w.onUnloadImageSuccess},{default:m((()=>[p(y,{src:t.group.headImageThumb,class:"group-image"},null,8,["src"])])),_:1},8,["onSuccess"])):i("",!0),w.isOwner?i("",!0):(n(),s(T,{key:1,name:t.group.showGroupName,url:t.group.headImageThumb,size:200},null,8,["name","url"]))])),_:1}),p(x,{label:"群聊名称:",name:"name",required:!0},{default:m((()=>[p(U,{type:"text",modelValue:t.group.name,"onUpdate:modelValue":a[0]||(a[0]=e=>t.group.name=e),disabled:!w.isOwner,placeholder:"请输入群聊名称"},null,8,["modelValue","disabled"])])),_:1}),p(x,{label:"群聊备注:",name:"remarkGroupName"},{default:m((()=>[p(U,{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(x,{label:"我在本群的昵称:",name:"remarkNickName"},{default:m((()=>[p(U,{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(x,{label:"群公告:",name:"notice"},{default:m((()=>[p(U,{type:"textarea",modelValue:t.group.notice,"onUpdate:modelValue":a[3]||(a[3]=e=>t.group.notice=e),disabled:!w.isOwner,placeholder:"请输入群公告"},null,8,["modelValue","disabled"])])),_:1})])),_:1},8,["modelValue","rules"]),p(O,{type:"primary",onClick:a[4]||(a[4]=e=>w.submit())},{default:m((()=>[h("提交")])),_:1})])),_:1})):i("",!0)}],["__scopeId","data-v-81d01480"]]);export{w as default};
