"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[741],{8680:function(e,t,s){var a=s(8870),n=s(436),c=s(1212),i=s(9379),o=s(467),l=s(5544),r=s(6540),u=s(758),d=s.n(u),m=s(118),p=s(374),h=s(3401),_=s(7745),x=s(3972),v=s(7896),f=s(4149),A=s(994),j=s(4848);function N(){var e=(0,p.v)(),t=e.statusBarHeight,s=e.safeBottom,a=(0,u.useRouter)(),N=a.params.postId||"",k=(0,r.useState)(null),b=(0,l.A)(k,2),S=b[0],w=b[1],y=(0,r.useState)([]),g=(0,l.A)(y,2),B=g[0],E=g[1],Y=(0,r.useState)(!0),M=(0,l.A)(Y,2),T=M[0],C=M[1],I=(0,r.useState)(""),K=(0,l.A)(I,2),O=K[0],U=K[1],z=(0,r.useState)(!1),J=(0,l.A)(z,2),P=J[0],H=J[1],L=(0,A.d)(480),R=function(){N?(C(!0),(0,f.aC)(N).then(function(e){w(e.post),E(e.comments)}).finally(function(){return C(!1)})):C(!1)};(0,r.useEffect)(function(){R()},[N]);var $=function(){var e=(0,o.A)((0,c.A)().m(function e(t){var s,a,n;return(0,c.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(S){e.n=1;break}return e.a(2);case 1:return s=!S.likedByMe,s&&L.show(),a=(0,i.A)((0,i.A)({},S),{},{likedByMe:s,counts:(0,i.A)((0,i.A)({},S.counts),{},{likes:Math.max(0,S.counts.likes+(s?1:-1))})}),w(a),e.p=2,e.n=3,(0,f.O$)(t,s);case 3:n=e.v,w(function(e){return e?(0,i.A)((0,i.A)({},e),{},{likedByMe:n.liked,counts:(0,i.A)((0,i.A)({},e.counts),{},{likes:n.likes})}):e}),e.n=5;break;case 4:e.p=4,e.v,w(S),d().showToast({title:"\u70b9\u8d5e\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5",icon:"none"});case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=(0,o.A)((0,c.A)().m(function e(){var t,s;return(0,c.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(t=O.trim(),t&&!P&&S){e.n=1;break}return e.a(2);case 1:return H(!0),U(""),e.p=2,e.n=3,(0,f.SI)(S._id,t);case 3:s=e.v,E(function(e){return[].concat((0,n.A)(e),[{_id:s.commentId,author:{id:"me",name:"\u6211",avatarKey:"gradient-avatar-1"},content:t,timeText:"\u521a\u521a"}])}),w(function(e){return e?(0,i.A)((0,i.A)({},e),{},{counts:(0,i.A)((0,i.A)({},e.counts),{},{comments:s.comments})}):e}),e.n=5;break;case 4:e.p=4,e.v,d().showToast({title:"\u8bc4\u8bba\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5",icon:"none"}),U(t);case 5:return e.p=5,H(!1),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(){return e.apply(this,arguments)}}();return(0,j.jsxs)(m.Ss,{className:"post-detail",children:[(0,j.jsx)(m.Ss,{className:"post-detail__nav",style:{paddingTop:"".concat(t,"px")},children:(0,j.jsxs)(m.Ss,{className:"post-detail__nav-row",children:[(0,j.jsx)(m.Ss,{className:"post-detail__back",onClick:function(){return d().navigateBack()},children:(0,j.jsx)(h.A,{name:"chev",size:22,className:"post-detail__back-icon"})}),(0,j.jsx)(m.EY,{className:"post-detail__title",children:"\u52a8\u6001\u8be6\u60c5"}),(0,j.jsx)(m.Ss,{className:"post-detail__nav-spacer"})]})}),(0,j.jsxs)(m.BM,{scrollY:!0,className:"post-detail__scroll",enhanced:!0,showScrollbar:!1,children:[S?(0,j.jsx)(m.Ss,{className:"post-detail__post",children:(0,j.jsx)(x.A,{post:S,onLike:$,enableImagePreview:!0})}):null,(0,j.jsxs)(m.Ss,{className:"post-detail__comments",children:[(0,j.jsxs)(m.EY,{className:"post-detail__comments-title",children:["\u8bc4\u8bba",S?" ".concat(S.counts.comments):""]}),T&&!S?(0,j.jsx)(m.EY,{className:"post-detail__empty",children:"\u52a0\u8f7d\u4e2d\u2026"}):0===B.length?(0,j.jsx)(m.EY,{className:"post-detail__empty",children:"\u8fd8\u6ca1\u6709\u8bc4\u8bba\uff0c\u6765\u62a2\u6c99\u53d1\u5427"}):B.map(function(e){return(0,j.jsxs)(m.Ss,{className:"post-detail__comment",children:[(0,j.jsx)(_.A,{avatarKey:e.author.avatarKey,avatarUrl:e.author.avatarUrl,size:"sm"}),(0,j.jsxs)(m.Ss,{className:"post-detail__comment-body",children:[(0,j.jsxs)(m.Ss,{className:"post-detail__comment-head",children:[(0,j.jsx)(m.EY,{className:"post-detail__comment-name",children:e.author.name}),(0,j.jsx)(m.EY,{className:"post-detail__comment-time",children:e.timeText})]}),(0,j.jsx)(m.EY,{className:"post-detail__comment-text",children:e.content})]})]},e._id)})]})]}),(0,j.jsxs)(m.Ss,{className:"post-detail__input-bar",style:{paddingBottom:"".concat(Math.max(12,s),"px")},children:[(0,j.jsx)(m.pd,{className:"post-detail__input",value:O,placeholder:"\u5199\u8bc4\u8bba\u2026",placeholderClass:"post-detail__input-ph",confirmType:"send",onInput:function(e){return U(e.detail.value)},onConfirm:q}),(0,j.jsx)(m.Ss,{className:"post-detail__send ".concat(O.trim()?"":"post-detail__send--disabled"),onClick:q,children:"\u53d1\u9001"})]}),(0,j.jsx)(v.A,{visible:L.visible})]})}var k={},b=(0,a.eU)(N,"pages/post-detail/index",{root:{cn:[]}},k||{});N&&N.behaviors&&(b.behaviors=(b.behaviors||[]).concat(N.behaviors));Page(b)}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[907,96,76],function(){return t(8680)});e.O()}]);