"use strict";var t=(t,e,s)=>new Promise(((o,a)=>{var l=t=>{try{i(s.next(t))}catch(e){a(e)}},n=t=>{try{i(s.throw(t))}catch(e){a(e)}},i=t=>t.done?o(t.value):Promise.resolve(t.value).then(l,n);i((s=s.apply(t,e)).next())}));const e=require("../../../../common/vendor.js"),s=require("../../../../utils/commUtils.js"),o=require("../../../../utils/http.js");if(!Array){e.resolveComponent("wd-img")()}Math;const a={__name:"UserPost",props:{post:Object},setup(a){const l=a,n=e.ref({}),i=e.ref(!1),r=e.ref({}),u=e.ref(null),d=e.ref(""),c=()=>t(this,null,(function*(){i.value=!i.value,i.value&&(yield p())})),p=(e=1,a=10)=>t(this,null,(function*(){var t;try{const t=yield o.httpGet(`/posts/commentsList?postId=${l.post.id}¤t=${e}&size=${a}`);200==t.code?r.value=t:s.toast(t.message)}catch(n){s.toast((null==(t=n.data)?void 0:t.message)||"评论获取失败")}})),m=()=>t(this,null,(function*(){var t,e;try{const e=yield o.httpPost("/posts/comments/"+l.post.id,{postId:l.post.id,content:d.value,beCommentsId:(null==(t=u.value)?void 0:t.id)||null});200==e.code?(s.toast("评论成功"),yield p(),u.value=null,d.value=""):s.toast(e.message)}catch(a){s.toast((null==(e=a.data)?void 0:e.message)||"评论失败")}})),f=()=>t(this,null,(function*(){try{const t=yield o.httpGet(`/posts/actions?postId=${l.post.id}`);200==t.code?(n.value=t.data,l.post.favorites=t.data.post.favorites,l.post.comments=t.data.post.comments,l.post.likes=t.data.post.likes,l.post.isFollowed=t.data.post.isFollowed):s.toast(t.message)}catch(t){}})),v=()=>t(this,null,(function*(){var t;try{const t=yield o.httpPost("/posts/like",{},{postId:l.post.id});200==t.code?yield f():s.toast(t.message)}catch(e){s.toast((null==(t=e.data)?void 0:t.message)||"点赞失败")}})),h=()=>t(this,null,(function*(){var t;try{const t=yield o.http({url:"/posts/unlike?postId="+l.post.id,method:"DELETE"});200==t.code?yield f():s.toast(t.message)}catch(e){s.toast((null==(t=e.data)?void 0:t.message)||"取消点赞失败")}})),g=()=>t(this,null,(function*(){var t;try{const t=yield o.httpPost("/posts/favorite",{},{postId:l.post.id});200==t.code?yield f():s.toast(t.message)}catch(e){s.toast((null==(t=e.data)?void 0:t.message)||"收藏失败")}})),y=()=>t(this,null,(function*(){var t;try{const t=yield o.http({url:"/unfavorite?postId="+l.post.id,method:"DELETE"});200==t.code?yield f():s.toast(t.message)}catch(e){s.toast((null==(t=e.data)?void 0:t.message)||"取消收藏失败")}})),w=()=>t(this,null,(function*(){var t;try{const t=yield o.httpPost("/posts/follow",{},{followingId:l.post.userId});200==t.code?yield f():s.toast(t.message)}catch(e){s.toast((null==(t=e.data)?void 0:t.message)||"关注失败")}})),I=()=>t(this,null,(function*(){try{const t=yield o.http({url:"/posts/unfollow?followingId="+l.post.userId,method:"POST"});200==t.code?yield f():s.toast(t.message)}catch(t){}}));return e.onLoad((()=>t(this,null,(function*(){yield f()})))),(t,o)=>e.e({a:null!=a.post.isFollowed},null!=a.post.isFollowed?e.e({b:!a.post.isFollowed},a.post.isFollowed?{d:e.o(I)}:{c:e.o(w)}):{},{e:e.unref(s.imgUrl)(a.post.avatar),f:e.t(a.post.username),g:e.t(a.post.location),h:e.t(a.post.time),i:e.f(a.post.images,((t,o,a)=>({a:o,b:"3c18181b-0-"+a,c:e.p({radius:8,mode:"center","enable-preview":!0,src:e.unref(s.imgUrl)(t),alt:t})}))),j:e.t(a.post.content),k:!e.unref(n).likes},e.unref(n).likes?{n:e.o(h),o:e.unref(s.imgUrl)("@/static/space/favorites.png")}:{l:e.o(v),m:e.unref(s.imgUrl)("@/static/space/thumbs.svg")},{p:e.t(a.post.likes||"0"),q:!e.unref(n).favorites},e.unref(n).favorites?{t:e.o(y),v:e.unref(s.imgUrl)("@/static/space/likes-on.png")}:{r:e.o(g),s:e.unref(s.imgUrl)("@/static/space/like.svg")},{w:e.t(a.post.favorites||"0"),x:e.o(c),y:e.unref(s.imgUrl)("@/static/space/comment.svg"),z:e.t(a.post.comments||"0"),A:e.unref(i)},e.unref(i)?e.e({B:e.unref(r).total>0},e.unref(r).total>0?e.e({C:e.f(e.unref(r).records,((t,o,a)=>({a:e.unref(s.imgUrl)(t.avatar),b:e.t(t.userName),c:e.t(t.content),d:e.t(t.createdTime),e:e.o((e=>(t=>{u.value=t})(t)),t.id),f:t.id}))),D:e.t("国内"),E:e.unref(r).total>10},e.unref(r).total>10?{F:e.o((t=>p(-1,-1)))}:{}):{}):{},{G:e.unref(i)},e.unref(i)?{H:e.unref(d),I:e.o((t=>e.isRef(d)?d.value=t.detail.value:null)),J:e.t(e.unref(u)?"@"+e.unref(u).userName:e.unref(u).userNamebeCommentId.userName),K:e.o(m)}:{})}},l=e._export_sfc(a,[["__scopeId","data-v-3c18181b"]]);wx.createComponent(l);