"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[947],{5053:function(e,a,n){var t=n(8870),s=n(1212),c=n(467),r=n(5544),o=n(6540),i=n(758),l=n.n(i),u=n(118),h=n(374),d=n(3401),v=n(7745),m=n(9672),_=n(4848);function p(){var e=(0,h.v)(),a=e.statusBarHeight,n=e.safeBottom,t=(0,i.useRouter)(),p=t.params.conversationId||"",f=t.params.targetUserId||"",x=decodeURIComponent(t.params.title||"\u804a\u5929"),b=(0,o.useState)(p),S=(0,r.A)(b,2),j=S[0],w=S[1],N=(0,o.useState)(null),I=(0,r.A)(N,2),A=I[0],g=I[1],k=(0,o.useState)([]),y=(0,r.A)(k,2),U=y[0],B=y[1],C=(0,o.useState)(""),E=(0,r.A)(C,2),M=E[0],T=E[1],Y=(0,o.useState)(!1),z=(0,r.A)(Y,2),R=z[0],D=z[1],H=(0,o.useState)(0),J=(0,r.A)(H,2),K=J[0],O=J[1],G=(0,o.useRef)(null),P=function(){var e=(0,c.A)((0,s.A)().m(function e(){var a;return(0,s.A)().w(function(e){while(1)switch(e.n){case 0:return e.n=1,(0,m.fG)({conversationId:j||void 0,targetUserId:j?void 0:f||void 0});case 1:a=e.v,a.conversationId&&a.conversationId!==j&&w(a.conversationId),a.peer&&g(a.peer),B(a.messages),O(function(e){return e+1e5});case 2:return e.a(2)}},e)}));return function(){return e.apply(this,arguments)}}();(0,o.useEffect)(function(){P()},[]),(0,i.useDidShow)(function(){G.current=setInterval(P,5e3)}),(0,i.useDidHide)(function(){G.current&&clearInterval(G.current)}),(0,o.useEffect)(function(){return function(){G.current&&clearInterval(G.current)}},[]);var W=function(){var e=(0,c.A)((0,s.A)().m(function e(){var a,n;return(0,s.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(a=M.trim(),a&&!R){e.n=1;break}return e.a(2);case 1:return D(!0),T(""),e.p=2,e.n=3,(0,m._z)(a,{conversationId:j||void 0,toUserId:j?void 0:f||void 0});case 3:return n=e.v,n.conversationId&&w(n.conversationId),e.n=4,P();case 4:e.n=6;break;case 5:e.p=5,e.v,l().showToast({title:"\u53d1\u9001\u5931\u8d25",icon:"none"}),T(a);case 6:return e.p=6,D(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),q=(null===A||void 0===A?void 0:A.name)||x;return(0,_.jsxs)(u.Ss,{className:"chat",children:[(0,_.jsx)(u.Ss,{className:"chat__nav",style:{paddingTop:"".concat(a,"px")},children:(0,_.jsxs)(u.Ss,{className:"chat__nav-row",children:[(0,_.jsx)(u.Ss,{className:"chat__back",onClick:function(){return l().navigateBack()},children:(0,_.jsx)(d.A,{name:"chev",size:22,className:"chat__back-icon"})}),(0,_.jsx)(u.EY,{className:"chat__title",children:q}),(0,_.jsx)(u.Ss,{className:"chat__nav-spacer"})]})}),(0,_.jsx)(u.BM,{scrollY:!0,className:"chat__scroll",scrollTop:K,scrollWithAnimation:!0,enhanced:!0,showScrollbar:!1,children:(0,_.jsx)(u.Ss,{className:"chat__list",children:0===U.length?(0,_.jsx)(u.EY,{className:"chat__empty",children:"\u8fd8\u6ca1\u6709\u6d88\u606f\uff0c\u6253\u4e2a\u62db\u547c\u5427 \ud83d\udc4b"}):U.map(function(e){return(0,_.jsxs)(u.Ss,{className:"chat__row ".concat(e.fromMe?"chat__row--me":""),children:[e.fromMe?null:(0,_.jsx)(v.A,{avatarKey:null===A||void 0===A?void 0:A.avatarKey,avatarUrl:null===A||void 0===A?void 0:A.avatarUrl,size:"sm"}),(0,_.jsxs)(u.Ss,{className:"chat__bubble-wrap",children:[(0,_.jsx)(u.Ss,{className:"chat__bubble ".concat(e.fromMe?"chat__bubble--me":""),children:e.content}),(0,_.jsx)(u.EY,{className:"chat__time",children:e.timeText})]})]},e._id)})})}),(0,_.jsxs)(u.Ss,{className:"chat__input-bar",style:{paddingBottom:"".concat(Math.max(12,n),"px")},children:[(0,_.jsx)(u.pd,{className:"chat__input",value:M,placeholder:"\u53d1\u6d88\u606f\u2026",placeholderClass:"chat__input-ph",confirmType:"send",onInput:function(e){return T(e.detail.value)},onConfirm:W}),(0,_.jsx)(u.Ss,{className:"chat__send ".concat(M.trim()?"":"chat__send--disabled"),onClick:W,children:"\u53d1\u9001"})]})]})}var f={},x=(0,t.eU)(p,"pages/chat/index",{root:{cn:[]}},f||{});p&&p.behaviors&&(x.behaviors=(x.behaviors||[]).concat(p.behaviors));Page(x)}},function(e){var a=function(a){return e(e.s=a)};e.O(0,[907,96,76],function(){return a(5053)});e.O()}]);