Files
Pawer/dist/pages/user-profile/index.js

1 line
6.7 KiB
JavaScript

"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[468],{4470:function(e,s,n){var r=n(8870),t=n(1212),i=n(467),a=n(9379),c=n(5544),l=n(436),o=n(6540),u=n(758),f=n.n(u),p=n(118),d=n(374),h=n(3401),_=n(2538),m=n(1798),x=n(3972),v=n(7896),A=n(1926),j=n(4149),k=n(994),N=n(5313),S=n(5596),g=n(4848),b=20;function y(e,s){var n=new Set(e.map(function(e){return e._id}));return[].concat((0,l.A)(e),(0,l.A)(s.filter(function(e){return!n.has(e._id)})))}function w(){var e=(0,d.v)(),s=e.statusBarHeight,n=e.safeBottom,r=(0,u.useRouter)(),l=r.params.userId||"",w=(0,o.useState)(null),E=(0,c.A)(w,2),Y=E[0],B=E[1],M=(0,o.useState)([]),T=(0,c.A)(M,2),I=T[0],C=T[1],U=(0,o.useState)([]),O=(0,c.A)(U,2),R=O[0],z=O[1],F=(0,o.useState)(!0),H=(0,c.A)(F,2),J=H[0],L=H[1],P=(0,o.useState)(!1),Q=(0,c.A)(P,2),$=Q[0],D=Q[1],G=(0,o.useState)(""),K=(0,c.A)(G,2),V=K[0],X=K[1],q=(0,k.d)(480),W=(0,o.useRef)([]),Z=(0,o.useRef)(new Set);(0,o.useEffect)(function(){W.current=R},[R]),(0,o.useEffect)(function(){return(0,N.Fo)(function(e){var s=e.postId,n=e.liked,r=e.likes;z(function(e){return e.map(function(e){return e._id===s?e.likedByMe===n&&e.counts.likes===r?e:(0,a.A)((0,a.A)({},e),{},{likedByMe:n,counts:(0,a.A)((0,a.A)({},e.counts),{},{likes:r})}):e})})})},[]);var ee=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";l&&(e&&D(!0),(0,j.hv)({authorId:l,cursor:s,pageSize:b}).then(function(s){z(function(n){return e?y(n,s.list):s.list}),X(s.nextCursor||"")}).finally(function(){e&&D(!1)}))};(0,o.useEffect)(function(){l?(L(!0),Promise.all([(0,A.E$)(l),(0,j.hv)({authorId:l,pageSize:b})]).then(function(e){var s=(0,c.A)(e,2),n=s[0],r=s[1];B(n.user),C(n.pets),z(r.list),X(r.nextCursor||"")}).finally(function(){return L(!1)})):L(!1)},[l]);var se=function(){J||$||!V||ee(!0,V)},ne=function(){var e=(0,i.A)((0,t.A)().m(function e(s){var n,r,i,c;return(0,t.A)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.n=1,(0,S.HQ)();case 1:if(e.v){e.n=2;break}return e.a(2);case 2:if(!Z.current.has(s)){e.n=3;break}return e.a(2);case 3:if(n=W.current.find(function(e){return e._id===s}),n){e.n=4;break}return e.a(2);case 4:return r=!n.likedByMe,i=Math.max(0,n.counts.likes+(r?1:-1)),Z.current.add(s),r&&q.show(),z(function(e){return e.map(function(e){return e._id===s?(0,a.A)((0,a.A)({},e),{},{likedByMe:r,counts:(0,a.A)((0,a.A)({},e.counts),{},{likes:i})}):e})}),e.p=5,e.n=6,(0,j.O$)(s,r);case 6:c=e.v,z(function(e){return e.map(function(e){return e._id===s?(0,a.A)((0,a.A)({},e),{},{likedByMe:c.liked,counts:(0,a.A)((0,a.A)({},e.counts),{},{likes:c.likes})}):e})}),e.n=8;break;case 7:e.p=7,e.v,z(function(e){return e.map(function(e){return e._id===s?(0,a.A)((0,a.A)({},e),{},{likedByMe:n.likedByMe,counts:(0,a.A)((0,a.A)({},e.counts),{},{likes:n.counts.likes})}):e})}),f().showToast({title:"\u70b9\u8d5e\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5",icon:"none"});case 8:return e.p=8,Z.current.delete(s),e.f(8);case 9:return e.a(2)}},e,null,[[5,7,8,9]])}));return function(s){return e.apply(this,arguments)}}(),re=function(){var e=(0,i.A)((0,t.A)().m(function e(){return(0,t.A)().w(function(e){while(1)switch(e.n){case 0:if(Y){e.n=1;break}return e.a(2);case 1:return e.n=2,(0,S.HQ)();case 2:if(e.v){e.n=3;break}return e.a(2);case 3:f().navigateTo({url:"/pages/chat/index?targetUserId=".concat(Y._id,"&title=").concat(encodeURIComponent(Y.nickname))});case 4:return e.a(2)}},e)}));return function(){return e.apply(this,arguments)}}();return(0,g.jsxs)(p.Ss,{className:"user-profile",children:[(0,g.jsx)(p.Ss,{className:"user-profile__nav",style:{paddingTop:"".concat(s,"px")},children:(0,g.jsxs)(p.Ss,{className:"user-profile__nav-row",children:[(0,g.jsx)(p.Ss,{className:"user-profile__back",onClick:function(){return f().navigateBack()},children:(0,g.jsx)(h.A,{name:"chev",size:22,className:"user-profile__back-icon"})}),(0,g.jsx)(p.EY,{className:"user-profile__title",children:(null===Y||void 0===Y?void 0:Y.nickname)||"\u4e2a\u4eba\u4e3b\u9875"}),(0,g.jsx)(p.Ss,{className:"user-profile__nav-spacer"})]})}),(0,g.jsxs)(p.BM,{scrollY:!0,className:"user-profile__scroll",enhanced:!0,showScrollbar:!1,lowerThreshold:120,onScrollToLower:se,children:[Y?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(_.A,{user:Y}),(0,g.jsx)(m.A,{stats:Y.stats}),(0,g.jsx)(p.Ss,{className:"user-profile__actions",children:(0,g.jsx)(p.Ss,{className:"user-profile__primary",onClick:re,children:"\u53d1\u6d88\u606f"})}),(0,g.jsxs)(p.Ss,{className:"user-profile__section",children:[(0,g.jsxs)(p.EY,{className:"user-profile__section-title",children:["\u6bdb\u5b69\u5b50 \xb7 ",I.length]}),(0,g.jsx)(p.BM,{scrollX:!0,showScrollbar:!1,className:"user-profile__pet-scroll",children:(0,g.jsxs)(p.Ss,{className:"user-profile__pet-list",children:[I.map(function(e){return(0,g.jsxs)(p.Ss,{className:"user-profile__pet-card",children:[(0,g.jsxs)(p.Ss,{className:"user-profile__pet-photo ".concat(e.photoUrl?"":e.photoKey),children:[e.photoUrl?(0,g.jsx)(p._V,{className:"user-profile__pet-img",src:e.photoUrl,mode:"aspectFill"}):null,(0,g.jsx)(p.EY,{className:"user-profile__pet-label",children:"cat"===e.species?"CAT":"DOG"})]}),(0,g.jsxs)(p.EY,{className:"user-profile__pet-name",children:[e.name," \xb7 ",e.breed]}),(0,g.jsxs)(p.EY,{className:"user-profile__pet-meta",children:[e.ageText||"\u5f85\u5b8c\u5584"," \xb7 ",e.tags[0]||"\u5f85\u5b8c\u5584"]})]},e._id)}),0===I.length?(0,g.jsx)(p.EY,{className:"user-profile__empty-small",children:"\u8fd8\u6ca1\u6709\u516c\u5f00\u7684\u6bdb\u5b69\u5b50"}):null]})})]}),(0,g.jsx)(p.Ss,{className:"user-profile__section",children:(0,g.jsx)(p.EY,{className:"user-profile__section-title",children:"\u516c\u5f00\u52a8\u6001"})}),(0,g.jsxs)(p.Ss,{className:"user-profile__feed",children:[R.map(function(e){return(0,g.jsx)(x.A,{post:e,onLike:ne,onOpen:function(s){(0,N.bE)(e),f().navigateTo({url:"/pages/post-detail/index?postId=".concat(s)})}},e._id)}),J&&0===R.length?(0,g.jsx)(p.EY,{className:"user-profile__empty",children:"\u52a0\u8f7d\u4e2d\u2026"}):J||0!==R.length?$?(0,g.jsx)(p.EY,{className:"user-profile__empty",children:"\u52a0\u8f7d\u66f4\u591a\u4e2d\u2026"}):R.length>0&&!V?(0,g.jsx)(p.EY,{className:"user-profile__empty",children:"\u6682\u65f6\u6ca1\u6709\u66f4\u591a\u4e86"}):null:(0,g.jsx)(p.EY,{className:"user-profile__empty",children:"\u8fd8\u6ca1\u6709\u516c\u5f00\u52a8\u6001"})]})]}):(0,g.jsx)(p.EY,{className:"user-profile__empty",children:J?"\u52a0\u8f7d\u4e2d\u2026":"\u7528\u6237\u4e0d\u5b58\u5728"}),(0,g.jsx)(p.Ss,{style:{height:"".concat(Math.max(20,n),"px")}})]}),(0,g.jsx)(v.A,{visible:q.visible})]})}var E={},Y=(0,r.eU)(w,"pages/user-profile/index",{root:{cn:[]}},E||{});w&&w.behaviors&&(Y.behaviors=(Y.behaviors||[]).concat(w.behaviors));Page(Y)}},function(e){var s=function(s){return e(e.s=s)};e.O(0,[907,96,76],function(){return s(4470)});e.O()}]);