livingold.vue 108 KB

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