livingold.vue 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986
  1. <template>
  2. <view class="swiper-wrapper">
  3. <view class="container">
  4. <view class="content">
  5. <view style="position: fixed;top: 0;z-index: 5;" class="content-top">
  6. <view class="x-f">
  7. <image v-if="!scene" @click="goBack" class="w60 h64 mr26" src="/static/images/return3.png" />
  8. <view class="align-center"
  9. style="padding: 6rpx 8rpx;height: 64rpx;background: rgba(0,0,0,0.5);border-radius: 32rpx;">
  10. <u-avatar :src="liveItem.liveImgUrl||'/static/images/avatar.png'" :size="32"></u-avatar>
  11. <view class="colorf ml10 mr6">
  12. <view>{{liveItem.liveName?truncateString(liveItem.liveName,8):"未命名"}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view v-if="Array.isArray(filteredViewers)" class=" align-center" @click="toggleViewerList"
  17. style="margin-top: 120rpx;">
  18. <view v-for="(item,viewerIndex) in filteredViewers" :key="viewerIndex">
  19. <image v-if="item.avatar" class="w52 h52 mr4" style="border-radius: 26rpx;"
  20. :src="item.avatar" />
  21. <view v-else class="w52 h52 mr4"
  22. :style="{backgroundColor: getUserRandomColor(item.userId), borderRadius:'50%'}">
  23. <text class="text-white text-xs">{{getNicknameInitial(item.nickName)}}</text>
  24. </view>
  25. </view>
  26. <view class="sum">{{liveUserTotal||0}}</view>
  27. </view>
  28. </view>
  29. <!-- 右边的side -->
  30. <!-- <view class="side-group">
  31. <view class="side-item" @click="onLike">
  32. <LikeButton :initialCount="100" :heartsPerClick="5" @like="onLike" />
  33. <view>{{liveViewData && liveViewData.like||0}}</view>
  34. </view>
  35. <view class="side-item">
  36. <button open-type="share" class="button button-reset">
  37. <image class="image" src="/static/images/weixin.png" mode="widthFix" />
  38. </button>
  39. <view>分享</view>
  40. </view>
  41. </view> -->
  42. <view class="side-group">
  43. <!-- v-if="isShowRed" -->
  44. <view :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','item-box']" v-if="isShowRed"
  45. @click="onRed()">
  46. <view class="x-f">
  47. <view class="tip">领红包</view>
  48. <view class="item">
  49. <image class="w70 img" src="/static/images/redbag.png" mode="widthFix" />
  50. </view>
  51. </view>
  52. </view>
  53. <!-- v-if="isShowLottery&&countdown" -->
  54. <view :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','item-box']"
  55. v-if="isShowLottery&&countdown" @click="onLottery()">
  56. <view class="x-f">
  57. <view class="tip">抽奖</view>
  58. <view class="item">
  59. <image class="w60" src="/static/images/lottery.png" mode="widthFix" />
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- <view class="activity-box">
  65. <view class="item-box" @click="onRed()" v-if="isShowRed">
  66. <view class="x-f">
  67. <view class="tip">领红包</view>
  68. <view class="item">
  69. <image class="w70 img" src="/static/images/redbag.png" mode="widthFix" />
  70. </view>
  71. </view>
  72. </view>
  73. <view class="item-box" @click="onLottery()" v-if="isShowLottery&&countdown">
  74. <view class="x-f">
  75. <view class="tip">抽奖</view>
  76. <view class="item">
  77. <image class="w60" src="/static/images/lottery.png" mode="widthFix" />
  78. </view>
  79. </view>
  80. </view>
  81. </view> -->
  82. <view class="shop-prompt f30 x-f"
  83. v-if="showPurchasePrompt&&orderUser&&orderUser.count&&liveItem.status==2">
  84. <image class="w32 h32 mr8" src="/static/images/shopping.png" />
  85. <text>{{ orderUser.count || 0 }}人正在去购买</text>
  86. </view>
  87. <view class="videolist" v-if="liveItem.status==2">
  88. <view class="video" :class="liveItem.showType == 1 ? 'video_row' : ''">
  89. <!-- 直播 -->
  90. <live-player v-if="liveItem.livingUrl && liveItem.liveType == 1" :id="'myLivePlayer_' + liveId"
  91. :src="liveItem.livingUrl" autoplay mode="live" object-fit="contain" :muted="false"
  92. orientation="vertical" :enable-play-gesture="false" min-cache="1" max-cache="3"
  93. @statechange="onLiveStateChange($event, liveItem)" @error="onLiveError($event, liveItem)"
  94. class="item"></live-player>
  95. <!-- 录播 -->
  96. <video v-if="liveItem.videoUrl&&liveItem.liveType==2" :id="`myVideo_${liveId}`" :autoplay="true"
  97. class="item" :src="liveItem.videoUrl" :controls="false" object-fit="contain"
  98. :custom-cache="false" :enable-progress-gesture="false" vslide-gesture-in-fullscreen="false"
  99. :show-center-play-btn="false" :http-cache="false" loop @error="videoError"
  100. @timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause"
  101. @play="onVideoPlay" @waiting="onVideoWaiting" :enable-play-gesture="false"
  102. :play-strategy="1" @dblclick="preventDoubleClick" preload="auto"
  103. :enable-stash-buffer="false" :stash-initial-size="0" :stash-max-size="0" :stash-time="0"
  104. type="application/x-mpegURL">
  105. </video>
  106. <view v-if="liveItem.videoUrl&&liveItem.liveType==2" class="time">{{diffTotalTime}}
  107. </view>
  108. </view>
  109. </view>
  110. <view class="videolist" v-if="liveItem.status==3">
  111. <view class="video" :class="liveItem.showType == 1 ? 'video_row' : ''">
  112. <view class="end">直播已结束</view>
  113. </view>
  114. </view>
  115. <view class="videolist" v-if="liveItem.status==4">
  116. <view class="video" :class="liveItem.showType == 1 ? 'video_row' : ''">
  117. <!-- 直播回放 -->
  118. <video v-if="liveItem.videoUrl&&liveItem.liveType==3" :id="`myVideo_${liveId}`" class="item"
  119. :src="liveItem.videoUrl" :autoplay="true" :controls="true" object-fit="contain"
  120. :custom-cache="false" :enable-progress-gesture="liveItem.isSpeedAllowed"
  121. vslide-gesture-in-fullscreen="true" :show-center-play-btn="true" :http-cache="false" loop
  122. @error="videoError" @timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded"
  123. @pause="onVideoPause" @play="onVideoPlay" :enable-play-gesture="true" preload="auto"
  124. @waiting="onVideoWaiting" type="application/x-mpegURL">
  125. </video>
  126. <view v-if="liveItem.videoUrl&&liveItem.liveType==3" class="lable">直播回放</view>
  127. </view>
  128. </view>
  129. <view class="trailer-box" v-if="liveItem.status==1">
  130. <video v-if="liveItem.previewUrl" :id="`myVideo_${liveId}`" class="item" :src="liveItem.previewUrl"
  131. :autoplay="true" :loop="false" :controls="false" object-fit="contain" :custom-cache="false"
  132. :enable-progress-gesture="false" vslide-gesture-in-fullscreen="false"
  133. :show-center-play-btn="false" :http-cache="false" @error="videoError"
  134. @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay"
  135. :disable-progress="true" :enable-play-gesture="true" @waiting="onVideoWaiting" preload="auto"
  136. type="application/x-mpegURL">
  137. </video>
  138. <image v-if="liveItem.status==1&&!liveItem.previewUrl" class="img" src="/static/images/no_live.png">
  139. </image>
  140. <view class="countdown-item mt30 mb30" v-if="liveItem.status==1&&liveCountdown">
  141. 开播倒计时
  142. <view class="x-f">
  143. <view class="white">
  144. {{liveCountdown.hours||"00"}}
  145. </view>
  146. <view class="white">
  147. {{ liveCountdown.minutes||"00"}}
  148. </view>
  149. <view class="white">
  150. {{ liveCountdown.seconds||"00" }}
  151. </view>
  152. </view>
  153. </view>
  154. <view class="name"> {{liveItem.liveName}}</view>
  155. <view class="title" v-if="liveCountdown">暂未开播</view>
  156. <view class="button" v-if="!isAgreement" @click="handleAgreement">预约直播</view>
  157. <view class="button ash" v-if="isAgreement">已预约</view>
  158. <view class="title" v-if="!liveCountdown">主播还在来的路上</view>
  159. </view>
  160. <view class="trailer-box" v-if="!liveItem">
  161. <image class="img" src="/static/images/no_live.png">
  162. </image>
  163. <view class="title">暂无直播</view>
  164. </view>
  165. <!-- 底部聊天区域 -->
  166. <view
  167. :style="{position: 'fixed',width: '100%',bottom:isFocus ? keyboardHeight+'rpx' : '0' ,zIndex:999}">
  168. <view class="mt20" :style="{ height: isFocus ? '64rpx' : '30vh' }">
  169. <scroll-view v-if="Array.isArray(talklist)" enable-flex scroll-y="true"
  170. class="pl20 scrolly flex-1 column" style="width: calc(100% - 20rpx); height: 100%;"
  171. :scroll-top="scrollTop" ref="scrollView">
  172. <view class="list justify-start" v-for="(item,talkIndex) in (talklist||[])" :key="talkIndex"
  173. :id="`list_${talkIndex}`" v-show="item.cmd!='red'&&item.cmd!='out'&&item.cmd!='entry'">
  174. <view
  175. :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','talk-list','justify-start']">
  176. <view class="fs30" style="max-width: 100%;">
  177. <text style="color: #FFDA73;">{{item.nickName||"未命名"}}:</text>
  178. <text class='colorf'>{{item.msg}}</text>
  179. </view>
  180. </view>
  181. </view>
  182. <view v-if="showWelcomeMessage" class="welcome-message" style="max-width: 100%;">
  183. <view class="list justify-start" v-show="inAndOut.cmd=='entry'||inAndOut.cmd=='out'">
  184. <view
  185. :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','talk-list','justify-start']">
  186. <view class="fs30">
  187. <text style="color: #ff89d6;">{{inAndOut.nickName||"未命名"}} </text>
  188. <text class='colorf'>{{inAndOut.msg}}直播间</text>
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. </scroll-view>
  194. </view>
  195. <!-- 底部输入框和操作按钮 -->
  196. <view class="justify-between p24 input-bottom">
  197. <view class="x-f justify-between" :class="liveItem.showType==1? 'horizontal':'vertical'"
  198. :style="{padding: '10rpx 14rpx 10rpx 32rpx',boxSizing: 'border-box',borderRadius: '36rpx',width: isFocus ? '100%' : '420rpx'}">
  199. <input :placeholder="placeholderText" v-model="value" placeholder-style="color:#e7e7e7;"
  200. placeholder-class="placeholder-style" class="ml20 input-native" @focus="inputFocus"
  201. @blur="inputBlur"
  202. style="border: none; font-size: 32rpx; color: #ffffff; background: transparent; width: 70%;"
  203. cursor-spacing="100" :adjust-position="false" />
  204. <view class="send" @click="sendMsg()">发送</view>
  205. </view>
  206. <view class="justify-between align-center" v-if="!isFocus">
  207. <view :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','icon-bg','ml20']" @click="isMore=true,shopping=false">
  208. <image src="/static/images/more-icon.png" class="w48 h48" />
  209. </view>
  210. </view>
  211. <view class="justify-between align-center" v-if="!isFocus">
  212. <view :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','icon-bg','ml20']">
  213. <button open-type="share" class="w48 h48 button button-reset">
  214. <image class="w48 h48" src="/static/images/weixin.png" mode="widthFix" />
  215. </button>
  216. </view>
  217. </view>
  218. <view class="justify-between align-center" v-if="!isFocus">
  219. <view :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','icon-bg','ml20']"
  220. style="position: relative;" @click="onLike">
  221. <LikeButton :initialCount="100" :heartsPerClick="5" @like="onLike" />
  222. <view class="num">{{liveViewData && liveViewData.like||0}}</view>
  223. </view>
  224. </view>
  225. <view class="justify-between align-center" v-if="!isFocus">
  226. <view :class="[liveItem.showType === 1 ? 'horizontal' : 'vertical','icon-bg','ml20']"
  227. @tap="openCart()">
  228. <image src="/static/images/shopping.png" class="w48 h48" />
  229. </view>
  230. </view>
  231. </view>
  232. </view>
  233. </view>
  234. <view class="goods" v-if="isShowGoods">
  235. <view class="top">
  236. <view class="left">
  237. <image class="w30 h30 mr8" src="/static/images/signal.png" />讲解中
  238. </view>
  239. <image @click="isShowGoods=false" class="w40 h40 " src="/static/images/del_black.png" />
  240. </view>
  241. <image class="photo" :src="goodsCard.imgUrl" />
  242. <view class="item">
  243. <view class="price"><text class="red">¥{{goodsCard.price}} </text><text
  244. class="del">¥{{goodsCard.otPrice}}</text></view>
  245. <view class="title oneline-hide">{{goodsCard.productName}}</view>
  246. <view class="button" @click="goShop(goodsCard.productId,goodsCard.goodsId)">
  247. 立即抢购
  248. </view>
  249. </view>
  250. </view>
  251. <u-popup :show="isShowLotteryPop&&countdown" round='40rpx'>
  252. <view class="prize-box" style="border-radius: 40rpx;height: fit-content;">
  253. <image class="nav-img " src="/static/images/red_head.png" mode="widthFix" />
  254. <image class="bg-img " src="/static/images/red_bg.png" />
  255. <view class="prize-content">
  256. <view class=" mr20" style="display: flex;justify-content: flex-end;">
  257. <view
  258. style="width: 80rpx;height: 80rpx;display: flex; justify-content: center;align-items: center;"
  259. @click="isShowLotteryPop=false"><u-icon class="x-end" name="close" color="#fff"
  260. size="20"></u-icon>
  261. </view>
  262. </view>
  263. <view class="column align-center ">
  264. <image class="w446 h80" src="/static/images/red_title.png" />
  265. <view class="fs24 colorf x-f mt30 mb30">
  266. 开奖倒计时
  267. <view class="x-f">
  268. <view class="white-item">
  269. {{countdown.hours||"00"}}
  270. </view>
  271. <view class="white-item">
  272. {{ countdown.minutes||"00" }}
  273. </view>
  274. <view class="white-item">
  275. {{ countdown.seconds||"00" }}
  276. </view>
  277. </view>
  278. </view>
  279. <view class="item-group">
  280. <ThreeItemSwiper :products="lotteryProducts"></ThreeItemSwiper>
  281. </view>
  282. <view class="point-group" v-for="(item,index) in lotteryProducts" :key="index">
  283. </view>
  284. <view class="colorf fs28">
  285. 观看直播参与抽奖
  286. </view>
  287. <view class="button" @click="onClaim">参与抽奖</view>
  288. </view>
  289. </view>
  290. </view>
  291. </u-popup>
  292. <u-popup :show="!!integral.status" round='20rpx' mode="center" bgColor='#ffffff' zIndex='10076'>
  293. <view class="integral-box">
  294. <view class="top">
  295. <view class="title">观看视频领芳华币</view>
  296. <image class="photo" src="/static/images/integral_bg.png" mode="widthFix" />
  297. </view>
  298. <view class="item">
  299. <view class="title ">{{integral.msg}}</view>
  300. <view class="button" @click="integral.status=false">确认</view>
  301. </view>
  302. </view>
  303. </u-popup>
  304. <u-popup :show="isShowRedCard" round='20rpx' mode="center" bgColor='transparent' zIndex='10076'>
  305. <view class="red-card">
  306. <image class="img" src="/static/images/red_card.png" />
  307. <view class="red-content">
  308. <view class="title">{{redCard.msg}}</view>
  309. <view class="txt ">直播惊喜芳华币</view>
  310. <view class="button" @click="isShowRedCard=false">确认</view>
  311. </view>
  312. </view>
  313. </u-popup>
  314. <!-- 中奖和未中奖 -->
  315. <u-popup :show="isShowPrize&&havePrize" round='20rpx' mode="center" bgColor='#fff' zIndex='10076'>
  316. <view class="prize-card" v-if="isCurrentUserWon">
  317. <image class="nav-img " src="/static/images/red_head.png" mode="widthFix" />
  318. <view class="title">恭喜您 中奖啦!</view>
  319. <view class="prize-content" v-for="(item,index) in (prizeInfo||[])" :key="index">
  320. <view class="item">{{item.userName}}</view>
  321. <view class="item">{{item.userId}}</view>
  322. <view class="txt item">{{item.prizeLevel}}等奖</view>
  323. </view>
  324. <view class="tip">请截图联系客服领取奖品</view>
  325. <view class="button" @click="confirm">确认</view>
  326. </view>
  327. <view class="no-prize-card" v-else>
  328. <image class="img" src="/static/images/no-prize.png" mode="widthFix" />
  329. <view class="tip">很遗憾 您未中奖</view>
  330. <view class="button" @click="confirm">确认</view>
  331. </view>
  332. </u-popup>
  333. <!-- 中奖记录 -->
  334. <!-- winning -->
  335. <u-popup :show="winning" @close="closeWin" round='20rpx' bgColor='#f3f5f9' zIndex='10076'>
  336. <view class="winning_record">
  337. <image class="head_bg" src="/static/images/red_head.png" mode="widthFix"></image>
  338. <image class="bg" src="/static/images/red_bg.png"></image>
  339. <view class="winning_content">
  340. <view class="title">我的中奖记录</view>
  341. <view class="row mb40">
  342. <view class="head">时间</view>
  343. <view class="head">奖品</view>
  344. </view>
  345. <scroll-view enable-flex scroll-y v-if="prizeAll" style="height: 500rpx;">
  346. <view class="row fs30 mb20" v-for="(item,index) in prizeAll" :key="index">
  347. <view class="start">{{item.createTime}}</view>
  348. <view class="end">{{item.productName?truncateString(item.productName,8):'' }}</view>
  349. </view>
  350. </scroll-view>
  351. <view v-else class="f36 mt150" style="text-align: center;">
  352. 暂无中奖信息
  353. </view>
  354. </view>
  355. </view>
  356. </u-popup>
  357. <!-- 观众列表弹窗 -->
  358. <u-popup :show="showadd" @close="close" @open="openViews" round='20rpx' bgColor='#ffffff' zIndex='10077'>
  359. <view class="view-box">
  360. <view class="fs32" style="text-align: center;">在线观众</view>
  361. <scroll-view v-if="Array.isArray(liveViewers)" scroll-y class="scroll-content"
  362. :style="{height: scrollHeight + 'px'}" @scrolltolower="handleScrollToLower">
  363. <view class="fs28 x-f mb20 mt20" v-for="(item,index) in (liveViewers||[])" :key="index">
  364. <view
  365. :style="{color: index === 0 ? '#FF3B30' : index === 1 ? '#FF9500' : index === 2 ? '#FFCC00' : '#8E8E93',fontWeight: index < 3 ? 'bold' : 'normal',width: '50rpx'}"
  366. class="mr10">{{index+1}}</view>
  367. <u-avatar v-if="item.avatar" :src="item.avatar" :size="36"></u-avatar>
  368. <view v-else class="w72 h72"
  369. :style="{backgroundColor: getUserRandomColor(item.userId), borderRadius:'50%'}">
  370. <text class="text-white text-sm">{{getNicknameInitial(item.nickName)}}</text>
  371. </view>
  372. <text class="ml16 f30">{{item.nickName||"未命名"}}</text>
  373. </view>
  374. </scroll-view>
  375. </view>
  376. </u-popup>
  377. <!-- 更多弹窗 -->
  378. <u-popup :show="isMore" @close="closeMore" round='20rpx' bgColor='#f3f5f9' zIndex='10076'>
  379. <view class="more-block">
  380. <view class="item" @click="navgetTo('/pages_shopping/live/integral'),isMore=false">
  381. <image class="w48 h48" src="/static/images/order.png" />
  382. <view style="text-align: center;">芳华币</view>
  383. </view>
  384. <view class=" item"
  385. @click="navgetTo('/pages_shopping/live/storeOrderRefundList?liveId='+liveId),isMore=false">
  386. <image class="w48 h48" src="/static/images/after_sales.png" />
  387. <view style="text-align: center;">售后订单</view>
  388. </view>
  389. <view class=" item" @click="goMiniProgram(),isMore=false">
  390. <image class="w48 h48" src="/static/images/points.png" />
  391. <view style="text-align: center;">兑换好礼</view>
  392. </view>
  393. <view class="item" @click="getMyLottery(),isMore=false,winning=true">
  394. <image class="w48 h48" src="/static/images/health_sel.png" />
  395. <view style="text-align: center;">中奖记录</view>
  396. </view>
  397. </view>
  398. </u-popup>
  399. <!-- 商品弹窗 -->
  400. <!-- show="true" -->
  401. <u-popup :show="shopping" @close="closeShop" round='20rpx' bgColor='#f3f5f9' zIndex='10075'>
  402. <view class="shoppop">
  403. <view class="shoppop-top">
  404. <view class="search-input x-f">
  405. <image class="w24 mr16" src="/static/images/search.png" mode="widthFix" />
  406. <input placeholder="请搜索商品" v-model="inputInfo" @input="handleSearchInput" />
  407. </view>
  408. <view class=" search-top" @click="navgetTo('/pages_shopping/live/order')">
  409. <image class="w48 h48" src="/static/images/carts.png" />
  410. <view style="text-align: center;">订单</view>
  411. </view>
  412. <!-- <view class="search-top" @click="isMore=true,shopping=false">
  413. <image class="w48 h48" src="/static/images/search2.png" />
  414. <view style="text-align: center;">更多</view>
  415. </view> -->
  416. </view>
  417. <!-- <scroll-view enable-flex scroll-y class="shop-list" :style="{ height: boxHeight + 'px' }">
  418. <view class="list-item" v-for="(item,index) in products" :key="index">
  419. <view class="goods-img">
  420. <image class="img" :src="item.imgUrl" mode="widthFix" />
  421. <view class="goods-label">{{index+1}}</view>
  422. </view>
  423. <view class="goods-right">
  424. <view class="goods-title">{{item.productName}}</view>
  425. <view class="goods-people">{{item.sales}} 人已购</view>
  426. <view class="goods-shop">
  427. <text class="nummber"><text style="font-size: 20rpx;font-weight: 600;">¥</text><text
  428. style="font-size: 36rpx;font-weight: bold;">{{Math.trunc(item.price)}}</text>.{{getPureDecimal(item.price)?getPureDecimal(item.price):'00'}}</text>
  429. <view class="btn-group x-f">
  430. <view class="collect-btn">
  431. <image v-if="item.isFavorite" @click="onGoodsCollect(item)" class="w36 h36"
  432. style="vertical-align: middle;"
  433. src="/static/images/collect_select.png" />
  434. <image v-else @click="onGoodsCollect(item)" class="w36 h36"
  435. style="vertical-align: middle;" src="/static/images/collect.png" />
  436. </view>
  437. <view v-if="item.status==1" class="shop-btn"
  438. @click="goShop(item.productId,item.goodsId)">去购买 </view>
  439. <view v-else-if="item.status==0" class="shop-btn">
  440. 已下架</view>
  441. </view>
  442. </view>
  443. </view>
  444. </view>
  445. </scroll-view> -->
  446. <scroll-view enable-flex scroll-y class="shop-list" :style="{ height: boxHeight + 'px' }">
  447. <!-- 骨架屏 -->
  448. <view v-if="loadingProducts && products.length === 0" class="skeleton-list">
  449. <view v-for="n in 6" :key="n" class="skeleton-item">
  450. <view class="skeleton-img"></view>
  451. <view class="skeleton-content">
  452. <view class="skeleton-line short"></view>
  453. <view class="skeleton-line medium"></view>
  454. <view class="skeleton-line long"></view>
  455. </view>
  456. </view>
  457. </view>
  458. <!-- 实际商品列表 -->
  459. <template v-else>
  460. <view v-for="(item,index) in products" :key="index" class="list-item">
  461. <view class="goods-img">
  462. <image class="img" :src="item.imgUrl" mode="widthFix" />
  463. <view class="goods-label">{{index+1}}</view>
  464. </view>
  465. <view class="goods-right">
  466. <view class="goods-title">{{item.productName}}</view>
  467. <view class="goods-people">{{item.sales}} 人已购</view>
  468. <view class="goods-shop">
  469. <text class="nummber"><text
  470. style="font-size: 20rpx;font-weight: 600;">¥</text><text
  471. style="font-size: 36rpx;font-weight: bold;">{{Math.trunc(item.price)}}</text>.{{getPureDecimal(item.price)?getPureDecimal(item.price):'00'}}</text>
  472. <view class="btn-group x-f">
  473. <view class="collect-btn">
  474. <image v-if="item.isFavorite" @click="onGoodsCollect(item)"
  475. class="w36 h36" style="vertical-align: middle;"
  476. src="/static/images/collect_select.png" />
  477. <image v-else @click="onGoodsCollect(item)" class="w36 h36"
  478. style="vertical-align: middle;" src="/static/images/collect.png" />
  479. </view>
  480. <view v-if="item.status==1" class="shop-btn"
  481. @click="goShop(item.productId,item.goodsId)">去购买 </view>
  482. <view v-else-if="item.status==0" class="shop-btn">
  483. 已下架</view>
  484. </view>
  485. </view>
  486. </view>
  487. </view>
  488. </template>
  489. </scroll-view>
  490. </view>
  491. </u-popup>
  492. <!-- 优惠券弹窗 -->
  493. <view class="coupon-pop" v-if="isShowCoupon">
  494. <view class="coupon-block">
  495. <image class="bg" src="/static/images/coupon_bg.png" />
  496. <image class="nav" src="/static/images/coupon_top.png" />
  497. <image @click="isShowCoupon=false" class="w40 h40 close" style="z-index: 99;"
  498. src="/static/images/close1.png" />
  499. <view class="item">
  500. <view class="title">{{couponInfo.couponName}}</view>
  501. <view class="price">¥<text class="bold">{{couponInfo.couponPrice}}</text></view>
  502. <view class="txt">满{{couponInfo.useMinPrice}}元可用</view>
  503. <view class="txt" style="margin-top: 26rpx;">指定商品可用</view>
  504. <view class="txt">自领取起{{couponInfo.couponTime}}天内有效</view>
  505. <view class="button" @click="onCoupon()">
  506. 立即领券
  507. </view>
  508. </view>
  509. </view>
  510. </view>
  511. </view>
  512. </view>
  513. </template>
  514. <script>
  515. import LikeButton from '@/pages_course/components/like.vue'
  516. import ThreeItemSwiper from '@/pages_course/components/ThreeItemSwiper.vue'
  517. import CryptoJS from 'crypto-js'
  518. import {
  519. myLottery, // 我的中奖明细
  520. coupon, //领取优惠券
  521. liveLottery, // 抽奖查询
  522. claim, //抽奖
  523. liveRed, // 点击领红包
  524. liveDataLike, // 点赞
  525. collectStore, // 店铺收藏/取消收藏
  526. collectGoods, // 商品收藏/取消收藏
  527. watchUserList, //获取直播间用户(展示在线用户)
  528. liveMsg, //获取最近聊天记录
  529. // 小黄车
  530. liveStore, //店铺展示,
  531. liveOrderUser, //正在购买
  532. getLiveInfo, //获取直播间信息接口
  533. getLiveViewData, //直播间点赞、关注、在线人数数据
  534. currentActivities, //红包 卡片 抽奖
  535. getlive,
  536. subNotifyLive,
  537. internetTraffic, // 流量(缓冲百分比),
  538. liveInternetTraffic // 直播流量(缓冲百分比),
  539. } from '@/api/living.js'
  540. import {
  541. getUserInfo
  542. } from '@/api/user'
  543. import {
  544. generateRandomString
  545. } from "@/utils/common.js"
  546. import dayjs from 'dayjs';
  547. import {
  548. nextTick
  549. } from "vue"
  550. var isSocketOpen = false;
  551. var socket = null;
  552. export default {
  553. components: {
  554. ThreeItemSwiper,
  555. LikeButton
  556. },
  557. data() {
  558. return {
  559. uuId: "",
  560. totalTraffic: 0, // 总流量(字节)
  561. bitrate: 800, // 录播默认码率 0.16Mbps
  562. bitrateLive: 1600, // 直播默认码率 0.16Mbps
  563. //定时器
  564. trafficTimer: null,
  565. pingTimeoutTimer: null, // 心跳超时定时器
  566. heartBeatTimer: null, // 心跳定时器
  567. liveViewDataTimer: null,
  568. reconnectTimer: null, // 重连定时器
  569. scrollTimer: null, // 滚动防抖定时器
  570. searchTimer: null, //搜索
  571. purchasePromptTimer: null, //购买提示
  572. welcomeTimer: null, //进入离开直播间定时器
  573. redTimer: null,
  574. liveStartTimer: null,
  575. lotteryTimer: null,
  576. stayTime: 0,
  577. startTime: 0,
  578. scrollTop: 0,
  579. isOnload: false,
  580. isConnecting: false, // 是否正在连接中
  581. hasInitialized: false,
  582. liveViewersData: [],
  583. liveUserCalled: false, //调用过watchUserList没
  584. userRandomColors: Object.create(null), // 缓存用户ID -> 随机色的映射
  585. heartBeatRetryCount: 0, // 心跳发送重试次数(避免一次失败就重连)
  586. maxHeartBeatRetries: 2, // 心跳最大重试次数
  587. pingTimeout: 20000, // 心跳超时时间从10s延长到20s(应对网络波动)
  588. shownEntryUsers: new Set(), // 存储已显示过「进入提示」的用户ID
  589. socket: null, // WebSocket 实例
  590. isSocketOpen: false, // 连接是否已打开
  591. heartBeatInterval: 15000, // 心跳发送间隔(15秒)
  592. reconnectCount: 0, // 当前重连次数
  593. maxReconnectAttempts: 3, // 最大重连次数
  594. isManualClose: false, // 是否手动关闭(用于区分主动关闭和异常断开)
  595. templateId: 'fxYJu817lxHNKXl0hJypb-y-lLm8CNmGbcwpQmasCVg',
  596. isAgreement: false,
  597. wsNewUrl: 'wss://api.fhhx.runtzh.com/ws/app/webSocket',
  598. // wsNewUrl: 'ws://192.168.10.166:7114/ws/app/webSocket',
  599. qrFrom: null,
  600. scene: '',
  601. liveCountdown: {}, //直播倒计时
  602. countdown: {}, //抽奖倒计时
  603. liveViewData: {},
  604. keyboardHeight: 0,
  605. videoCurrentTime: 0, // 当前视频播放时间
  606. videoProgressKey: '', // 存储进度的key
  607. inAndOut: {},
  608. winning: false,
  609. isShowPrize: false,
  610. isShowCoupon: false,
  611. prizeInfo: [],
  612. havePrize: uni.getStorageSync('havePrize') || false, //是否参与抽奖
  613. countDownKey: 0,
  614. lotteryProducts: [],
  615. lotteryList: [],
  616. talklist: [],
  617. isShowLotteryPop: false,
  618. liveItem: {},
  619. isSending: false,
  620. isMore: false,
  621. value: '',
  622. placeholderText: '说点什么...',
  623. prizeAll: [],
  624. isShowLottery: false,
  625. isShowRedCard: false,
  626. redCard: null, //点击红包出现弹窗
  627. integral: {},
  628. lotteryInfo: {},
  629. goodsCard: {},
  630. couponInfo: {},
  631. redInfo: {},
  632. storeId: null,
  633. isFocus: false,
  634. shopping: false,
  635. inputInfo: '',
  636. showWelcomeMessage: false,
  637. scrollIntoView: '',
  638. isShowGoods: false,
  639. isShowRed: false,
  640. lastClickTime: 0,
  641. videoRetryCounts: Object.create(null), // 记录每个直播间的视频重试次数,格式: { liveId: 次数 }
  642. clickDelay: 300, // 300ms内只响应一次点击
  643. liveUserTotal: 0,
  644. viewPageSize: 10, // 每页数量
  645. viewPageNum: 1, // 当前页码
  646. viewLoading: false, // 是否正在加载
  647. scrollHeight: 0,
  648. showPurchasePrompt: false,
  649. prevOrderCount: 0, // 用于记录上一次的购买人数
  650. videoUrl: null,
  651. showType: 1, //横屏1 竖屏2
  652. boxHeight: 300, //小黄车高度
  653. liveViewers: [], //观众
  654. livingUrl: "",
  655. products: [],
  656. loadingProducts: false, // 商品加载状态
  657. orderUser: {}, //正在购买
  658. userType: 0,
  659. timestamp: '',
  660. showadd: false,
  661. liveId: null,
  662. userinfo: '', //用户信息
  663. userData: {},
  664. diffTotalTime: ''
  665. };
  666. },
  667. async onLoad(options) {
  668. if (options.liveId) {
  669. this.liveId = options.liveId;
  670. }
  671. // 扫码传来的参数
  672. if (options.scene) {
  673. this.scene = options.scene;
  674. const decodedScene = decodeURIComponent(this.scene);
  675. const params = {};
  676. decodedScene.split('&').forEach(item => {
  677. const [key, value] = item.split('=');
  678. params[key] = value;
  679. this.liveId = params.a;
  680. })
  681. if (params.b && params.c) {
  682. this.qrFrom = `&companyId=${params.b}&companyUserId=${params.c}`;
  683. }
  684. }
  685. if (options.companyId && options.companyUserId) {
  686. this.qrFrom = `&companyId=${options.companyId}&companyUserId=${options.companyUserId}`;
  687. }
  688. this.userinfo = uni.getStorageSync("userInfo")
  689. this.userData = uni.getStorageSync("userData")
  690. console.log("全部参数", options)
  691. try {
  692. const isLogin = await this.utils.isLogin();
  693. if (isLogin) {
  694. await this.getUserInfo();
  695. this.initTime();
  696. if (this.liveId) {
  697. // 先获取直播间信息
  698. await this.getliving(this.liveId);
  699. this.isOnload = true;
  700. // 然后获取聊天记录
  701. await this.getLiveMsg(this.liveId);
  702. await this.getliveViewData(this.liveItem);
  703. }
  704. }
  705. } catch (error) {
  706. console.error("初始化失败:", error);
  707. }
  708. //获取键盘高度
  709. uni.onKeyboardHeightChange(res => {
  710. this.keyboardHeight = res.height * 2;
  711. });
  712. },
  713. onPullDownRefresh() {
  714. this.getLiveMsg(this.liveId)
  715. this.getliveUser()
  716. setTimeout(() => {
  717. uni.stopPullDownRefresh()
  718. }, 1000)
  719. },
  720. async onShow() {
  721. if (this.liveId) {
  722. await this.getLiveMsg(this.liveItem);
  723. }
  724. if (!this.liveViewData) {
  725. this.getliveViewData(this.liveItem);
  726. }
  727. if (!this.userData) {
  728. await this.getUserInfo()
  729. }
  730. this.uuId = generateRandomString(16)
  731. const isLiveLogin = uni.getStorageSync('isLiveLogin')
  732. this.share = uni.getStorageSync('share')
  733. this.scene = uni.getStorageSync('scene')
  734. if (this.share && this.share.length > 0) {
  735. this.liveId = this.share.liveId
  736. this.qrFrom = `&companyId=${this.share.companyId}&companyUserId=${this.share.companyUserId}`;
  737. uni.removeStorageSync('share')
  738. }
  739. if (this.scene) {
  740. const decodedScene = decodeURIComponent(this.scene);
  741. const params = {};
  742. decodedScene.split('&').forEach(item => {
  743. const [key, value] = item.split('=');
  744. params[key] = value;
  745. this.liveId = params.a;
  746. })
  747. if (params.b && params.c) {
  748. this.qrFrom = `&companyId=${params.b}&companyUserId=${params.c}`;
  749. }
  750. uni.removeStorageSync('scene')
  751. }
  752. if (isLiveLogin) {
  753. if (this.liveId) {
  754. await this.getliving(this.liveId)
  755. this.getCurrentActivities()
  756. this.getliveOrder()
  757. this.initSocket()
  758. }
  759. this.hasInitialized = true
  760. uni.removeStorageSync('isLiveLogin');
  761. }
  762. // 恢复播放和连接
  763. await this.resumePageActivity()
  764. this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
  765. this.isAgreement = uni.getStorageSync('isAgreement')
  766. this.$nextTick(() => {
  767. this.setVideoProgress();
  768. });
  769. if (this.lookTimer) {
  770. clearInterval(this.lookTimer)
  771. this.lookTimer = null;
  772. this.stayTime = 0;
  773. this.startTime = 0;
  774. }
  775. if (this.trafficTimer) {
  776. clearInterval(this.trafficTimer)
  777. this.trafficTimer = null;
  778. this.startTime = 0;
  779. this.totalTraffic = 0;
  780. }
  781. this.startTimer()
  782. },
  783. //分享给好友
  784. onShareAppMessage() {
  785. return {
  786. title: '邀请你来观看直播:' + this.liveItem.liveName,
  787. path: '/pages_course/living?companyId=-2&companyUserId=' + this.userData.userId + '&liveId=' + this.liveId,
  788. imageUrl: '/static/images/logo.png',
  789. success(res) {
  790. console.log("分享成功", res);
  791. },
  792. fail(err) {
  793. console.error("分享失败", err);
  794. }
  795. };
  796. },
  797. computed: {
  798. filteredViewers() {
  799. const safeLiveViewers = Array.isArray(this.liveViewersData) ? this.liveViewersData : [];
  800. // 截取前3项
  801. return safeLiveViewers.slice(0, 3);
  802. },
  803. isCurrentUserWon() {
  804. if (!Array.isArray(this.prizeInfo) || !this.userData?.userId) {
  805. return false;
  806. }
  807. return this.prizeInfo.some(item => {
  808. return String(item.userId) === String(this.userData.userId);
  809. });
  810. }
  811. },
  812. onHide() {
  813. // 清除所有定时器
  814. this.clearAllTimers();
  815. this.stopHeartBeat()
  816. },
  817. onUnload() {
  818. this.stopHeartBeat()
  819. this.saveVideoProgress()
  820. if (this.liveItem) {
  821. this.pauseVideo()
  822. // 清除直播间的时间定时器
  823. if (this.liveItem.timeTimer) {
  824. clearInterval(this.liveItem.timeTimer);
  825. this.liveItem.timeTimer = null; // 清空定时器标识
  826. }
  827. }
  828. this.liveUserCalled = false
  829. this.loadUserColorsFromStorage();
  830. // 先关闭WebSocket
  831. this.closeWebSocket(true);
  832. // 清除所有定时器
  833. this.clearAllTimers();
  834. // 暂停视频
  835. const videoId = `myVideo_${this.liveId}`;
  836. const videoContext = uni.createVideoContext(videoId, this);
  837. if (videoContext) {
  838. videoContext.pause();
  839. }
  840. // 清理大数据
  841. this.talklist = [];
  842. this.liveViewersData = [];
  843. this.liveViewers = [];
  844. this.products = [];
  845. this.liveItem = [];
  846. },
  847. mounted() {
  848. this.getCurrentActivities();
  849. this.getliveOrder()
  850. },
  851. watch: {
  852. // 监听liveItem.status的变化
  853. 'liveItem.status': {
  854. handler(newStatus, oldStatus) {
  855. if (newStatus === undefined || oldStatus === undefined) return;
  856. if (newStatus === oldStatus) return;
  857. if (!this.liveId) {
  858. console.warn("liveId不存在,无法触发getliving请求");
  859. return;
  860. }
  861. // 状态变化时,调用getliving更新直播间数据
  862. // console.log(`liveItem.status从${oldStatus}变为${newStatus},触发getliving请求`);
  863. this.getliving(this.liveId);
  864. },
  865. deep: true,
  866. },
  867. // 监听orderUser.count的变化
  868. 'orderUser.count': {
  869. handler(newVal, oldVal) {
  870. if (newVal !== this.prevOrderCount) {
  871. this.prevOrderCount = newVal;
  872. this.showPurchaseMessage();
  873. }
  874. },
  875. immediate: true
  876. }
  877. },
  878. methods: {
  879. // 定期清理视频缓存
  880. startVideoCacheCleanup() {
  881. if (this.videoCleanupTimer) {
  882. clearInterval(this.videoCleanupTimer);
  883. }
  884. // 每30秒清理一次视频缓存
  885. this.videoCleanupTimer = setInterval(() => {
  886. this.cleanupVideoCache();
  887. }, 30000);
  888. },
  889. // 清理视频缓存
  890. cleanupVideoCache() {
  891. if (!this.liveItem || !this.liveId) return;
  892. // 只对录播视频进行清理
  893. if (this.liveItem.liveType === 2 && this.liveItem.videoUrl) {
  894. this.reloadVideoPlayer();
  895. }
  896. },
  897. // 重新加载视频播放器
  898. reloadVideoPlayer() {
  899. const videoId = `myVideo_${this.liveId}`;
  900. const videoContext = uni.createVideoContext(videoId, this);
  901. if (videoContext) {
  902. const currentTime = this.videoCurrentTime;
  903. // 暂停视频
  904. videoContext.pause();
  905. // 延迟重新加载
  906. setTimeout(() => {
  907. // 重新设置视频源,强制清理缓存
  908. this.$set(this.liveItem, 'videoUrl', this.liveItem.videoUrl + '&t=' + Date.now());
  909. // 恢复播放位置
  910. setTimeout(() => {
  911. if (videoContext.seek) {
  912. videoContext.seek(currentTime);
  913. }
  914. videoContext.play();
  915. }, 500);
  916. }, 100);
  917. }
  918. },
  919. // 启动内存监控
  920. startMemoryMonitoring() {
  921. if (this.memoryMonitorTimer) {
  922. clearInterval(this.memoryMonitorTimer);
  923. }
  924. this.memoryMonitorTimer = setInterval(() => {
  925. this.checkMemoryUsage();
  926. }, 15000); // 每15秒检查一次
  927. },
  928. // 检查内存使用情况
  929. checkMemoryUsage() {
  930. // 在微信小程序中,可以通过性能监控API检查内存
  931. if (wx && wx.getPerformance) {
  932. try {
  933. const performance = wx.getPerformance();
  934. const memory = performance.memory;
  935. if (memory && memory.usedJSHeapSize > 50 * 1024 * 1024) { // 超过50MB
  936. console.warn('内存使用过高,触发清理:', memory.usedJSHeapSize);
  937. this.forceMemoryCleanup();
  938. }
  939. } catch (e) {
  940. console.log('无法获取内存信息');
  941. }
  942. }
  943. },
  944. // 强制内存清理
  945. forceMemoryCleanup() {
  946. console.log('执行强制内存清理');
  947. // 1. 清理视频播放器
  948. this.cleanupVideoPlayer();
  949. // 2. 清理大数据
  950. this.clearBigData();
  951. // 3. 强制垃圾回收(在支持的环境下)
  952. this.triggerGarbageCollection();
  953. },
  954. // 清理视频播放器
  955. cleanupVideoPlayer() {
  956. const videoId = `myVideo_${this.liveId}`;
  957. const videoContext = uni.createVideoContext(videoId, this);
  958. if (videoContext) {
  959. // 停止播放
  960. videoContext.stop();
  961. // 重置视频源
  962. setTimeout(() => {
  963. this.$set(this.liveItem, 'videoUrl', '');
  964. setTimeout(() => {
  965. this.$set(this.liveItem, 'videoUrl', this.getFreshVideoUrl());
  966. this.playVideo();
  967. }, 500);
  968. }, 100);
  969. }
  970. },
  971. // 获取带时间戳的新视频URL
  972. getFreshVideoUrl() {
  973. if (!this.liveItem.originalVideoUrl) {
  974. this.liveItem.originalVideoUrl = this.liveItem.videoUrl;
  975. }
  976. // 添加时间戳参数,避免缓存
  977. const separator = this.liveItem.originalVideoUrl.includes('?') ? '&' : '?';
  978. return this.liveItem.originalVideoUrl + separator + 't=' + Date.now();
  979. },
  980. // 清理大数据
  981. clearBigData() {
  982. // 清理聊天记录,只保留最近50条
  983. if (this.talklist.length > 50) {
  984. this.talklist = this.talklist.slice(-50);
  985. }
  986. // 清理观众数据
  987. if (this.liveViewersData.length > 100) {
  988. this.liveViewersData = this.liveViewersData.slice(-100);
  989. }
  990. // 清理虚拟数据
  991. if (this.liveViewers.length > 100) {
  992. this.liveViewers = this.liveViewers.slice(-100);
  993. }
  994. // 清理商品数据
  995. if (this.products.length > 50) {
  996. this.products = this.products.slice(0, 50);
  997. }
  998. },
  999. // 触发垃圾回收(在支持的环境下)
  1000. triggerGarbageCollection() {
  1001. if (wx && wx.triggerGC) {
  1002. wx.triggerGC();
  1003. }
  1004. },
  1005. goMiniProgram() {
  1006. // uni.navigateToMiniProgram({
  1007. // appId: 'wx45cf09091aead547',
  1008. // path: '/pages/home/index',
  1009. // success: function(res) {
  1010. // console.log('跳转成功', res);
  1011. // },
  1012. // fail: function(err) {
  1013. // console.error('跳转失败', err);
  1014. // }
  1015. // });
  1016. uni.showToast({
  1017. title: '系统升级中,兑换请联系伴学助手!',
  1018. icon: 'none'
  1019. });
  1020. },
  1021. // 阻止双击事件
  1022. preventDoubleClick(e) {
  1023. e.preventDefault();
  1024. e.stopPropagation();
  1025. return false;
  1026. },
  1027. // 清理所有定时器
  1028. clearAllTimers() {
  1029. if (this.scrollTimer) {
  1030. clearTimeout(this.scrollTimer);
  1031. this.scrollTimer = null;
  1032. }
  1033. if (this.liveViewDataTimer) {
  1034. clearInterval(this.liveViewDataTimer);
  1035. this.liveViewDataTimer = null;
  1036. }
  1037. if (this.redTimer) {
  1038. clearInterval(this.redTimer);
  1039. this.redTimer = null;
  1040. }
  1041. if (this.liveStartTimer) {
  1042. clearInterval(this.liveStartTimer);
  1043. this.liveStartTimer = null;
  1044. }
  1045. if (this.lotteryTimer) {
  1046. clearInterval(this.lotteryTimer);
  1047. this.lotteryTimer = null;
  1048. }
  1049. if (this.welcomeTimer) {
  1050. clearInterval(this.welcomeTimer);
  1051. this.welcomeTimer = null;
  1052. }
  1053. if (this.trafficInterval != null) {
  1054. clearInterval(this.trafficInterval)
  1055. }
  1056. if (this.lookTimer) {
  1057. clearInterval(this.lookTimer)
  1058. this.lookTimer = null;
  1059. this.stayTime = 0;
  1060. this.startTime = 0;
  1061. }
  1062. if (this.trafficTimer) {
  1063. clearInterval(this.trafficTimer)
  1064. this.trafficTimer = null;
  1065. this.startTime = 0;
  1066. this.totalTraffic = 0;
  1067. }
  1068. if (this.intervalId) {
  1069. clearInterval(this.intervalId);
  1070. this.intervalId = null;
  1071. }
  1072. if (this.reconnectTimer) {
  1073. clearInterval(this.reconnectTimer);
  1074. this.reconnectTimer = null;
  1075. }
  1076. if (this.scrollTimer) {
  1077. clearTimeout(this.scrollTimer);
  1078. this.scrollTimer = null;
  1079. }
  1080. if (this.searchTimer) {
  1081. clearTimeout(this.searchTimer);
  1082. this.searchTimer = null;
  1083. }
  1084. if (this.purchasePromptTimer) {
  1085. clearTimeout(this.purchasePromptTimer);
  1086. this.purchasePromptTimer = null;
  1087. }
  1088. },
  1089. //直播计算流量
  1090. startTrafficCalculation(bitrate) {
  1091. if (this.trafficTimer) {
  1092. clearInterval(this.trafficTimer);
  1093. this.trafficTimer = null;
  1094. }
  1095. this.startTime = Date.now();
  1096. var that = this
  1097. this.trafficTimer = setInterval(() => {
  1098. that.calculateTraffic(bitrate);
  1099. console.log("liveItem在这里>>>", this.liveItem)
  1100. }, 10000); // 每10秒计算一次
  1101. },
  1102. // 计算流量
  1103. calculateTraffic(bitrate) {
  1104. const currentTime = Date.now();
  1105. const duration = (currentTime - this.startTime) / 1000; // 持续时间(秒)
  1106. // 流量 = 码率 × 时间
  1107. // 码率单位: bps, 时间单位: 秒, 流量单位: 比特
  1108. const trafficBits = bitrate * duration;
  1109. // 转换为字节
  1110. this.totalTraffic = trafficBits / 8;
  1111. this.getLiveInternetTraffic()
  1112. },
  1113. startTimer() {
  1114. this.startTime = Date.now()
  1115. this.lookTimer = setInterval(() => {
  1116. this.stayTime = Math.floor((Date.now() - this.startTime) / 1000)
  1117. }, 1000)
  1118. },
  1119. //直播、录播缓冲
  1120. getLiveInternetTraffic() {
  1121. if (!this.liveId) return;
  1122. const currentTime = this.stayTime / this.liveItem.duration * 100;
  1123. const param = {
  1124. userId: this.userData.userId || '',
  1125. liveId: this.liveId || '',
  1126. uuId: dayjs().format('YYYYMMDD') + this.uuId,
  1127. internetTraffic: this.totalTraffic,
  1128. }
  1129. liveInternetTraffic(param)
  1130. },
  1131. // 回放、预告缓冲
  1132. getInternetTraffic() {
  1133. if (!this.liveId || !this.liveId || !this.userData.userId || !this.uuId) return;
  1134. const currentTime = this.stayTime / this.liveItem.duration * 100;
  1135. const param = {
  1136. videoType: this.liveItem.videoType,
  1137. videoId: this.liveItem.videoId,
  1138. userId: this.userData.userId,
  1139. liveId: this.liveId,
  1140. uuId: dayjs().format('YYYYMMDD') + this.uuId,
  1141. duration: this.liveItem.duration,
  1142. bufferRate: currentTime,
  1143. }
  1144. if (this.liveItem.status == 1) {
  1145. param.videoType = this.liveItem.previewVideoType || ''
  1146. param.videoId = this.liveItem.previewVideoId || ''
  1147. }
  1148. if (this.liveItem.liveType == 1) {
  1149. param.bufferRate = this.totalTraffic
  1150. }
  1151. internetTraffic(param)
  1152. },
  1153. scrollToBottom() {
  1154. if (this.scrollTimer) {
  1155. clearTimeout(this.scrollTimer);
  1156. }
  1157. this.scrollTimer = setTimeout(() => {
  1158. this.$nextTick(() => {
  1159. const query = uni.createSelectorQuery().in(this);
  1160. query.select('.scrolly').boundingClientRect(scrollRect => {
  1161. if (!scrollRect) return;
  1162. query.select('.scrolly').scrollOffset(scrollOffset => {
  1163. const newScrollTop = scrollOffset.scrollHeight - scrollRect
  1164. .height;
  1165. this.scrollTop = newScrollTop;
  1166. }).exec();
  1167. }).exec();
  1168. });
  1169. }, 0);
  1170. },
  1171. // 恢复页面活动
  1172. async resumePageActivity() {
  1173. if (this.liveItem) {
  1174. await this.getliving(this.liveId)
  1175. this.startTimeTimer(this.liveItem)
  1176. }
  1177. if (!this.isSocketAvailable()) {
  1178. this.initSocket()
  1179. }
  1180. },
  1181. // 获取用户专属随机色(缓存机制:同一用户始终用同一颜色)
  1182. getUserRandomColor(userId) {
  1183. if (!userId) {
  1184. return '#8978e2'; // 默认颜色
  1185. }
  1186. //如果缓存中已有该用户的颜色,直接返回
  1187. if (this.userRandomColors[userId]) {
  1188. return this.userRandomColors[userId];
  1189. }
  1190. //为新用户生成固定颜色(基于用户ID生成,不是完全随机)
  1191. const color = this.generateStableColor(userId);
  1192. this.userRandomColors[userId] = color;
  1193. // 存储到本地缓存,确保页面刷新后颜色不变
  1194. this.saveUserColorsToStorage();
  1195. return color;
  1196. }, // 基于用户ID生成稳定颜色(不是完全随机)
  1197. generateStableColor(userId) {
  1198. // 将用户ID转换为数字种子
  1199. let seed = 0;
  1200. for (let i = 0; i < userId.length; i++) {
  1201. seed = (seed * 31 + userId.charCodeAt(i)) % 1000000;
  1202. }
  1203. const colorPool = [
  1204. '#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7',
  1205. '#DDA0DD', '#98D8C8', '#F7DC6F', '#BB8FCE', '#85C1E9',
  1206. '#F8C471', '#82E0AA', '#F1948A', '#85C1E9', '#D7BDE2'
  1207. ];
  1208. return colorPool[seed % colorPool.length];
  1209. },
  1210. // 保存颜色映射到本地存储
  1211. saveUserColorsToStorage() {
  1212. try {
  1213. uni.setStorageSync('userRandomColors', this.userRandomColors);
  1214. } catch (e) {
  1215. console.warn('保存用户颜色缓存失败:', e);
  1216. }
  1217. },
  1218. // 从本地存储加载颜色映射
  1219. loadUserColorsFromStorage() {
  1220. try {
  1221. const cached = uni.getStorageSync('userRandomColors');
  1222. if (cached) {
  1223. this.userRandomColors = cached;
  1224. }
  1225. } catch (e) {
  1226. console.warn('加载用户颜色缓存失败:', e);
  1227. }
  1228. },
  1229. //头像名字
  1230. getNicknameInitial(nickName) {
  1231. if (!nickName || typeof nickName !== 'string') return '未';
  1232. if (/^[\u4e00-\u9fa5]/.test(nickName[0])) {
  1233. return nickName[0];
  1234. }
  1235. return nickName[0].toUpperCase();
  1236. },
  1237. async getUserInfo() {
  1238. await getUserInfo().then(
  1239. res => {
  1240. if (res.code == 200) {
  1241. this.userData = res.user;
  1242. } else {
  1243. uni.showToast({
  1244. icon: 'none',
  1245. title: "请求失败",
  1246. });
  1247. }
  1248. },
  1249. rej => {}
  1250. );
  1251. },
  1252. //订阅消息
  1253. handleAgreement() {
  1254. const templateId = this.templateId;
  1255. uni.requestSubscribeMessage({
  1256. tmplIds: [templateId],
  1257. success: (res) => {
  1258. // console.log("模板订阅状态", res[templateId]);
  1259. if (res[templateId] === "accept") {
  1260. uni.showToast({
  1261. title: '订阅成功,开播将提醒您',
  1262. icon: 'success'
  1263. });
  1264. this.callSendMessageApi()
  1265. } else if (res[templateId] === 'reject') {
  1266. uni.showToast({
  1267. title: '您已拒绝订阅,将无法收到提醒',
  1268. icon: 'none'
  1269. });
  1270. } else if (res[templateId] === 'ban') {
  1271. uni.showToast({
  1272. title: '您已关闭所有订阅权限,请在设置中开启',
  1273. icon: 'none'
  1274. });
  1275. }
  1276. },
  1277. fail: (err) => {
  1278. console.error('订阅消息失败', err);
  1279. uni.showToast({
  1280. title: '订阅失败,请重试',
  1281. icon: 'none'
  1282. });
  1283. }
  1284. });
  1285. },
  1286. async callSendMessageApi() {
  1287. if (!this.userData.userId) return;
  1288. const templateData = {
  1289. taskName: this.liveId,
  1290. userId: this.userData.userId,
  1291. templateId: this.templateId, // 模板ID
  1292. data: {
  1293. thing6: this.liveItem.liveName,
  1294. date7: this.liveItem.startTime,
  1295. }
  1296. };
  1297. subNotifyLive(templateData).then(res => {
  1298. if (res.code == 200) {
  1299. this.isAgreement = true;
  1300. uni.setStorageSync('isAgreement', true);
  1301. } else {
  1302. uni.showToast({
  1303. title: res.msg,
  1304. icon: 'none'
  1305. });
  1306. }
  1307. },
  1308. rej => {}
  1309. );
  1310. },
  1311. //发送心跳
  1312. sendHeartBeat() {
  1313. if (!this.isSocketAvailable()) return;
  1314. try {
  1315. const heartBeatMsg = JSON.stringify({
  1316. cmd: "heartbeat",
  1317. msg: "ping",
  1318. userId: this.userData.userId || '',
  1319. liveId: this.liveId
  1320. });
  1321. this.socket.send({
  1322. data: heartBeatMsg,
  1323. success: () => {
  1324. this.heartBeatRetryCount = 0; // 成功后重置重试次数
  1325. this.startPingTimeout(); // 启动超时检测
  1326. },
  1327. fail: (err) => {
  1328. console.error("心跳包发送失败:", err);
  1329. this.heartBeatRetryCount++;
  1330. // 心跳失败先重试,重试次数用完再重连
  1331. if (this.heartBeatRetryCount < this.maxHeartBeatRetries) {
  1332. setTimeout(() => this.sendHeartBeat(), 2000); // 2秒后重试
  1333. } else {
  1334. this.heartBeatRetryCount = 0;
  1335. this.handleReconnect(); // 重试用完才重连
  1336. }
  1337. }
  1338. });
  1339. } catch (err) {
  1340. console.error("心跳发送异常:", err);
  1341. this.heartBeatRetryCount++;
  1342. if (this.heartBeatRetryCount < this.maxHeartBeatRetries) {
  1343. setTimeout(() => this.sendHeartBeat(), 2000);
  1344. } else {
  1345. this.heartBeatRetryCount = 0;
  1346. this.handleReconnect();
  1347. }
  1348. }
  1349. },
  1350. // 启动心跳超时检测
  1351. startPingTimeout() {
  1352. // 清除之前的超时定时器
  1353. if (this.pingTimeoutTimer) {
  1354. clearTimeout(this.pingTimeoutTimer);
  1355. this.pingTimeoutTimer = null;
  1356. }
  1357. // 超时后触发重连
  1358. this.pingTimeoutTimer = setTimeout(() => {
  1359. // console.error("心跳响应超时,连接异常");
  1360. this.handleReconnect();
  1361. }, this.pingTimeout);
  1362. },
  1363. stopHeartBeat() {
  1364. if (this.heartBeatTimer) {
  1365. clearInterval(this.heartBeatTimer);
  1366. this.heartBeatTimer = null;
  1367. }
  1368. if (this.pingTimeoutTimer) {
  1369. clearTimeout(this.pingTimeoutTimer);
  1370. this.pingTimeoutTimer = null;
  1371. }
  1372. }, // 封装通用的连接状态校验方法
  1373. isSocketAvailable() {
  1374. // WebSocket readyState:0=CONNECTING, 1=OPEN, 2=CLOSING, 3=CLOSED
  1375. return this.socket && this.isSocketOpen && this.socket.readyState === 1;
  1376. },
  1377. // 处理重连逻辑
  1378. handleReconnect() {
  1379. this.resetReconnectState();
  1380. // uni.onNetworkStatusChange(res=>{
  1381. // if (res.networkType === 'wifi') {
  1382. // }
  1383. // })
  1384. this.stopHeartBeat();
  1385. if (this.reconnectCount < this.maxReconnectAttempts) {
  1386. this.reconnectCount++;
  1387. const delay = 1000;
  1388. console.log(`第${this.reconnectCount}次重连,延迟${delay}ms`);
  1389. this.reconnectTimer = setInterval(() => {
  1390. this.initSocket();
  1391. }, delay);
  1392. } else {
  1393. console.log(`停止重连(手动关闭/已达最大次数)`);
  1394. this.closeWebSocket(true);
  1395. }
  1396. },
  1397. // 重置重连状态
  1398. resetReconnectState() {
  1399. this.reconnectCount = 0;
  1400. if (this.reconnectTimer) {
  1401. clearInterval(this.reconnectTimer);
  1402. this.reconnectTimer = null;
  1403. }
  1404. },
  1405. //输入框
  1406. inputFocus() {
  1407. // this.chatHeight = this.keyboardHeight;
  1408. this.isFocus = true;
  1409. },
  1410. inputBlur() {
  1411. // this.chatHeight = 0;
  1412. this.isFocus = false
  1413. },
  1414. getTimeDifferenceInSeconds(createTimeStr) {
  1415. const createTime = new Date(createTimeStr.replace(/-/g, '/'));
  1416. const now = new Date();
  1417. const timeDiffMs = now - createTime;
  1418. const timeDiffSeconds = Math.floor(timeDiffMs / 1000);
  1419. return Math.max(0, timeDiffSeconds);
  1420. },
  1421. // 录播时间点
  1422. onVideoMetaLoaded(e) {
  1423. this.videoProgressKey = `videoProgress_${this.liveId}`;
  1424. this.setVideoProgress();
  1425. },
  1426. setVideoProgress() {
  1427. // 只有录播和回放需要设置进度
  1428. if (this.liveItem.liveType !== 2 && this.liveItem.liveType !== 3) {
  1429. return;
  1430. }
  1431. let currentTime = 0;
  1432. if (this.liveItem.liveType === 2) {
  1433. // 录播:计算当前时间与开始时间的差值,对视频总时长取模
  1434. const diff = this.getTimeDifferenceInSeconds(this.liveItem.startTime);
  1435. if (diff > this.liveItem.duration) {
  1436. const storedProgress = uni.getStorageSync(this.videoProgressKey);
  1437. currentTime = (storedProgress >= this.liveItem.duration) ? 0 : (storedProgress || 0);
  1438. } else {
  1439. currentTime = diff % this.liveItem.duration;
  1440. }
  1441. // currentTime = diff % this.liveItem.duration;
  1442. } else if (this.liveItem.liveType === 3) {
  1443. // 回放:从存储中获取进度
  1444. const storedProgress = uni.getStorageSync(this.videoProgressKey);
  1445. currentTime = storedProgress || 0;
  1446. }
  1447. const videoId = `myVideo_${this.liveId}`;
  1448. const videoContext = uni.createVideoContext(videoId, this);
  1449. if (videoContext) {
  1450. videoContext.seek(currentTime);
  1451. }
  1452. },
  1453. onVideoWaiting(e) {
  1454. // console.log('视频等待加载', e);
  1455. //流量
  1456. if (this.liveItem.liveType == 2) {
  1457. this.startTrafficCalculation(this.bitrate);
  1458. } else {
  1459. let that = this
  1460. if (this.trafficInterval) {
  1461. clearInterval(this.trafficInterval);
  1462. this.trafficInterval = null;
  1463. }
  1464. this.trafficInterval = setInterval(function() {
  1465. that.getInternetTraffic();
  1466. }, 10000);
  1467. }
  1468. },
  1469. // 视频时间更新
  1470. onVideoTimeUpdate(e) {
  1471. // 获取当前播放时间
  1472. this.videoCurrentTime = e.detail.currentTime;
  1473. // 每隔10秒保存一次进度(避免频繁存储)
  1474. if (Math.floor(this.videoCurrentTime) % 10 === 0) {
  1475. this.saveVideoProgress();
  1476. }
  1477. // this.setVideoProgress();
  1478. },
  1479. // 视频暂停
  1480. onVideoPause(e) {
  1481. if (this.liveItem.liveType === 2) {
  1482. const videoId = `myVideo_${this.liveId}`;
  1483. const videoContext = uni.createVideoContext(videoId, this);
  1484. setTimeout(() => {
  1485. videoContext.play();
  1486. }, 100);
  1487. }
  1488. // 暂停时保存进度
  1489. this.saveVideoProgress();
  1490. },
  1491. // 视频播放
  1492. onVideoPlay(e) {},
  1493. // 设置视频当前时间
  1494. // setVideoCurrentTime(time) {
  1495. // if (!time) return;
  1496. // const videoId = `myVideo_${this.liveId}`;
  1497. // const videoContext = uni.createVideoContext(videoId, this);
  1498. // if (videoContext) {
  1499. // videoContext.seek(time);
  1500. // console.log(`设置视频播放位置: ${time}秒`);
  1501. // }
  1502. // },
  1503. // 保存视频进度
  1504. saveVideoProgress() {
  1505. if (this.videoProgressKey) {
  1506. uni.setStorage({
  1507. key: this.videoProgressKey,
  1508. data: this.videoCurrentTime,
  1509. success: () => {},
  1510. fail: (err) => {
  1511. console.error('保存视频进度失败:', err);
  1512. }
  1513. });
  1514. }
  1515. },
  1516. // 点击红包
  1517. onRed() {
  1518. if (!this.liveId) return;
  1519. if (!this.redInfo?.redId) return;
  1520. if (this.redTimer) {
  1521. clearInterval(this.redTimer);
  1522. this.redTimer = null;
  1523. }
  1524. let data = {
  1525. liveId: this.liveId,
  1526. userId: this.userData.userId,
  1527. redId: this.redInfo.redId,
  1528. }
  1529. liveRed(data).then(res => {
  1530. this.isShowRed = false
  1531. this.redCard = res
  1532. this.isShowRedCard = true
  1533. },
  1534. rej => {}
  1535. );
  1536. },
  1537. //领取优惠券
  1538. onCoupon() {
  1539. if (!this.couponInfo.couponIssueId) return;
  1540. let data = {
  1541. goodsId: this.couponInfo.goodsId,
  1542. couponIssueId: this.couponInfo.couponIssueId,
  1543. liveId: this.liveId
  1544. };
  1545. coupon(data)
  1546. .then(res => {
  1547. this.isShowCoupon = false
  1548. if (res.code == 200) {
  1549. uni.showToast({
  1550. title: res.msg,
  1551. icon: 'none'
  1552. });
  1553. } else {
  1554. uni.showToast({
  1555. title: res.msg,
  1556. icon: 'none'
  1557. });
  1558. }
  1559. })
  1560. .catch(rej => {});
  1561. },
  1562. // 我的中奖名单
  1563. getMyLottery() {
  1564. this.winning = true
  1565. myLottery().then(res => {
  1566. if (res.code == 200) {
  1567. // console.log("我的中奖名单", res)
  1568. this.prizeAll = res.data.list || {};
  1569. } else {
  1570. }
  1571. })
  1572. .catch(rej => {});
  1573. },
  1574. // 抽奖
  1575. onLottery() {
  1576. if (!this.lotteryInfo) return;
  1577. let data = {
  1578. lotteryId: this.lotteryInfo.lotteryId
  1579. };
  1580. liveLottery(data)
  1581. .then(res => {
  1582. if (res.code == 200) {
  1583. const resData = res.data || {};
  1584. this.lotteryList = Array.isArray(resData) ? resData : [];
  1585. this.lotteryProducts = Array.isArray(resData.products) ? resData.products : [];
  1586. if (resData.duration) {
  1587. this.isShowLotteryPop = true;
  1588. }
  1589. } else {
  1590. uni.showToast({
  1591. title: res.msg,
  1592. icon: 'none'
  1593. });
  1594. this.lotteryList = [];
  1595. this.lotteryProducts = [];
  1596. }
  1597. })
  1598. .catch(rej => {
  1599. uni.showToast({
  1600. title: '获取抽奖信息失败',
  1601. icon: 'none'
  1602. });
  1603. // 失败时强制重置为数组
  1604. this.lotteryList = [];
  1605. this.lotteryProducts = [];
  1606. });
  1607. },
  1608. // 参与抽奖
  1609. onClaim() {
  1610. let data = {
  1611. liveId: this.liveId,
  1612. lotteryId: this.lotteryInfo.lotteryId,
  1613. }
  1614. claim(data).then(res => {
  1615. if (res.code == 200) {
  1616. uni.showToast({
  1617. title: res.msg,
  1618. icon: 'none'
  1619. });
  1620. this.isShowLotteryPop = false
  1621. this.havePrize = true
  1622. uni.setStorageSync('havePrize', this.havePrize);
  1623. } else {
  1624. uni.showToast({
  1625. title: res.msg,
  1626. icon: 'none'
  1627. });
  1628. }
  1629. },
  1630. rej => {}
  1631. );
  1632. },
  1633. confirm() {
  1634. this.isShowPrize = false;
  1635. this.havePrize = false;
  1636. uni.setStorageSync('havePrize', this.havePrize);
  1637. },
  1638. // 商品收藏
  1639. onGoodsCollect(item) {
  1640. if (!item || item.length === 0 || !item.goodsId) {
  1641. return;
  1642. }
  1643. collectGoods(item.goodsId).then(res => {
  1644. if (res.code == 200) {
  1645. uni.showToast({
  1646. title: res.msg,
  1647. icon: 'none'
  1648. });
  1649. item.isFavorite = !item.isFavorite
  1650. } else {
  1651. uni.showToast({
  1652. title: res.msg,
  1653. icon: 'none'
  1654. });
  1655. }
  1656. },
  1657. rej => {}
  1658. );
  1659. },
  1660. //正在购买
  1661. getliveOrder(item) {
  1662. if (!this.liveId) {
  1663. return;
  1664. }
  1665. liveOrderUser(this.liveId).then(res => {
  1666. if (res.code == 200) {
  1667. this.orderUser = res;
  1668. } else {
  1669. console.log('获取正在购买用户失败');
  1670. }
  1671. },
  1672. rej => {}
  1673. );
  1674. },
  1675. onLiveStateChange(e, liveItem) {
  1676. // 可以根据状态码处理不同的直播状态
  1677. const stateCode = e.detail.code;
  1678. if (e.detail.code == -2301 || e.detail.code == -2302) {
  1679. this.playVideo()
  1680. } else if (e.detail.code == 2004) {
  1681. this.calculateTimeDiff(this.liveItem)
  1682. this.startTrafficCalculation(this.bitrateLive);
  1683. }
  1684. // 2001: 已经连接服务器
  1685. // 2002: 已经连接服务器,开始拉流
  1686. // 2003: 网络接收到首个视频数据包(IDR)
  1687. // 2004: 视频播放开始
  1688. // 2005: 视频播放进度
  1689. // 2006: 视频播放结束
  1690. // 2007: 视频播放Loading
  1691. // 2008: 解码器启动
  1692. // -2301: 网络断连,且经多次重连抢救无效,更多重试请自行重启播放
  1693. // -2302: 获取加速拉流地址失败
  1694. }, // 直播错误事件
  1695. onLiveError(e, liveItem) {
  1696. this.videoError(e, liveItem);
  1697. console.log('错误');
  1698. },
  1699. // 红包 卡片 抽奖
  1700. getCurrentActivities() {
  1701. if (!this.liveId) return;
  1702. currentActivities(this.liveId).then(res => {
  1703. if (res.code === 200) {
  1704. // 提取数据(默认空数组/对象避免报错)
  1705. this.redInfo = (Array.isArray(res.red) ? res.red : [])[0] || {};
  1706. this.lotteryInfo = (Array.isArray(res.lottery) ? res.lottery : [])[0] || {};
  1707. this.goodsCard = res.goods || {};
  1708. this.isShowGoods = this.goodsCard && this.goodsCard.status == 1;
  1709. this.isShowRed = this.redInfo && this.redInfo.redStatus == 1;
  1710. this.isShowLottery = this.lotteryInfo && this.lotteryInfo.lotteryStatus == 1;
  1711. if (this.isShowRed) {
  1712. this.redTimer = setInterval(() => {
  1713. const redCountdown = this.handleTime(this.redInfo.updateTime, this.redInfo
  1714. .duration)
  1715. if (!redCountdown) {
  1716. this.isShowRed = false
  1717. clearInterval(this.redTimer)
  1718. }
  1719. }, 1000);
  1720. }
  1721. // 处理抽奖定时器
  1722. if (this.isShowLottery) {
  1723. this.lotteryTimer = setInterval(() => {
  1724. this.countdown = this.handleTime(this.lotteryInfo.updateTime, this
  1725. .lotteryInfo
  1726. .duration)
  1727. }, 1000);
  1728. }
  1729. } else {
  1730. uni.showToast({
  1731. title: res.msg,
  1732. icon: 'none'
  1733. });
  1734. }
  1735. }, rej => {});
  1736. },
  1737. // 计算当前时间与 liveItem.startTime 的差值,并更新 totalTime
  1738. calculateTimeDiff(item) {
  1739. if (!item.startTime) return;
  1740. // 提取对应场景的时间字符串(直播用startTime,抽奖用updateTime)
  1741. let timeStr = item.startTime;
  1742. // 转换时间格式(适配iOS,将 "-" 替换为 "/")
  1743. const time = new Date(timeStr.replace(/-/g, "/"));
  1744. if (isNaN(time.getTime())) {
  1745. return;
  1746. }
  1747. const now = new Date();
  1748. let diffMs = Math.max(0, now.getTime() - time.getTime())
  1749. // 转换为 时:分:秒(补零处理)
  1750. const totalSeconds = Math.floor(diffMs / 1000);
  1751. const hours = this.padZero(Math.floor(totalSeconds / 3600));
  1752. const minutes = this.padZero(Math.floor((totalSeconds % 3600) / 60));
  1753. const seconds = this.padZero(totalSeconds % 60);
  1754. this.diffTotalTime = `${hours}:${minutes}:${seconds}`;
  1755. // this.$set(this.liveItem, "diffMs", diffMs);
  1756. // this.$set(this.liveItem, "totalSeconds", totalSeconds);
  1757. },
  1758. padZero(num) {
  1759. return num < 10 ? `0${num}` : num;
  1760. },
  1761. // 启动当前直播间的时间差值定时器
  1762. startTimeTimer(item) {
  1763. if (!item) return;
  1764. // 立即计算一次(避免等待1秒才显示)
  1765. const totalTime = this.calculateTimeDiff(item);
  1766. item.timeTimer = setInterval(() => {
  1767. const totalTime = this.calculateTimeDiff(item);
  1768. }, 1000);
  1769. },
  1770. toggleViewerList() {
  1771. const now = Date.now();
  1772. if (now - this.lastClickTime > this.clickDelay) {
  1773. this.showadd = !this.showadd;
  1774. if (this.showadd) {
  1775. this.getliveUser(false); // 加载第一页观众
  1776. }
  1777. this.lastClickTime = now;
  1778. }
  1779. },
  1780. // 播放视频
  1781. playVideo() {
  1782. if (!this.liveItem) {
  1783. console.log('liveItem 为空,无法播放视频');
  1784. return;
  1785. }
  1786. try {
  1787. // 直播流使用live-player
  1788. if (this.liveItem.liveType === 1 && this.liveItem.livingUrl && this.liveItem.status == 2) {
  1789. const livePlayerId = `myLivePlayer_${this.liveId}`;
  1790. const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
  1791. // console.log("直播")
  1792. if (livePlayerContext) {
  1793. livePlayerContext.play();
  1794. }
  1795. } else if (this.liveItem.status == 1 && this.liveItem.previewUrl) {
  1796. const videoId = `myVideo_${this.liveId}`;
  1797. const videoContext = uni.createVideoContext(videoId, this);
  1798. if (videoContext) {
  1799. videoContext.play();
  1800. }
  1801. } else if (this.liveItem.liveType === 2 && this.liveItem.videoUrl && this.liveItem.status == 2) {
  1802. const videoId = `myVideo_${this.liveId}`;
  1803. const videoContext = uni.createVideoContext(videoId, this);
  1804. // console.log("录播")
  1805. if (videoContext) {
  1806. videoContext.play();
  1807. }
  1808. } // 回放视频使用video
  1809. else if (this.liveItem.liveType === 3 && this.liveItem.videoUrl && this.liveItem.status == 4) {
  1810. const videoId = `myVideo_${this.liveId}`;
  1811. const videoContext = uni.createVideoContext(videoId, this);
  1812. // console.log("回放")
  1813. if (videoContext) {
  1814. videoContext.play();
  1815. }
  1816. }
  1817. } catch (error) {
  1818. console.error("播放视频失败:", error);
  1819. }
  1820. },
  1821. pauseVideo() {
  1822. if (!this.liveItem) return;
  1823. try {
  1824. // 直播流使用live-player
  1825. if (this.liveItem.status == 1) {
  1826. const videoId = `myVideo_${this.liveId}`;
  1827. const videoContext = uni.createVideoContext(videoId, this);
  1828. if (videoContext) {
  1829. videoContext.pause();
  1830. }
  1831. } else if (this.liveItem.status == 2) {
  1832. if (this.liveItem.liveType === 1) {
  1833. const livePlayerId = `myLivePlayer_${this.liveId}`;
  1834. const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
  1835. if (livePlayerContext) {
  1836. livePlayerContext.pause();
  1837. }
  1838. } else if (this.liveItem.liveType === 2) {
  1839. const videoId = `myVideo_${this.liveId}`;
  1840. const videoContext = uni.createVideoContext(videoId, this);
  1841. if (videoContext) {
  1842. videoContext.pause();
  1843. }
  1844. }
  1845. }
  1846. } catch (error) {
  1847. console.error("暂停视频失败:", error);
  1848. }
  1849. },
  1850. // 视频错误处理
  1851. videoError(e, liveItem) {
  1852. if (!liveItem || !this.liveId) return;
  1853. // 初始化重试计数
  1854. if (this.videoRetryCounts[liveItem.liveId] === undefined) {
  1855. this.videoRetryCounts[liveItem.liveId] = 0;
  1856. }
  1857. // 限制重试次数
  1858. if (this.videoRetryCounts[liveItem.liveId] >= 3) {
  1859. console.error(`直播间 ${this.liveId} 视频加载失败,停止重试`);
  1860. // 显示错误提示
  1861. uni.showToast({
  1862. title: "视频加载失败,请检查网络",
  1863. icon: 'none',
  1864. duration: 2000
  1865. });
  1866. return;
  1867. }
  1868. this.videoRetryCounts[this.liveId]++;
  1869. // 延迟重试
  1870. setTimeout(() => {
  1871. if (this.liveId === this.liveId) {
  1872. console.log(`第${this.videoRetryCounts[this.liveId]}次重试播放视频`);
  1873. this.playVideo();
  1874. }
  1875. }, 2000);
  1876. },
  1877. openViews() {
  1878. // 计算scroll-view高度
  1879. this.$nextTick(() => {
  1880. const query = uni.createSelectorQuery().in(this);
  1881. query.select('.view-box').boundingClientRect(data => {
  1882. if (data) {
  1883. this.scrollHeight = data.height - 80; // 80是标题高度,120是底部高度
  1884. }
  1885. }).exec();
  1886. });
  1887. },
  1888. // 滚动到底部触发
  1889. handleScrollToLower() {
  1890. // 清除上一次未执行的定时器,避免重复请求
  1891. if (this.scrollTimer) {
  1892. clearTimeout(this.scrollTimer);
  1893. }
  1894. // 延迟0.5秒(500毫秒)执行接口请求
  1895. this.scrollTimer = setTimeout(() => {
  1896. this.getliveUser(true);
  1897. }, 1000);
  1898. },
  1899. async getLiveMsg(liveItem) {
  1900. if (!liveItem || !this.liveId) {
  1901. console.error('getLiveMsg 错误:无效的 liveItem');
  1902. return;
  1903. }
  1904. try {
  1905. const res = await liveMsg(this.liveId, 30, 1);
  1906. if (res.code == 200) {
  1907. const rows = Array.isArray(res.rows) ? res.rows : [];
  1908. const reversedTalkList = [...rows].reverse();
  1909. this.talklist = Array.isArray(reversedTalkList) ? reversedTalkList : [];
  1910. // 获取历史消息后也滚动到底部
  1911. this.$nextTick(() => {
  1912. this.scrollToBottom();
  1913. });
  1914. } else {
  1915. this.talklist = [];
  1916. }
  1917. } catch (error) {
  1918. this.talklist = [];
  1919. console.error("获取聊天记录失败:", error);
  1920. }
  1921. },
  1922. generateRandomChineseName() {
  1923. const prefixes = [
  1924. '幸福', '快乐', '安康', '吉祥', '如意', '平安', '健康', '长寿',
  1925. '福气', '美满', '和谐', '团圆', '富贵', '荣华', '宁静', '淡泊',
  1926. '知足', '常乐', '悠然', '自在', '夕阳', '晚霞', '金秋', '银发',
  1927. '老顽童', '开心', '笑口常开', '岁月静好', '云淡风轻', '海阔天空'
  1928. ];
  1929. const suffixes = [
  1930. '老人', '大爷', '大妈', '爷爷', '奶奶', '伯伯', '阿姨', '前辈',
  1931. '先生', '女士', '长者', '翁', '婆', '哥', '姐', '友',
  1932. '客', '迷', '粉丝', '达人', '爱好者', '之家', '之人', '之心',
  1933. '之情', '之乐', '之旅', '之梦', '之歌', '之韵'
  1934. ];
  1935. const specialNames = [
  1936. '老有所乐', '知足常乐', '笑看人生', '云淡风轻', '岁月如歌',
  1937. '夕阳红', '金色年华', '老当益壮', '鹤发童颜', '老骥伏枥',
  1938. '闲云野鹤', '淡泊明志', '宁静致远', '随遇而安', '顺其自然',
  1939. '老来俏', '开心果', '老宝贝', '不老松', '常青树'
  1940. ];
  1941. // 30%概率使用特殊网名,70%使用前缀+后缀组合
  1942. if (Math.random() < 0.3) {
  1943. return specialNames[Math.floor(Math.random() * specialNames.length)];
  1944. } else {
  1945. const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
  1946. const suffix = suffixes[Math.floor(Math.random() * suffixes.length)];
  1947. return prefix + suffix;
  1948. }
  1949. },
  1950. // 获取直播间用户
  1951. async getliveUser(isLoadMore = false) {
  1952. this.viewLoading = true;
  1953. try {
  1954. const res = await watchUserList(this.liveId, this.viewPageSize, this.viewPageNum, false);
  1955. if (res.code === 200) {
  1956. const userRows = Array.isArray(res.rows) ? res.rows : [];
  1957. let array = userRows.map(item => ({
  1958. avatar: item.avatar || '',
  1959. userId: item.userId || '',
  1960. nickName: item.nickName || '未命名'
  1961. }));
  1962. // 虚拟数据
  1963. let virtualData = []
  1964. let virtualTotal = res.total * 2 + 50
  1965. this.liveUserTotal = virtualTotal
  1966. for (let i = 0; i < virtualTotal; i++) {
  1967. let data = {
  1968. avatar: '',
  1969. userId: '8565' + i,
  1970. nickName: this.generateRandomChineseName()
  1971. }
  1972. virtualData.push(data)
  1973. }
  1974. this.liveViewersData = [...array, ...virtualData]
  1975. const newRows = Array.isArray(res.rows) ? res.rows : [];
  1976. const currentViewers = Array.isArray(this.liveViewers) ? this.liveViewers : [];
  1977. let viewlist = isLoadMore ? [...currentViewers, ...newRows] : newRows;
  1978. this.liveViewers = [...viewlist, ...virtualData]
  1979. this.viewPageNum++;
  1980. }
  1981. } catch (error) {
  1982. console.error('获取观众列表失败:', error);
  1983. } finally {
  1984. this.viewLoading = false;
  1985. }
  1986. },
  1987. //小黄车搜索商品
  1988. handleSearchInput() {
  1989. // 使用防抖优化性能,避免频繁请求
  1990. clearTimeout(this.searchTimer);
  1991. this.searchTimer = setTimeout(() => {
  1992. this.queryCollect();
  1993. }, 500); // 500毫秒延迟
  1994. },
  1995. // 显示购买提示信息
  1996. showPurchaseMessage() {
  1997. // 清除之前的定时器
  1998. if (this.purchasePromptTimer) {
  1999. clearTimeout(this.purchasePromptTimer);
  2000. }
  2001. // 显示提示
  2002. this.showPurchasePrompt = true;
  2003. // 2秒后自动隐藏
  2004. this.purchasePromptTimer = setTimeout(() => {
  2005. this.showPurchasePrompt = false;
  2006. }, 2000);
  2007. },
  2008. //名字超过省略
  2009. truncateString(str, maxLength) {
  2010. if (typeof str !== 'string' || str.length <= maxLength) {
  2011. return str;
  2012. }
  2013. return str.slice(0, maxLength) + '...'; // 截断后加省略号
  2014. },
  2015. // 跳转页面
  2016. navgetTo(url) {
  2017. uni.navigateTo({
  2018. url: url
  2019. })
  2020. },
  2021. // 修改获取直播信息方法
  2022. async getliving(liveId) {
  2023. if (!liveId) return;
  2024. const param = {
  2025. id: liveId
  2026. };
  2027. try {
  2028. const res = await getlive(param);
  2029. if (res.code !== 200) {
  2030. uni.showToast({
  2031. title: res.msg,
  2032. icon: 'none'
  2033. });
  2034. return;
  2035. }
  2036. this.liveItem = Object.assign({}, this.liveItem, res.data);
  2037. // this.talklist = Array.isArray((res.data || {}).talklist) ? res.data.talklist : [];
  2038. this.startTimeTimer(this.liveItem);
  2039. // 清除旧定时器(如预告倒计时)
  2040. if (this.liveStartTimer) {
  2041. clearInterval(this.liveStartTimer);
  2042. this.liveStartTimer = null;
  2043. }
  2044. if (res.data.status == 1) {
  2045. // 直播预告
  2046. this.liveStartTimer = setInterval(async () => {
  2047. this.liveCountdown = this.handleTime(res.data.startTime, 0);
  2048. if (!this.liveCountdown) {
  2049. uni.removeStorageSync('isAgreement');
  2050. await this.getliving(this.liveId);
  2051. clearInterval(this.liveStartTimer);
  2052. }
  2053. }, 1000);
  2054. this.$set(this.liveItem, 'previewUrl', res.data.previewUrl);
  2055. this.$set(this.liveItem, 'livingUrl', ''); // 清空直播流
  2056. this.$set(this.liveItem, 'videoUrl', ''); // 清空回放视频
  2057. } else if (res.data.status == 2) {
  2058. if (res.data.liveType == 1) {
  2059. // 直播流
  2060. let cTime = Math.floor(Math.random() * 10000) + 1;
  2061. let livingUrl = res.data.flvHlsUrl + "&t=" + cTime;
  2062. console.log("地址在", this.liveItem.livingUrl)
  2063. this.$set(this.liveItem, 'livingUrl', livingUrl);
  2064. this.$set(this.liveItem, 'videoUrl', ''); // 清空回放视频
  2065. } else if (res.data.liveType === 2) {
  2066. // 回放视频 2录播 3直播回放
  2067. // let urlStr = 'https://fs-1319721001.cos.ap-chongqing.myqcloud.com/10%E6%9C%8820%E6%97%A5%20%281%29.m3u8'
  2068. // this.$set(this.liveItem, 'videoUrl', urlStr);
  2069. this.$set(this.liveItem, 'videoUrl', res.data.videoUrl);
  2070. this.$set(this.liveItem, 'livingUrl', '');
  2071. }
  2072. } else if (res.data.status == 4 && res.data.liveType == 3) {
  2073. this.$set(this.liveItem, 'videoUrl', res.data.videoUrl);
  2074. this.$set(this.liveItem, 'livingUrl', '');
  2075. } else {
  2076. // 未开播
  2077. this.$set(this.liveItem, 'livingUrl', '');
  2078. this.$set(this.liveItem, 'videoUrl', '');
  2079. }
  2080. this.$set(this.liveItem, 'autoplay', res.data.liveType !== 0);
  2081. this.$set(this.liveItem, 'showType', res.data.showType);
  2082. this.storeId = res.storeId;
  2083. // 启动“30秒刷新直播间数据”的定时器
  2084. this.startLiveViewDataTimer();
  2085. this.playVideo();
  2086. } catch (err) {
  2087. console.error("获取直播信息失败:", err);
  2088. uni.showToast({
  2089. title: "获取直播信息失败",
  2090. icon: 'none'
  2091. });
  2092. }
  2093. },
  2094. getPureDecimal(num, precision = 6) {
  2095. const decimalPart = Math.abs(num).toFixed(precision).split('.')[1];
  2096. return decimalPart?.replace(/0+$/, '') || ''; // 移除末尾多余的0
  2097. },
  2098. goBack() {
  2099. // 暂停当前视频
  2100. if (this.liveItem) {
  2101. this.pauseVideo();
  2102. }
  2103. // 关闭WebSocket连接
  2104. this.closeWebSocket(true);
  2105. // 导航返回
  2106. const pages = getCurrentPages();
  2107. if (pages.length > 1) {
  2108. uni.navigateBack();
  2109. } else {
  2110. uni.reLaunch({
  2111. url: '/pages_course/livingList'
  2112. });
  2113. }
  2114. },
  2115. // 点赞
  2116. async onLike() {
  2117. console.log("点到了")
  2118. if (!this.liveId) return;
  2119. try {
  2120. const res = await liveDataLike(this.liveId);
  2121. if (res?.like) {
  2122. this.liveViewData.like++; // 只更新当前直播间的点赞数
  2123. } else {
  2124. uni.showToast({
  2125. title: res.msg,
  2126. icon: 'none'
  2127. });
  2128. }
  2129. } catch (error) {
  2130. console.error('点赞失败:', error);
  2131. }
  2132. },
  2133. //直播间点赞、关注、在线人数数据
  2134. getliveViewData(liveItem) {
  2135. if (!liveItem || !this.liveId) return;
  2136. getLiveViewData(this.liveId).then(res => {
  2137. if (res.code == 200) {
  2138. // 强制响应式更新,确保数据实时显示
  2139. this.liveViewData = res;
  2140. }
  2141. }).catch(error => {
  2142. console.error("获取直播间数据失败:", error);
  2143. // 失败时兜底,避免显示异常
  2144. this.liveViewData = {
  2145. like: 0,
  2146. watchCount: 0
  2147. };
  2148. });
  2149. },
  2150. // 30秒刷新一下直播间点赞数
  2151. startLiveViewDataTimer() {
  2152. // 先清除旧定时器(防止重复创建)
  2153. if (this.liveViewDataTimer) {
  2154. clearInterval(this.liveViewDataTimer);
  2155. this.liveViewDataTimer = null;
  2156. }
  2157. // 启动新定时器,每3秒执行一次
  2158. this.liveViewDataTimer = setInterval(() => {
  2159. // 安全校验:确保liveItem和liveId存在(避免无效请求)
  2160. if (this.liveItem && this.liveId) {
  2161. this.getliveViewData(this.liveItem);
  2162. }
  2163. }, 30000);
  2164. },
  2165. // 去购买,跳商品详情
  2166. goShop(productId, goodsId) {
  2167. if (!this.liveId) return;
  2168. uni.navigateTo({
  2169. url: '/pages_shopping/live/goods?productId=' + productId + '&liveId=' + this.liveId +
  2170. '&goodsId=' +
  2171. goodsId + '&storeId=' + this.storeId
  2172. })
  2173. },
  2174. // 查询店铺
  2175. async queryCollect() {
  2176. this.loadingProducts = true;
  2177. if (!this.liveId) return;
  2178. if (this.inputInfo == null) this.inputInfo = ''
  2179. uni.showLoading({
  2180. title: '加载中'
  2181. });
  2182. try {
  2183. const res = await liveStore(this.liveId, this.inputInfo);
  2184. uni.hideLoading()
  2185. this.shopping = true
  2186. if (res.code === 200) {
  2187. // 数据绑定到当前 liveItem,避免全局污染
  2188. this.products = Array.isArray(res.data) ? res.data : [];
  2189. }
  2190. } catch (error) {
  2191. console.error('获取小黄车商品失败:', error);
  2192. } finally {
  2193. this.loadingProducts = false;
  2194. }
  2195. },
  2196. // 时间戳
  2197. initTime() {
  2198. const now = new Date();
  2199. this.timestamp = now.getTime();
  2200. },
  2201. openCart() {
  2202. this.queryCollect()
  2203. },
  2204. close() {
  2205. this.showadd = false
  2206. },
  2207. // 关闭小黄车
  2208. closeShop() {
  2209. this.shopping = false;
  2210. },
  2211. closeMore() {
  2212. this.isMore = false;
  2213. },
  2214. closeWin() {
  2215. this.winning = false;
  2216. },
  2217. // 关闭WebSocket连接(isManual:是否手动关闭)
  2218. closeWebSocket(isManual = true) {
  2219. if (!this.socket || !this.isSocketOpen) {
  2220. console.warn("WebSocket 任务不存在或未打开,无需关闭");
  2221. return;
  2222. }
  2223. // console.log("websocket 连接关闭");
  2224. this.isManualClose = isManual;
  2225. this.stopHeartBeat();
  2226. this.resetReconnectState();
  2227. try {
  2228. // 先保存引用,避免在关闭过程中被置为null
  2229. const socketToClose = this.socket;
  2230. this.socket = null;
  2231. this.isSocketOpen = false;
  2232. socketToClose.close({
  2233. code: 1000,
  2234. reason: isManual ? "主动关闭" : "异常关闭"
  2235. });
  2236. console.log("WebSocket连接已发起关闭");
  2237. } catch (err) {
  2238. console.error("关闭WebSocket失败:", err);
  2239. // 即使关闭失败,也要重置状态
  2240. this.socket = null;
  2241. this.isSocketOpen = false;
  2242. }
  2243. },
  2244. startHeartBeat() {
  2245. this.stopHeartBeat(); // 先停止现有心跳,防止重复
  2246. this.sendHeartBeat(); // 立即发送一次心跳
  2247. // 按间隔循环发送心跳
  2248. this.heartBeatTimer = setInterval(() => {
  2249. this.sendHeartBeat();
  2250. }, this.heartBeatInterval);
  2251. },
  2252. initSocket() {
  2253. if (this.isConnecting) {
  2254. return;
  2255. }
  2256. // 如果已经存在连接且状态为open,则退出
  2257. if (this.socket && this.socket.readyState === 1) {
  2258. return;
  2259. }
  2260. if (this.socket && (this.socket.readyState === 0 || this.socket.readyState === 1)) {
  2261. console.log('关闭现有WebSocket连接,创建新连接');
  2262. this.closeWebSocket(true);
  2263. }
  2264. // 校验必要参数
  2265. if (!this.liveId) {
  2266. console.error("缺失直播间ID,无法初始化WebSocket");
  2267. return;
  2268. }
  2269. if (!this.userData || !this.userData.userId) {
  2270. console.error("用户信息缺失,无法初始化WebSocket");
  2271. return;
  2272. }
  2273. // 清除之前的重连定时器
  2274. this.resetReconnectState();
  2275. const now = new Date();
  2276. this.timestamp = now.getTime(); // 生成签名
  2277. const signature = CryptoJS.HmacSHA256(
  2278. `${this.liveId}${this.userData.userId}${this.userType}${this.timestamp}`,
  2279. this.timestamp.toString()
  2280. ).toString(CryptoJS.enc.Hex);
  2281. try {
  2282. const baseWsUrl = 'wss://api.fhhx.runtzh.com/ws/app/webSocket';
  2283. // const baseWsUrl = 'ws://192.168.10.166:7114/ws/app/webSocket';
  2284. let wsUrl =
  2285. `${baseWsUrl}?userId=${this.userData.userId}&liveId=${this.liveId}&userType=${this.userType}&timestamp=${this.timestamp}&signature=${signature}`;
  2286. if (this.qrFrom) {
  2287. wsUrl += this.qrFrom;
  2288. }
  2289. const socketTask = uni.connectSocket({
  2290. url: wsUrl,
  2291. success: () => {
  2292. // console.log("Socket连接请求发送成功")
  2293. },
  2294. fail: (err) => {
  2295. console.error("Socket连接请求失败:", err);
  2296. this.handleReconnect();
  2297. }
  2298. });
  2299. // 连接打开事件
  2300. socketTask.onOpen((res) => {
  2301. // console.log("WebSocket连接已打开");
  2302. this.socket = socketTask;
  2303. this.isConnecting = false;
  2304. this.isSocketOpen = true;
  2305. this.reconnectCount = 0;
  2306. this.resetReconnectState();
  2307. this.heartBeatRetryCount = 0; // 重置心跳重试次数
  2308. this.shownEntryUsers.clear(); // 重连后重置进入提示记录
  2309. this.startHeartBeat();
  2310. });
  2311. // 消息接收事件
  2312. socketTask.onMessage((res) => {
  2313. try {
  2314. const data = JSON.parse(res.data);
  2315. // 处理服务端心跳响应
  2316. if (data.cmd === "heartBeatAck") {
  2317. this.stopHeartBeat(); // 清除当前超时检测
  2318. this.startHeartBeat(); // 重新启动心跳周期
  2319. return;
  2320. }
  2321. this.handleSocketMessage(res);
  2322. } catch (err) {
  2323. console.error("消息解析异常:", err);
  2324. }
  2325. });
  2326. // 连接错误事件
  2327. socketTask.onError((err) => {
  2328. console.error("WebSocket连接错误:", err);
  2329. this.isSocketOpen = false;
  2330. this.stopHeartBeat();
  2331. this.isConnecting = false;
  2332. this.handleReconnect(); // 错误直接触发重连
  2333. });
  2334. // 连接关闭事件
  2335. socketTask.onClose((res) => {
  2336. console.log("WebSocket连接关闭:", res);
  2337. this.isSocketOpen = false;
  2338. this.isConnecting = false;
  2339. this.stopHeartBeat(); // 清除心跳定时器
  2340. if (!this.isManualClose && this.reconnectCount < this.maxReconnectAttempts) {
  2341. this.handleReconnect();
  2342. } else {}
  2343. });
  2344. } catch (e) {
  2345. console.error("创建WebSocket异常:", e);
  2346. this.handleReconnect();
  2347. }
  2348. },
  2349. handleTime(time, duration) {
  2350. // 将time转换为毫秒级时间戳
  2351. let timeStamp;
  2352. // 如果time是数字且合理(毫秒级时间戳通常为13位左右的正数),视为有效时间戳
  2353. if (typeof time === 'number' && time > 0 && time < 9999999999999) {
  2354. timeStamp = time;
  2355. }
  2356. //如果是字符串,尝试解析为日期后转为时间戳
  2357. else if (typeof time === 'string' && time.trim() !== '') {
  2358. // 处理兼容性:将"2025-09-25 17:30:00"转为ISO格式"2025-09-25T17:30:00"
  2359. const isoTime = time.replace(' ', 'T');
  2360. const date = new Date(isoTime);
  2361. // 校验日期是否有效
  2362. if (!isNaN(date.getTime())) {
  2363. timeStamp = date.getTime();
  2364. } else {
  2365. console.error('无效的日期格式:', time);
  2366. return false; // 格式错误时返回false
  2367. }
  2368. } else {
  2369. console.error('time参数必须是有效的时间戳(数字)或日期字符串');
  2370. return false;
  2371. }
  2372. // 后续逻辑保持不变(基于转换后的timeStamp计算)
  2373. const targetTimestamp = timeStamp + duration * 60 * 1000;
  2374. const currentTimestamp = new Date().getTime();
  2375. const timeDiffMs = targetTimestamp - currentTimestamp;
  2376. if (timeDiffMs <= 0) {
  2377. return false;
  2378. }
  2379. const hours = Math.floor(timeDiffMs / (1000 * 60 * 60));
  2380. const minutes = Math.floor((timeDiffMs % (1000 * 60 * 60)) / (1000 * 60));
  2381. const seconds = Math.floor((timeDiffMs % (1000 * 60)) / 1000);
  2382. const formatNum = (num) => num.toString().padStart(2, "0");
  2383. return {
  2384. hours: formatNum(hours),
  2385. minutes: formatNum(minutes),
  2386. seconds: formatNum(seconds)
  2387. };
  2388. },
  2389. // 限制聊天消息数量,防止内存泄漏
  2390. addToTalkList(message) {
  2391. const MAX_TALK_ITEMS = 30;
  2392. const oldList = Array.isArray(this.talklist) ? this.talklist : [];
  2393. const newList = [...oldList, message];
  2394. if (newList.length > MAX_TALK_ITEMS) {
  2395. newList.splice(0, newList.length - MAX_TALK_ITEMS);
  2396. }
  2397. this.talklist = newList;
  2398. // 使用 setTimeout 替代 requestAnimationFrame
  2399. setTimeout(() => {
  2400. this.scrollToBottom();
  2401. }, 0);
  2402. },
  2403. // 处理Socket消息
  2404. async handleSocketMessage(message) {
  2405. let data = JSON.parse(message.data)
  2406. const socketMessage = data.data // 服务端返回的消息体
  2407. if (data.code == 200) {
  2408. const messageData = {
  2409. ...socketMessage,
  2410. cmd: socketMessage.cmd || '', // 确保cmd字段存在
  2411. ts: Date.now() // 时间戳
  2412. };
  2413. // 处理服务端返回的sendMsg消息,加入本地列表
  2414. if (socketMessage.cmd == 'sendMsg') {
  2415. if (!this.isSocketAvailable()) {
  2416. uni.showToast({
  2417. title: '连接已断开,正在重试...',
  2418. icon: 'none'
  2419. });
  2420. this.handleReconnect();
  2421. return;
  2422. }
  2423. this.addToTalkList(messageData);
  2424. } else if (socketMessage.cmd == 'red') {
  2425. const redData = socketMessage.data ? JSON.parse(socketMessage.data) : {};
  2426. this.redInfo = redData || {};
  2427. this.isShowRed = socketMessage.status === 1;
  2428. if (this.isShowRed) {
  2429. this.redTimer = setInterval(() => {
  2430. const redCountdown = this.handleTime(this.redInfo.updateTime, this.redInfo
  2431. .duration)
  2432. if (!redCountdown) {
  2433. this.isShowRed = false
  2434. clearInterval(this.redTimer)
  2435. }
  2436. }, 1000);
  2437. }
  2438. } else if (socketMessage.cmd == 'goods') {
  2439. const goodsData = socketMessage.data ? JSON.parse(socketMessage.data) : {};
  2440. this.goodsCard = goodsData || {};
  2441. this.isShowGoods = socketMessage.status == 1;
  2442. } else if (socketMessage.cmd == 'coupon') {
  2443. const couponData = socketMessage.data ? JSON.parse(socketMessage.data) : {};
  2444. this.couponInfo = couponData || {};
  2445. this.isShowCoupon = socketMessage.status === 1;
  2446. if (this.isShowCoupon) {}
  2447. } else if (socketMessage.cmd == 'lottery') {
  2448. const lotteryData = socketMessage.data ? JSON.parse(socketMessage.data) : {};
  2449. this.lotteryInfo = lotteryData || {};
  2450. this.isShowLottery = socketMessage.status === 1;
  2451. if (socketMessage.status != 1) {
  2452. this.isShowLotteryPop = false
  2453. }
  2454. // 清除已有定时器(无论状态是否为1,先清掉旧的)
  2455. clearTimeout(this.lotteryTimer);
  2456. if (this.isShowLottery) {
  2457. this.countdown = this.handleTime(this.lotteryInfo.updateTime, this.lotteryInfo
  2458. .duration)
  2459. if (this.countdown) {
  2460. this.lotteryTimer = setInterval(() => {
  2461. this.countdown = this.handleTime(this.lotteryInfo.updateTime, this
  2462. .lotteryInfo
  2463. .duration)
  2464. if (!this.countdown) {
  2465. // console.log("倒计时", this.countdown)
  2466. this.isShowLottery = false;
  2467. this.isShowLotteryPop = false;
  2468. clearInterval(this.lotteryTimer)
  2469. }
  2470. }, 1000);
  2471. }
  2472. } else {
  2473. this.isShowLottery = false
  2474. }
  2475. } else if (socketMessage.cmd == 'entry') {
  2476. try {
  2477. if (!this.liveUserCalled) {
  2478. await this.getliveUser(false);
  2479. this.liveUserCalled = true;
  2480. }
  2481. const userIdToEntry = socketMessage.userId;
  2482. const existingIndex = this.liveViewersData.findIndex(item => item.userId ===
  2483. userIdToEntry);
  2484. if (existingIndex === -1) {
  2485. const liveViewers = {
  2486. userId: socketMessage.userId,
  2487. nickName: socketMessage.nickName,
  2488. avatar: socketMessage.avatar
  2489. }
  2490. this.liveViewersData.push(liveViewers);
  2491. this.liveUserTotal++;
  2492. }
  2493. // 解析用户ID(根据实际接口字段调整,此处假设data含userId)
  2494. const userData = JSON.parse(socketMessage.data || '{}');
  2495. const userId = userData.userId || socketMessage.userId; // 兼容不同字段
  2496. if (!userId) return; // 无用户ID不处理
  2497. // 仅新用户(未显示过)才触发提示
  2498. if (!this.shownEntryUsers.has(userId)) {
  2499. this.inAndOut = socketMessage;
  2500. this.showWelcomeMessage = true;
  2501. this.shownEntryUsers.add(userId); // 加入已显示集合
  2502. // 3秒后隐藏提示(可调整时长)
  2503. if (this.welcomeTimer) clearTimeout(this.welcomeTimer);
  2504. this.welcomeTimer = setTimeout(() => {
  2505. this.showWelcomeMessage = false;
  2506. }, 3000);
  2507. }
  2508. } catch (err) {
  2509. console.error("解析entry用户数据失败:", err);
  2510. }
  2511. } else if (socketMessage.cmd == 'out') {
  2512. if (this.liveUserTotal > 0) {
  2513. const userIdToRemove = socketMessage.userId;
  2514. const index = this.liveViewersData.findIndex(item => item.userId === userIdToRemove);
  2515. if (index !== -1) {
  2516. this.liveViewersData.splice(index, 1);
  2517. this.liveUserTotal--; // 根据userId删除对应的用户数据
  2518. }
  2519. }
  2520. this.inAndOut = socketMessage;
  2521. this.showWelcomeMessage = true;
  2522. // 3秒后隐藏提示
  2523. if (this.welcomeTimer) clearTimeout(this.welcomeTimer);
  2524. this.welcomeTimer = setTimeout(() => {
  2525. this.showWelcomeMessage = false;
  2526. }, 3000);
  2527. } else if (socketMessage.cmd == 'live_start' || socketMessage.cmd ==
  2528. 'live_end') {
  2529. // 开始直播,关闭直播
  2530. if (this.liveStartTimer) {
  2531. clearInterval(this.liveStartTimer);
  2532. this.liveStartTimer = null;
  2533. }
  2534. if (this.redTimer) {
  2535. clearInterval(this.redTimer);
  2536. this.redTimer = null;
  2537. }
  2538. // 请求最新直播间数据
  2539. await this.getliving(this.liveId);
  2540. } else if (socketMessage.cmd == 'Integral') {
  2541. this.integral = {
  2542. msg: socketMessage.msg,
  2543. status: true
  2544. }
  2545. } else if (socketMessage.cmd == 'LotteryDetail') {
  2546. try {
  2547. this.prizeInfo = Array.isArray(JSON.parse(socketMessage.data || '[]')) ?
  2548. JSON.parse(socketMessage.data || '[]') : [];
  2549. } catch (err) {
  2550. console.error('解析抽奖结果失败:', err);
  2551. this.prizeInfo = [];
  2552. }
  2553. this.isShowPrize = true;
  2554. this.isShowLottery = false;
  2555. this.isShowLotteryPop = false;
  2556. } else if (socketMessage.cmd == 'blockUser') {
  2557. uni.removeStorage({
  2558. key: 'AppToken',
  2559. success: () => {
  2560. uni.reLaunch({
  2561. url: '/pages/auth/login'
  2562. });
  2563. }
  2564. });
  2565. }
  2566. } else {
  2567. uni.showToast({
  2568. title: data.msg,
  2569. icon: 'none'
  2570. });
  2571. }
  2572. },
  2573. sendMsg(retries = 1) {
  2574. // 防止连续点击发送两次(800ms短时锁定)
  2575. if (this.isSending) return;
  2576. this.isSending = true;
  2577. setTimeout(() => {
  2578. this.isSending = false;
  2579. }, 800);
  2580. const text = (this.value || '').trim();
  2581. if (!text) {
  2582. uni.showToast({
  2583. title: "不能发送空消息",
  2584. icon: 'none'
  2585. });
  2586. return;
  2587. }
  2588. if (!this.isSocketAvailable()) {
  2589. if (retries > 0) {
  2590. uni.showToast({
  2591. title: `连接不稳定,正在重试(${retries}次)...`,
  2592. icon: 'none'
  2593. });
  2594. // 延迟500ms重试,重试次数减1
  2595. setTimeout(() => this.sendMsg(retries - 1), 500);
  2596. } else {
  2597. uni.showToast({
  2598. title: '连接已断开,发送失败',
  2599. icon: 'none'
  2600. });
  2601. this.value = text; // 恢复输入框内容
  2602. }
  2603. return;
  2604. }
  2605. const liveId = this.liveId;
  2606. this.value = ''; // 立即清空输入框
  2607. // 构造发送给服务端的消息数据
  2608. const data = {
  2609. liveId,
  2610. userId: this.userData.userId,
  2611. userType: 0,
  2612. cmd: "sendMsg",
  2613. msg: text,
  2614. nickName: this.userData.nickname || '未命名',
  2615. avatar: this.userData.avatar || '/static/images/avatar.png'
  2616. };
  2617. // 发送socket消息
  2618. try {
  2619. this.socket.send({
  2620. data: JSON.stringify(data),
  2621. success: () => {
  2622. this.value = '';
  2623. },
  2624. fail: (err) => {
  2625. console.error("消息发送失败:", err);
  2626. if (retries > 0) {
  2627. uni.showToast({
  2628. title: `发送失败,正在重试(${retries}次)`,
  2629. icon: 'none'
  2630. });
  2631. setTimeout(() => this.sendMsg(retries - 1), 500);
  2632. } else {
  2633. uni.showToast({
  2634. title: '发送失败,请稍后再试',
  2635. icon: 'none'
  2636. });
  2637. this.value = text; // 恢复输入框内容
  2638. }
  2639. }
  2640. });
  2641. } catch (err) {
  2642. console.error("发送消息异常:", err);
  2643. if (retries > 0) {
  2644. setTimeout(() => this.sendMsg(retries - 1), 500);
  2645. } else {
  2646. uni.showToast({
  2647. title: '发送失败,请稍后再试',
  2648. icon: 'none'
  2649. });
  2650. this.value = text;
  2651. }
  2652. }
  2653. }
  2654. }
  2655. };
  2656. </script>
  2657. <style scoped lang="scss">
  2658. .input-bottom {
  2659. .button -reset::after {
  2660. border: none !important;
  2661. padding: 0 !important;
  2662. margin: 0 !important;
  2663. }
  2664. .button-reset {
  2665. background-color: transparent !important;
  2666. padding: 0 !important;
  2667. line-height: inherit !important;
  2668. margin: 0 !important;
  2669. width: auto !important;
  2670. font-weight: 500 !important;
  2671. border-radius: none !important;
  2672. }
  2673. .num {
  2674. width: 36rpx;
  2675. height: 20rpx;
  2676. background: #FFFFFF;
  2677. border-radius: 10rpx 10rpx 10rpx 10rpx;
  2678. text-align: center;
  2679. line-height: 20rpx;
  2680. position: absolute;
  2681. bottom: -10rpx;
  2682. font-weight: 600;
  2683. font-size: 14rpx;
  2684. color: #FA341E;
  2685. }
  2686. }
  2687. .horizontal {
  2688. background-color: rgba(23, 23, 23, 0.8);
  2689. }
  2690. .vertical {
  2691. background: rgba(0, 0, 0, 0.3);
  2692. }
  2693. .skeleton-item {
  2694. display: flex;
  2695. padding: 20rpx;
  2696. background: #fff;
  2697. margin-bottom: 16rpx;
  2698. border-radius: 16rpx;
  2699. }
  2700. .skeleton-img {
  2701. width: 200rpx;
  2702. height: 200rpx;
  2703. background: #f0f0f0;
  2704. border-radius: 8rpx;
  2705. margin-right: 24rpx;
  2706. animation: pulse 1.5s ease-in-out infinite;
  2707. }
  2708. .skeleton-content {
  2709. flex: 1;
  2710. }
  2711. .skeleton-line {
  2712. height: 20rpx;
  2713. background: #f0f0f0;
  2714. margin-bottom: 16rpx;
  2715. border-radius: 4rpx;
  2716. animation: pulse 1.5s ease-in-out infinite;
  2717. }
  2718. .skeleton-line.short {
  2719. width: 60%;
  2720. }
  2721. .skeleton-line.medium {
  2722. width: 80%;
  2723. }
  2724. .skeleton-line.long {
  2725. width: 95%;
  2726. }
  2727. @keyframes pulse {
  2728. 0% {
  2729. opacity: 1;
  2730. }
  2731. 50% {
  2732. opacity: 0.5;
  2733. }
  2734. 100% {
  2735. opacity: 1;
  2736. }
  2737. }
  2738. ::v-deep .u-icon--right {
  2739. justify-content: flex-end !important;
  2740. }
  2741. // 无头像用户文字样式
  2742. .text-white {
  2743. color: #ffffff;
  2744. }
  2745. .text-xs {
  2746. font-size: 18rpx;
  2747. }
  2748. .text-sm {
  2749. font-size: 24rpx;
  2750. }
  2751. .w52,
  2752. .w72 {
  2753. display: flex;
  2754. align-items: center;
  2755. justify-content: center;
  2756. }
  2757. .swiper-wrapper {
  2758. position: relative;
  2759. width: 100%;
  2760. height: 100vh;
  2761. overflow: hidden;
  2762. background-color: #000000;
  2763. .container {
  2764. width: 100%;
  2765. height: 100%;
  2766. position: relative;
  2767. transition: opacity 0.3s ease;
  2768. transform: translateZ(0);
  2769. will-change: opacity;
  2770. }
  2771. }
  2772. .welcome-message {
  2773. position: fixed;
  2774. width: 100%;
  2775. bottom: 38vh;
  2776. left: 50%;
  2777. transform: translateX(-50%);
  2778. color: white;
  2779. padding: 10px 20px;
  2780. border-radius: 20px;
  2781. z-index: 10;
  2782. transition: opacity 0.3s ease;
  2783. }
  2784. .send {
  2785. background-color: #fafafa;
  2786. border-radius: 28rpx;
  2787. // width: 50rpx;
  2788. // height: 80rpx;
  2789. width: 100rpx;
  2790. height: 70rpx;
  2791. line-height: 70rpx;
  2792. text-align: center;
  2793. // padding: 14rpx 16rpx;
  2794. color: #181818;
  2795. font-weight: 500;
  2796. }
  2797. /* 减少重绘和重排 */
  2798. .talk-list,
  2799. .viewer-item,
  2800. .message-item {
  2801. will-change: transform;
  2802. contain: layout style paint;
  2803. backface-visibility: hidden;
  2804. transform: translateZ(0);
  2805. }
  2806. .talk-list {
  2807. will-change: transform; // 提示浏览器优化
  2808. contain: layout style paint; // 限制渲染范围
  2809. max-width: 100%;
  2810. border-radius: 30rpx;
  2811. // background-color: rgba(33, 33, 33, 0.5);
  2812. padding: 10rpx 30rpx;
  2813. }
  2814. .content {
  2815. position: relative;
  2816. z-index: 2;
  2817. height: 100%;
  2818. width: 100%;
  2819. top: 0;
  2820. left: 0;
  2821. display: flex;
  2822. flex-direction: column;
  2823. justify-content: space-between;
  2824. // .activity-box {
  2825. // position: fixed;
  2826. // top: 188rpx;
  2827. // left: 30rpx;
  2828. // z-index: 999999;
  2829. // display: flex;
  2830. // align-items: center;
  2831. // .item-box {
  2832. // -webkit-transform: translateZ(0);
  2833. // /* 硬件加速 */
  2834. // transform: translateZ(0);
  2835. // border-radius: 16rpx;
  2836. // background-color: rgba(77, 77, 77, 0.5);
  2837. // width: 90rpx;
  2838. // height: 100rpx;
  2839. // margin-right: 20rpx;
  2840. // position: relative;
  2841. // z-index: 999;
  2842. // .tip {
  2843. // position: absolute;
  2844. // width: 100%;
  2845. // bottom: 0;
  2846. // color: #fafcff;
  2847. // font-size: 26rpx;
  2848. // background-color: rgba(15, 15, 15, 0.8);
  2849. // border-radius: 16rpx;
  2850. // text-align: center;
  2851. // }
  2852. // .item {
  2853. // margin: 0 auto;
  2854. // padding: 10rpx 0;
  2855. // .img {
  2856. // height: 100%;
  2857. // }
  2858. // }
  2859. // }
  2860. // }
  2861. // 减少重绘
  2862. .side-group,
  2863. .content-top {
  2864. will-change: transform;
  2865. }
  2866. .side-group {
  2867. position: absolute;
  2868. top: 55%;
  2869. right: 30rpx;
  2870. z-index: 1000;
  2871. display: flex;
  2872. flex-direction: column;
  2873. align-items: center;
  2874. // .side-item {
  2875. // font-weight: 500;
  2876. // font-size: 24rpx;
  2877. // color: #FFFFFF;
  2878. // margin-bottom: 32rpx;
  2879. // text-align: center;
  2880. // .button -reset::after {
  2881. // border: none !important;
  2882. // padding: 0 !important;
  2883. // margin: 0 !important;
  2884. // }
  2885. // .button-reset {
  2886. // background-color: transparent !important;
  2887. // padding: 0 !important;
  2888. // line-height: inherit !important;
  2889. // margin: 0 !important;
  2890. // width: auto !important;
  2891. // font-weight: 500 !important;
  2892. // border-radius: none !important;
  2893. // }
  2894. // .image {
  2895. // width: 72rpx;
  2896. // height: 72rpx;
  2897. // }
  2898. // }
  2899. .item-box {
  2900. -webkit-transform: translateZ(0);
  2901. /* 硬件加速 */
  2902. transform: translateZ(0);
  2903. border-radius: 16rpx;
  2904. width: 96rpx;
  2905. height: 96rpx;
  2906. position: relative;
  2907. z-index: 999;
  2908. margin-bottom: 30rpx;
  2909. .tip {
  2910. position: absolute;
  2911. width: 100%;
  2912. bottom: 0;
  2913. color: #fafcff;
  2914. font-size: 26rpx;
  2915. background: rgba(0, 0, 0, 0.5);
  2916. text-align: center;
  2917. }
  2918. .item {
  2919. margin: 0 auto;
  2920. padding: 10rpx 0;
  2921. .img {
  2922. height: 100%;
  2923. }
  2924. }
  2925. }
  2926. }
  2927. .content-top {
  2928. width: 100%;
  2929. margin-top: 48rpx;
  2930. display: flex;
  2931. justify-content: space-between;
  2932. padding: 0 24rpx;
  2933. box-sizing: border-box;
  2934. .sum {
  2935. width: 80rpx;
  2936. height: 52rpx;
  2937. background: rgba(0, 0, 0, 0.5);
  2938. border-radius: 26rpx 26rpx 26rpx 26rpx;
  2939. font-size: 24rpx;
  2940. color: #FFFFFF;
  2941. text-align: center;
  2942. line-height: 52rpx;
  2943. }
  2944. }
  2945. .follow-btn {
  2946. padding: 8rpx 16rpx;
  2947. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  2948. border-radius: 26rpx;
  2949. font-weight: 500;
  2950. font-size: 26rpx;
  2951. color: #FFFFFF;
  2952. }
  2953. }
  2954. .trailer-box {
  2955. position: relative;
  2956. top: 15%;
  2957. display: flex;
  2958. flex-direction: column;
  2959. align-items: center;
  2960. color: #ffffff;
  2961. padding: 20rpx;
  2962. .button {
  2963. margin-top: 20rpx;
  2964. background: #6d7bd4;
  2965. color: #fff;
  2966. border-radius: 20rpx;
  2967. padding: 20rpx 30rpx;
  2968. position: relative;
  2969. z-index: 99999;
  2970. }
  2971. .ash {
  2972. background: #636363;
  2973. }
  2974. .countdown-item {
  2975. display: flex;
  2976. flex-direction: column;
  2977. align-items: center;
  2978. .white {
  2979. width: 60rpx;
  2980. height: 60rpx;
  2981. text-align: center;
  2982. overflow: hidden;
  2983. background: #FFFFFF;
  2984. border-radius: 8rpx;
  2985. margin: 30rpx 10rpx 0;
  2986. font-weight: 600;
  2987. font-size: 24rpx;
  2988. color: #000000;
  2989. line-height: 60rpx;
  2990. }
  2991. }
  2992. .item {
  2993. width: 100%;
  2994. height: 400rpx;
  2995. }
  2996. .name {
  2997. font-size: 34rpx;
  2998. }
  2999. .img {
  3000. margin-bottom: 40rpx;
  3001. width: 240rpx;
  3002. height: 240rpx;
  3003. }
  3004. .title {
  3005. margin-top: 30rpx;
  3006. font-size: 42rpx;
  3007. font-weight: 500;
  3008. }
  3009. }
  3010. .videolist {
  3011. position: relative;
  3012. height: 100vh;
  3013. width: 100%;
  3014. .video {
  3015. transform: translateZ(0);
  3016. backface-visibility: hidden;
  3017. perspective: 1000;
  3018. height: 100vh;
  3019. width: 100%;
  3020. // background-color: rgba(57, 57, 57, 0.4);
  3021. .item {
  3022. width: 100%;
  3023. height: 100%;
  3024. }
  3025. .time {
  3026. color: #ffffff;
  3027. font-size: 20rpx;
  3028. margin-left: 10rpx;
  3029. }
  3030. .end {
  3031. position: absolute;
  3032. top: 50%;
  3033. left: 50%;
  3034. transform: translate(-50%, -50%);
  3035. font-size: 36rpx;
  3036. color: #fff;
  3037. }
  3038. .lable {
  3039. position: absolute;
  3040. top: 50rpx;
  3041. right: 16rpx;
  3042. background-color: rgba(57, 57, 57, 0.6);
  3043. padding: 4rpx 10rpx;
  3044. color: #fff;
  3045. border-radius: 15rpx;
  3046. }
  3047. }
  3048. .video_row {
  3049. position: absolute;
  3050. top: 20%;
  3051. max-height: 450rpx;
  3052. z-index: 99;
  3053. }
  3054. }
  3055. .prize-card {
  3056. width: 504rpx;
  3057. padding: 40rpx 40rpx 30rpx;
  3058. box-sizing: border-box;
  3059. display: flex;
  3060. flex-direction: column;
  3061. border-radius: 20rpx;
  3062. align-items: center;
  3063. background: linear-gradient(180deg, #f7823f 0%, #ffd4be 27%, #ffffff 100%);
  3064. position: relative;
  3065. .nav-img {
  3066. width: 311rpx;
  3067. position: absolute;
  3068. top: -122rpx;
  3069. left: 50%;
  3070. transform: translateX(-50%);
  3071. }
  3072. .title {
  3073. color: #C32008;
  3074. font-size: 34rpx;
  3075. font-weight: 600;
  3076. margin: 20rpx 0 40rpx;
  3077. }
  3078. .prize-content {
  3079. width: 100%;
  3080. display: flex;
  3081. justify-content: space-between;
  3082. align-items: center;
  3083. font-size: 28rpx;
  3084. margin: 10rpx 0;
  3085. .txt {
  3086. font-weight: 600;
  3087. }
  3088. }
  3089. .tip {
  3090. font-size: 28rpx;
  3091. color: #414141;
  3092. margin: 40rpx 0;
  3093. }
  3094. .button {
  3095. width: 200rpx;
  3096. height: 70rpx;
  3097. line-height: 70rpx;
  3098. background: linear-gradient(180deg, #ff7c30 0%, #FF3A1E 100%);
  3099. border-radius: 28rpx;
  3100. font-weight: 500;
  3101. font-size: 32rpx;
  3102. color: #ffffff;
  3103. text-align: center;
  3104. }
  3105. }
  3106. .no-prize-card {
  3107. width: 504rpx;
  3108. padding: 40rpx 40rpx 30rpx;
  3109. box-sizing: border-box;
  3110. display: flex;
  3111. flex-direction: column;
  3112. border-radius: 20rpx;
  3113. align-items: center;
  3114. position: relative;
  3115. .img {
  3116. margin-top: 40rpx;
  3117. width: 300rpx;
  3118. height: 300rpx;
  3119. }
  3120. .tip {
  3121. font-size: 36rpx;
  3122. color: #414141;
  3123. margin: 40rpx 0;
  3124. }
  3125. .button {
  3126. width: 220rpx;
  3127. height: 80rpx;
  3128. line-height: 80rpx;
  3129. background: linear-gradient(180deg, #fdfbb8 0%, #b79243 100%);
  3130. border-radius: 28rpx;
  3131. font-weight: 500;
  3132. font-size: 32rpx;
  3133. color: #ffffff;
  3134. text-align: center;
  3135. }
  3136. }
  3137. .red-card {
  3138. width: 550rpx;
  3139. height: 636rpx;
  3140. position: relative;
  3141. .img {
  3142. position: absolute;
  3143. width: 100%;
  3144. height: 100%;
  3145. }
  3146. .red-content {
  3147. position: relative;
  3148. z-index: 5;
  3149. display: flex;
  3150. flex-direction: column;
  3151. align-items: center;
  3152. .title {
  3153. font-size: 36rpx;
  3154. color: #FF3A1E;
  3155. margin: 180rpx 0 90rpx;
  3156. }
  3157. .txt {
  3158. font-size: 28rpx;
  3159. color: #FFECC3;
  3160. margin: 80rpx 0 40rpx;
  3161. }
  3162. .button {
  3163. width: 392rpx;
  3164. height: 96rpx;
  3165. line-height: 96rpx;
  3166. background: linear-gradient(180deg, #FFF4D5 0%, #FFE5B1 100%);
  3167. border-radius: 48rpx 48rpx 48rpx 48rpx;
  3168. font-weight: 600;
  3169. font-size: 36rpx;
  3170. color: #C32008;
  3171. text-align: center;
  3172. }
  3173. }
  3174. }
  3175. .integral-box {
  3176. min-width: 400rpx;
  3177. max-width: 600rpx;
  3178. display: flex;
  3179. flex-direction: column;
  3180. align-items: center;
  3181. border-radius: 20rpx;
  3182. overflow: hidden;
  3183. .top {
  3184. width: 100%;
  3185. position: relative;
  3186. .title {
  3187. width: 100%;
  3188. font-weight: 600;
  3189. font-size: 40rpx;
  3190. color: #FFFFFF;
  3191. text-shadow: 0px 4px 8px rgba(255, 89, 2, 0.8);
  3192. position: absolute;
  3193. top: 50rpx;
  3194. text-align: center;
  3195. }
  3196. .photo {
  3197. width: 100%;
  3198. }
  3199. }
  3200. .item {
  3201. padding: 20rpx;
  3202. .title {
  3203. font-weight: 500;
  3204. font-size: 32rpx;
  3205. text-align: center;
  3206. }
  3207. .button {
  3208. font-size: 32rpx;
  3209. margin-top: 20rpx;
  3210. background: linear-gradient(270deg, #ff4702 0%, #fe6304 100%);
  3211. color: #fff;
  3212. text-align: center;
  3213. padding: 18rpx 60rpx;
  3214. border-radius: 10rpx;
  3215. font-weight: 500;
  3216. }
  3217. }
  3218. }
  3219. .goods {
  3220. position: fixed;
  3221. bottom: 140rpx;
  3222. right: 104rpx;
  3223. z-index: 5;
  3224. background-color: #fff;
  3225. border-radius: 20rpx;
  3226. overflow: hidden;
  3227. width: 280rpx;
  3228. padding: 4rpx;
  3229. .top {
  3230. position: absolute;
  3231. top: 4rpx;
  3232. display: flex;
  3233. justify-content: space-between;
  3234. align-items: center;
  3235. color: #fff;
  3236. width: 100%;
  3237. padding-right: 10rpx;
  3238. box-sizing: border-box;
  3239. .left {
  3240. background-color: rgba(0, 0, 0, 0.8);
  3241. padding: 12rpx;
  3242. font-size: 22rpx;
  3243. display: flex;
  3244. justify-content: space-between;
  3245. align-items: center;
  3246. border-radius: 10rpx;
  3247. }
  3248. }
  3249. .photo {
  3250. width: 100%;
  3251. height: 180rpx;
  3252. border-radius: 16rpx 16rpx 0 0;
  3253. overflow: hidden;
  3254. }
  3255. .item {
  3256. padding: 4rpx;
  3257. .price {
  3258. font-size: 30rpx;
  3259. .red {
  3260. color: #FF5701;
  3261. font-weight: 600;
  3262. margin-right: 10rpx;
  3263. }
  3264. .del {
  3265. color: #828282;
  3266. font-weight: 500;
  3267. font-size: 28rpx;
  3268. text-decoration: line-through
  3269. }
  3270. }
  3271. .title {
  3272. font-weight: 500;
  3273. font-size: 30rpx;
  3274. margin: 10rpx 0 12rpx;
  3275. }
  3276. .button {
  3277. background: linear-gradient(270deg, #ff4702 0%, #fe6304 100%);
  3278. color: #fff;
  3279. text-align: center;
  3280. padding: 16rpx 0;
  3281. border-radius: 10rpx;
  3282. font-weight: 500;
  3283. font-size: 30rpx;
  3284. }
  3285. }
  3286. }
  3287. .coupon-pop {
  3288. position: fixed;
  3289. bottom: 140rpx;
  3290. right: 100rpx;
  3291. z-index: 5;
  3292. border-radius: 20rpx;
  3293. width: 320rpx;
  3294. .coupon-block {
  3295. width: 100%;
  3296. position: relative;
  3297. .item {
  3298. width: 100%;
  3299. position: absolute;
  3300. top: 20rpx;
  3301. display: flex;
  3302. flex-direction: column;
  3303. align-items: center;
  3304. color: #fff;
  3305. .title {
  3306. font-weight: 500;
  3307. font-size: 30rpx;
  3308. margin: 16rpx 0 12rpx;
  3309. }
  3310. .price {
  3311. font-size: 40rpx;
  3312. .bold {
  3313. font-size: 56rpx;
  3314. font-weight: 600;
  3315. }
  3316. }
  3317. .txt {
  3318. font-weight: 500;
  3319. font-size: 30rpx;
  3320. margin: 5rpx 0;
  3321. }
  3322. .button {
  3323. background: linear-gradient(270deg, #fffce1 0%, #ffeaaf 100%);
  3324. color: #ff0004;
  3325. text-align: center;
  3326. padding: 16rpx 0;
  3327. border-radius: 40rpx;
  3328. font-weight: 500;
  3329. font-size: 30rpx;
  3330. width: 70%;
  3331. margin-top: 26rpx;
  3332. }
  3333. }
  3334. .bg {
  3335. height: 432rpx;
  3336. width: 100%;
  3337. }
  3338. .nav {
  3339. position: absolute;
  3340. height: 120rpx;
  3341. top: -120rpx;
  3342. left: 0;
  3343. width: 100%;
  3344. z-index: 6;
  3345. }
  3346. .close {
  3347. position: absolute;
  3348. right: 10rpx;
  3349. top: 10rpx;
  3350. }
  3351. }
  3352. }
  3353. .icon-bg {
  3354. border-radius: 50%;
  3355. width: 72rpx;
  3356. height: 72rpx;
  3357. display: flex;
  3358. justify-content: center;
  3359. align-items: center;
  3360. transition: transform 0.2s ease;
  3361. }
  3362. .list {
  3363. width: 80%;
  3364. margin-bottom: 20rpx;
  3365. animation: simpleFade .2s;
  3366. }
  3367. @keyframes simpleFade {
  3368. from {
  3369. opacity: 0;
  3370. }
  3371. to {
  3372. opacity: 1;
  3373. }
  3374. }
  3375. .shop-prompt {
  3376. position: absolute;
  3377. bottom: 750rpx;
  3378. left: 24rpx;
  3379. padding: 6rpx 20rpx;
  3380. background: rgba(230, 154, 34, 0.7);
  3381. border-radius: 24rpx;
  3382. z-index: 9;
  3383. font-weight: 500;
  3384. color: #FFFFFF;
  3385. transition: opacity 0.3s ease;
  3386. }
  3387. .view-box {
  3388. position: relative;
  3389. height: 40vh;
  3390. /* 设置弹出层高度为视窗高度的70% */
  3391. padding: 40rpx 0rpx;
  3392. box-sizing: border-box;
  3393. display: flex;
  3394. flex-direction: column;
  3395. .scroll-content {
  3396. flex: 1;
  3397. margin-top: 50rpx;
  3398. overflow-y: auto;
  3399. padding: 0 40rpx;
  3400. }
  3401. .bottom {
  3402. padding: 20rpx 40rpx;
  3403. position: absolute;
  3404. bottom: 0;
  3405. width: 100%;
  3406. box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(195, 195, 195, 0.3);
  3407. background: #fff;
  3408. }
  3409. }
  3410. // 抽奖
  3411. .prize-box {
  3412. position: relative;
  3413. .nav-img {
  3414. width: 311rpx;
  3415. position: absolute;
  3416. top: -122rpx;
  3417. left: 50%;
  3418. transform: translateX(-50%);
  3419. }
  3420. .bg-img {
  3421. position: absolute;
  3422. top: 0;
  3423. left: 0;
  3424. width: 100%;
  3425. height: 100%;
  3426. z-index: 1;
  3427. }
  3428. .prize-content {
  3429. position: relative;
  3430. z-index: 2;
  3431. padding: 24rpx 0 68rpx;
  3432. .item {
  3433. flex: 1;
  3434. text-align: center;
  3435. }
  3436. .white-item {
  3437. width: 40rpx;
  3438. height: 40rpx;
  3439. text-align: center;
  3440. overflow: hidden;
  3441. background: #FFFFFF;
  3442. box-shadow: inset 0rpx 2rpx 8rpx 0rpx #FFEBB2;
  3443. border-radius: 8rpx;
  3444. margin: 4rpx;
  3445. font-weight: 600;
  3446. font-size: 24rpx;
  3447. color: #F85D22;
  3448. line-height: 40rpx;
  3449. }
  3450. .item-group {
  3451. width: 100%;
  3452. }
  3453. .point-group {
  3454. margin: 20rpx 0 50rpx;
  3455. display: flex;
  3456. gap: 6rpx;
  3457. .item {
  3458. width: 20rpx;
  3459. height: 8rpx;
  3460. background: rgba(255, 255, 255, 0.5);
  3461. border-radius: 4rpx 4rpx 4rpx 4rpx;
  3462. }
  3463. .selected {
  3464. background: #FFEB66;
  3465. }
  3466. }
  3467. .button {
  3468. margin-top: 30rpx;
  3469. width: 520rpx;
  3470. height: 88rpx;
  3471. line-height: 88rpx;
  3472. background: linear-gradient(180deg, #FFF4D6 0%, #FFEB66 100%);
  3473. box-shadow: 0rpx 10rpx 8rpx 4rpx rgba(246, 82, 25, 0.5);
  3474. border-radius: 44rpx;
  3475. font-weight: 500;
  3476. font-size: 36rpx;
  3477. color: #F4410B;
  3478. text-align: center;
  3479. }
  3480. }
  3481. }
  3482. .more-block {
  3483. border-radius: 20rpx 0 0 20rpx;
  3484. padding: 70rpx 30rpx;
  3485. display: flex;
  3486. justify-content: space-between;
  3487. .item {
  3488. text-align: center;
  3489. }
  3490. }
  3491. .winning_record {
  3492. position: relative;
  3493. height: 800rpx;
  3494. .head_bg {
  3495. position: absolute;
  3496. top: -125rpx;
  3497. left: 50%;
  3498. width: 311rpx;
  3499. transform: translateX(-50%);
  3500. }
  3501. .bg {
  3502. width: 100%;
  3503. height: 100%;
  3504. }
  3505. .winning_content {
  3506. position: absolute;
  3507. top: 50rpx;
  3508. color: #fff;
  3509. width: 100%;
  3510. padding: 0 36rpx;
  3511. box-sizing: border-box;
  3512. .title {
  3513. text-align: center;
  3514. font-size: 40rpx;
  3515. font-weight: 500;
  3516. margin-bottom: 40rpx;
  3517. }
  3518. .row {
  3519. display: flex;
  3520. justify-content: space-between;
  3521. .head {
  3522. flex: 1;
  3523. text-align: center;
  3524. }
  3525. .start {
  3526. flex: 1;
  3527. }
  3528. .end {
  3529. flex: 1;
  3530. text-align: end;
  3531. }
  3532. }
  3533. }
  3534. }
  3535. .shoppop {
  3536. padding: 22rpx 16rpx;
  3537. .shoppop-top {
  3538. display: flex;
  3539. justify-content: space-between;
  3540. align-items: center;
  3541. padding: 0 16rpx 22rpx;
  3542. .search-input {
  3543. width: 414rpx;
  3544. height: 76rpx;
  3545. background: #FFFFFF;
  3546. border-radius: 36rpx;
  3547. margin-left: 20rpx;
  3548. padding: 0 32rpx;
  3549. box-sizing: border-box;
  3550. font-size: 24rpx;
  3551. margin-right: 24rpx;
  3552. }
  3553. .search-top {
  3554. font-size: 20rpx;
  3555. color: #222222;
  3556. }
  3557. }
  3558. .shop-list {
  3559. overflow: hidden;
  3560. .list-item {
  3561. display: flex;
  3562. align-items: center;
  3563. padding: 20rpx 16rpx;
  3564. background: #FFFFFF;
  3565. border-radius: 16rpx;
  3566. margin-bottom: 16rpx;
  3567. .goods-img {
  3568. width: 200rpx;
  3569. height: 200rpx;
  3570. border-radius: 16rpx;
  3571. overflow: hidden;
  3572. position: relative;
  3573. margin-right: 24rpx;
  3574. .img {
  3575. width: 100%;
  3576. height: 100%;
  3577. }
  3578. .goods-label {
  3579. position: absolute;
  3580. top: 0;
  3581. width: 64rpx;
  3582. height: 40rpx;
  3583. background: rgba(0, 0, 0, 0.5);
  3584. border-radius: 16rpx 0rpx 16rpx 0rpx;
  3585. text-align: center;
  3586. font-weight: 500;
  3587. font-size: 28rpx;
  3588. color: #FFFFFF;
  3589. }
  3590. }
  3591. .goods-right {
  3592. flex: 1;
  3593. .goods-title {
  3594. font-weight: 500;
  3595. font-size: 30rpx;
  3596. color: #000000;
  3597. margin-bottom: 10rpx;
  3598. }
  3599. .goods-details {
  3600. font-size: 24rpx;
  3601. color: #999999;
  3602. margin: 10rpx 0 20rpx;
  3603. }
  3604. .goods-people {
  3605. font-size: 22rpx;
  3606. color: #E69A22;
  3607. height: 56rpx;
  3608. }
  3609. .goods-shop {
  3610. display: flex;
  3611. justify-content: space-between;
  3612. .nummber {
  3613. color: #FF5C03;
  3614. font-size: 22rpx;
  3615. font-weight: 500;
  3616. }
  3617. .btn-group {
  3618. text-align: center;
  3619. line-height: 56rpx;
  3620. .collect-btn {
  3621. width: 72rpx;
  3622. height: 100%;
  3623. background: #F5F7FA;
  3624. border-radius: 8rpx 0rpx 0rpx 8rpx;
  3625. }
  3626. .shop-btn {
  3627. width: 152rpx;
  3628. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  3629. border-radius: 0rpx 8rpx 8rpx 0rpx;
  3630. font-weight: 500;
  3631. font-size: 30rpx;
  3632. color: #FFFFFF;
  3633. }
  3634. }
  3635. }
  3636. }
  3637. }
  3638. }
  3639. }
  3640. </style>