living.vue 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699
  1. <template>
  2. <view class="swiper-wrapper">
  3. <view class="container" :class="{active: true}">
  4. <view class="blackbg"></view>
  5. <view class="content">
  6. <!-- 页面内容 -->
  7. <view style="position: fixed;top: 0;z-index: 5;" class="content-top">
  8. <view class="u-flex-y-center">
  9. <image @click="goBack" class="w60 h64 mr26" src="/static/images/live/return.png">
  10. </image>
  11. <view class="align-center"
  12. style="padding: 6rpx 4rpx;height: 64rpx;background: rgba(0,0,0,0.5);border-radius: 32rpx;">
  13. <u-avatar :src="liveItem.liveImgUrl||$img.logo" size="32"></u-avatar>
  14. <view class="colorf ml10 mr6">
  15. <view>{{liveItem.liveName?truncateString(liveItem.liveName,8):"未命名"}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="u-flex-end align-center" @click="toggleViewerList" style="margin-top: 120rpx;">
  20. <image v-if="Array.isArray(filteredViewers)" class="w52 h52 mr4"
  21. v-for="(item,viewerIndex) in filteredViewers" :key="viewerIndex"
  22. style="border-radius: 26rpx;" :src="item.avatar||$img.logo">
  23. </image>
  24. <view class="sum">{{liveUserTotal||0}}</view>
  25. </view>
  26. </view>
  27. <!-- 右边的 -->
  28. <view :class=" liveItem.showType==1 ? 'siderow-group' : 'side-group'">
  29. <view class="side-item">
  30. <image class="image" @click="onLike(liveItem)" src="/static/images/like.png">
  31. </image>
  32. <view>{{liveItem.liveViewData?.like||0}}</view>
  33. </view>
  34. <!-- -->
  35. <view class="side-item">
  36. <button open-type="share" class="button">
  37. <image class="image" src="/static/images/share.png" mode="widthFix"></image>
  38. </button>
  39. <view>分享</view>
  40. </view>
  41. </view>
  42. <!-- <view class="hongbao-box" v-if="redInfo?.redStatus==1&&isShowRed">
  43. <view class="u-flex-y-center">
  44. <view class="tip">领红包</view>
  45. <view class="item">
  46. <image @click="onRed()" src="/static/images/redbag.png" mode="widthFix">
  47. </image>
  48. </view>
  49. </view>
  50. </view> -->
  51. <view class="activity-box">
  52. <!-- v-if="redInfo?.redStatus==1&&isShowRed" -->
  53. <view class="item-box" @click="onRed()" v-if="isShowRed">
  54. <view class="u-flex-y-center">
  55. <view class="tip">领红包</view>
  56. <view class="item">
  57. <image class="w70" src="/static/images/redbag.png" mode="widthFix">
  58. </image>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="item-box" @click="onLottery()" v-if="isShowLottery">
  63. <view class="u-flex-y-center">
  64. <view class="tip">抽奖</view>
  65. <view class="item">
  66. <image class="w60" src="/static/images/lottery.png" mode="widthFix">
  67. </image>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="shop-prompt f30 u-flex-y-center" v-if="showPurchasePrompt&&orderUser?.count">
  73. <image class="w32 h32 mr8" src="/static/images/live/shopping.png"></image>
  74. <text> {{orderUser.userName ? maskString(orderUser.userName) : ''}} 等
  75. {{orderUser.count || 0}}
  76. 人正在去购买</text>
  77. </view>
  78. <view class="videolist" style="margin: auto 0">
  79. <view class="video" style="height:100vh">
  80. <!-- 视频组件 -->
  81. <live-player v-if=" liveItem.livingUrl && liveItem.liveType === 1"
  82. :id="'myLivePlayer_' + liveId" :class="liveItem.showType == 1 ? 'video_row' : 'videotop'"
  83. :src="liveItem.livingUrl" autoplay mode="live" object-fit="contain" :waiting="false"
  84. :muted="false" :orientation="liveItem.showType == 1 ? 'horizontal' : 'vertical'"
  85. @statechange="onLiveStateChange($event, liveItem)" @error="onLiveError($event, liveItem)"
  86. class="live-player"></live-player>
  87. <!-- <video v-if="currentSwiperIndex === index && liveItem.livingUrl"
  88. :id="'myVideo_' + liveItem.liveId"
  89. :class="liveItem.showType == 1 ? 'video_row' : 'videotop'" :src="liveItem.livingUrl"
  90. :controls='false' object-fit='contain' :custom-cache="false"
  91. :enable-progress-gesture="false" vslide-gesture-in-fullscreen='true'
  92. :show-center-play-btn="false" :http-cache="false" @error="videoError">
  93. </video> -->
  94. <!-- <video v-if=" liveItem.videoUrl" :class="liveItem.showType == 1 ? 'video_row' : 'videotop'"
  95. :src="liveItem.videoUrl" :autoplay="true" :controls='false' object-fit='contain'
  96. :custom-cache="false" :enable-progress-gesture="false" vslide-gesture-in-fullscreen='true'
  97. :show-center-play-btn="false" :http-cache="false" loop @error="videoError">
  98. </video> -->
  99. <video v-if="liveItem.videoUrl" :id="`myVideo_${liveId}`"
  100. :class="liveItem.showType == 1 ? 'video_row' : 'videotop'" :src="liveItem.videoUrl"
  101. :autoplay="true" :controls="false" object-fit="contain" :custom-cache="false"
  102. :enable-progress-gesture="false" vslide-gesture-in-fullscreen="true"
  103. :show-center-play-btn="false" :http-cache="false" loop @error="videoError"
  104. @timeupdate="onVideoTimeUpdate" @loadeddata="onVideoLoaded"
  105. @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay">
  106. </video>
  107. <view v-if="liveItem.videoUrl" class="time">{{liveItem.totalTime}}</view>
  108. </view>
  109. </view>
  110. <!-- 底部聊天区域 -->
  111. <view class="pb40 mt90 " style="position: fixed;bottom: 120rpx;width: 100%;">
  112. <view class="w100 h500 mt20">
  113. <scroll-view enable-flex scroll-y="true" class="talk p20 scrolly flex-1 column"
  114. style="width: calc(100% - 40rpx);height: calc(100% - 40rpx);"
  115. :scroll-into-view="scrollIntoView">
  116. <view>
  117. <view class="list justify-start" v-for="(item,talkIndex) in talklist" :key="talkIndex"
  118. v-show="item.cmd=='announcement'">
  119. <view class="talk-list ml16 justify-start">
  120. <view class="fs30">
  121. <text class='colorf'>
  122. {{item.msg}}直播间{{liveItem.messageContent}}</text>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <view class="list justify-start" v-for="(item,talkIndex) in talklist" :key="talkIndex"
  128. :id="`list_${talkIndex}`" v-show="item.cmd!='red'&&item.cmd!='out'&&item.cmd!='entry'">
  129. <view class="talk-list ml16 justify-start">
  130. <view class="fs30">
  131. <text style="color: #FFDA73;">{{item.nickName}}:</text>
  132. <text class='colorf'>{{item.msg}}</text>
  133. </view>
  134. </view>
  135. </view>
  136. <view v-if="showWelcomeMessage" class="welcome-message">
  137. <view class="list justify-start" v-for="(item,talkIndex) in talklist" :key="talkIndex"
  138. v-show="item.cmd=='entry'||item.cmd=='out'">
  139. <view class="talk-list ml16 justify-start">
  140. <view class="fs30">
  141. <text style="color: #ff89d6;">{{item.nickName}} </text>
  142. <text class='colorf'>
  143. {{item.msg}}直播间{{liveItem.messageContent}}</text>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. </scroll-view>
  149. </view>
  150. <!-- 底部输入框和操作按钮 -->
  151. <view class="justify-between p24 input-box">
  152. <view class="u-flex-y-center w580"
  153. style="background:rgba(57, 57, 57, 1);padding:10rpx 14rpx 10rpx 32rpx;box-sizing:border-box;border-radius:36rpx;">
  154. <u-input :placeholder="placeholderText" border="none" customStyle='font-size:24rpx;'
  155. v-model="value" shape='circle' color='#fff' placeholderStyle='color:#e7e7e7'
  156. class="ml20" @focus="inputFocus" @blur="inputBlur">
  157. </u-input>
  158. <view class="send" @click="sendMsg()">发送</view>
  159. </view>
  160. <view class="justify-between mr15 align-center">
  161. <view class="icon-bg ml20" @click="openCart()">
  162. <image src="/static/images/shopping.png" class="w58 h58"></image>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. <u-popup :show="isShowGoods" @close="!isShowGoods" round='20rpx' mode="center" zIndex='10099'
  169. bgColor='#ffffff'>
  170. <view class="goods">
  171. <view class="top">
  172. <view class="left">
  173. <image class="w30 h30 mr8" src="/static/images/signal.png"></image>讲解中
  174. </view>
  175. <image class="w44 h44 mr10" src="/static/images/close.png" @click="isShowGoods=false">
  176. </image>
  177. </view>
  178. <image class="photo" :src="goodsCard?.imgUrl"></image>
  179. <view class="item">
  180. <view class="price"><text class="red">¥{{goodsCard?.price}} </text><text
  181. class="del">¥{{goodsCard?.otPrice}}</text></view>
  182. <view class="title oneline-hide">{{goodsCard?.productName}}</view>
  183. <view class="button" @click="goShop(goodsCard?.productId,goodsCard?.goodsId)">
  184. 立即抢购
  185. </view>
  186. </view>
  187. </view>
  188. </u-popup>
  189. <u-popup :show="isShowLotteryPop" @close="!isShowLotteryPop" round='40rpx'>
  190. <view class="prize-box" style="border-radius: 40rpx;height: fit-content;">
  191. <image class="nav-img " src="/static/images/red_head.png" mode="widthFix"></image>
  192. <image class="bg-img " src="/static/images/red_bg.png"></image>
  193. <view class="prize-content">
  194. <view class="u-flex-row-reverse u-flex mr20">
  195. <u-icon name="close" color="#fff" size="20" @click="isShowLotteryPop=false"></u-icon>
  196. </view>
  197. <view class="column align-center ">
  198. <image class="w446 h80" src="/static/images/red_title.png"></image>
  199. <view class="fs24 colorf u-flex-y-center mt30 mb30">
  200. 52人已参与,开奖倒计时
  201. <!-- <view class="white-item">{{lotteryTime.hours}}</view>:
  202. <view class="white-item">{{lotteryTime.minutes}}</view>:
  203. <view class="white-item">{{lotteryTime.seconds}}</view> -->
  204. <u-count-down :time="lotteryTime||0" format="DD:HH:mm:ss" autoStart millisecond
  205. @change="onChange">
  206. <view class="u-flex-y-center">
  207. <view class="white-item">
  208. {{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}
  209. </view>
  210. <view class="white-item">{{ timeData.minutes }}</view>
  211. <view class="white-item">{{ timeData.seconds }}</view>
  212. </view>
  213. </u-count-down>
  214. </view>
  215. <!-- <view class="item-group">
  216. <three-d-swiper :items="swiperItems" :swiperHeight="348" :autoPlay="4000"
  217. :indicatorTop="20"></three-d-swiper>
  218. </view> -->
  219. <view class="item-group">
  220. <ThreeItemSwiper :products="lotteryProducts"></ThreeItemSwiper>
  221. </view>
  222. <!-- <view class="item-group">
  223. <view class="item" v-for="(item,index) in lotteryProducts" :key="index">
  224. <image class="w280 h280" :src="item.imgUrl"></image>
  225. <view v-show="true" class="title">{{item.prizeLevel}}等奖</view>
  226. <view v-show="true" class="txt">{{item.productName}}</view>
  227. </view>
  228. <view class="item center">
  229. <image class="w280 h280" src="/static/images/img.png"></image>
  230. <view v-show="true" class="title">二等奖</view>
  231. <view v-show="true" class="txt">新用户免费领礼品弹窗</view>
  232. </view>
  233. <view class="item">
  234. <image class="w280 h280" src="/static/images/img.png"></image>
  235. <view v-show="false" class="title">二等奖</view>
  236. <view v-show="false" class="txt">新用户免费领礼品弹窗</view>
  237. </view>
  238. </view> -->
  239. <view class="point-group" v-for="(item,index) in lotteryProducts" :key="index">
  240. <!-- <view class="item" v-if="item.length"
  241. :class="{ selected: activePointIndex === 0 }" @click="activePointIndex = 0">
  242. </view> -->
  243. <!-- <view class="item" :class="{ selected: activePointIndex === 1 }"
  244. @click="() => { activePointIndex = 1; scrollToCenterItem() }"></view>
  245. <view class="item" :class="{ selected: activePointIndex === 2 }"
  246. @click="activePointIndex = 2"></view> -->
  247. </view>
  248. <view class="colorf fs28">
  249. 观看直播参与抽奖
  250. </view>
  251. <view class="button" @click="onClaim">参与抽奖</view>
  252. </view>
  253. </view>
  254. </view>
  255. </u-popup>
  256. <u-popup :show="integral?.status" @close="!integral?.status" round='20rpx' mode="center" bgColor='#ffffff'
  257. zIndex='10076'>
  258. <view class="integral-box">
  259. <view class="top">
  260. <view class="title">观看视频领芳华币</view>
  261. <image class="photo" src="/static/images/integral.png" mode="widthFix"></image>
  262. </view>
  263. <view class="item">
  264. <view class="title ">{{integral?.msg}}</view>
  265. <view class="button" @click="integral.status=flase">确认</view>
  266. </view>
  267. </view>
  268. </u-popup>
  269. <u-popup :show="isShowRedCard" @close="!isShowRedCard" round='20rpx' mode="center" bgColor='transparent'
  270. zIndex='10076'>
  271. <view class="red-card">
  272. <image src="/static/images/red_card.png"></image>
  273. <view class="red-content">
  274. <view class="title">{{redCard?.msg}}</view>
  275. <view class="txt ">直播惊喜芳华币</view>
  276. <view class="button" @click="isShowRedCard=flase">确认</view>
  277. </view>
  278. </view>
  279. </u-popup>
  280. <u-popup :show="isShowPrize" @close="!isShowPrize" round='20rpx' mode="center" bgColor='#fff' zIndex='10076'>
  281. <view class="prize-card">
  282. <view class="title">位幸运观众</view>
  283. <view class="prize-content" v-for="(item,index) in prizeInfo" :key="index">
  284. <view class="name">{{item.userName}}</view>
  285. <view class="txt ">{{item.prizeLevel}}等奖</view>
  286. </view>
  287. <view class="button" @click="isShowPrize=flase">确认</view>
  288. </view>
  289. </u-popup>
  290. <!-- 观众列表弹窗 -->
  291. <u-popup :show="showadd" @close="close" @open="openViews" round='20rpx' bgColor='#ffffff' zIndex='10077'>
  292. <view class="view-box">
  293. <view class="t-c fs32">在线观众</view>
  294. <scroll-view scroll-y class="scroll-content" :style="{height: scrollHeight + 'px'}"
  295. @scrolltolower="handleScrollToLower">
  296. <view class="fs28 u-flex-y-center mb20 mt20" v-for="(item,index) in liveViewers" :key="index">
  297. <view
  298. :style="{color: index === 0 ? '#FF3B30' : index === 1 ? '#FF9500' : index === 2 ? '#FFCC00' : '#8E8E93',fontWeight: index < 3 ? 'bold' : 'normal',width: '50rpx'}"
  299. class="mr10">{{index+1}}</view>
  300. <u-avatar :src="item.avatar||$img.logo" size="36"></u-avatar>
  301. <text class="ml16 f30">{{item.nickName||"未命名"}}</text>
  302. </view>
  303. <!-- <view class="no-more" v-if="viewNoMoreData && liveViewers.length > 0">
  304. <text>没有更多了</text>
  305. </view> -->
  306. </scroll-view>
  307. </view>
  308. </u-popup>
  309. <!-- 商品弹窗 -->
  310. <u-popup :show="shopping" @close="closeShop" @open="openShop" round='20rpx' bgColor='f3f5f9' zIndex='10070'>
  311. <view class="shoppop">
  312. <view class="shoppop-top">
  313. <!-- <u-avatar :src="store.logoUrl" size="36" class="ml16"></u-avatar> -->
  314. <view class="search-input u-flex-y-center">
  315. <image class="w24 mr16" src="/static/images/search.png" mode="widthFix">
  316. </image>
  317. <input placeholder="请搜索商品" v-model="inputInfo" @input="handleSearchInput" />
  318. </view>
  319. <view class="t-c search-top" @click="goOrderList(liveItem)">
  320. <image class="w48 h48" src="/static/images/order.png"></image>
  321. <view>订单</view>
  322. </view>
  323. </view>
  324. <scroll-view enable-flex scroll-y class="shop-list" :style="{ height: boxHeight + 'px' }">
  325. <view class="list-item" v-for="(item,index) in products" :key="index">
  326. <view class="goods-img">
  327. <image :src="item.imgUrl" mode="widthFix"></image>
  328. <view class="goods-label">{{index+1}}</view>
  329. </view>
  330. <view class="goods-right">
  331. <view class="goods-title">{{item.productName}}</view>
  332. <view class="goods-people">{{item.sales}} 人已购</view>
  333. <view class="goods-shop">
  334. <text class="nummber"><text style="font-size: 20rpx;font-weight: 600;">¥</text><text
  335. style="font-size: 36rpx;font-weight: bold;">{{Math.trunc(item.price)}}</text>.{{getPureDecimal(item.price)?getPureDecimal(item.price):'00'}}/日</text>
  336. <view class="btn-group u-flex-y-center">
  337. <view class="collect-btn">
  338. <image v-if="item.isFavorite" @click="onGoodsCollect(item)" class="w36 h36"
  339. src="/static/images/collect_select.png">
  340. </image>
  341. <image v-else @click="onGoodsCollect(item)" class="w36 h36"
  342. src="/static/images/collect.png">
  343. </image>
  344. </view>
  345. <view v-if="item.status==1" class="shop-btn"
  346. @click="goShop(item.productId,item.goodsId)">去购买 </view>
  347. <view v-else-if="item.status==0" class="shop-btn">
  348. 已下架</view>
  349. </view>
  350. </view>
  351. </view>
  352. </view>
  353. </scroll-view>
  354. </view>
  355. </u-popup>
  356. </view>
  357. </view>
  358. </template>
  359. <script>
  360. import ThreeItemSwiper from '@/components/ThreeItemSwiper.vue'
  361. import Hls from 'hls.js';
  362. import CryptoJS from 'crypto-js'
  363. import {
  364. liveLottery, // 抽奖查询
  365. claim, //抽奖
  366. liveRed, // 点击领红包
  367. liveDataLike, // 点赞
  368. collectStore, // 店铺收藏/取消收藏
  369. collectGoods, // 商品收藏/取消收藏
  370. // store, // 查询店铺
  371. // follow, // 关注/取消关注
  372. watchUserList, //获取直播间用户(展示在线用户)
  373. liveMsg, //获取最近聊天记录
  374. // 小黄车
  375. liveStore, //店铺展示,
  376. liveOrderUser, //正在购买
  377. getLiveInfo, //获取直播间信息接口
  378. getLiveViewData, //直播间点赞、关注、在线人数数据
  379. currentActivities //红包 卡片 抽奖
  380. } from '@/api/live'
  381. import {
  382. liveOrderList, // 订单列表
  383. } from '@/api/order'
  384. import parse from '/uni_modules/uview-plus/libs/config/props/parse';
  385. import {
  386. LiveWS
  387. } from '@/utils/liveWS.js'
  388. import {
  389. getlive,
  390. } from '@/api/home'
  391. // var wsUrl = "wss://live.test.ylrztop.com/ws/live-api/app/webSocket"; //余红奇
  392. var wsUrl = "ws://192.168.10.166:7114/app/webSocket"; //余红奇
  393. var pingpangTimes = null;
  394. var initTimes = null;
  395. var isSocketOpen = false;
  396. var socket = null;
  397. export default {
  398. components: {
  399. ThreeItemSwiper
  400. },
  401. data() {
  402. return {
  403. videoCurrentTime: 0, // 当前视频播放时间
  404. isVideoPlaying: false, // 视频是否正在播放
  405. videoProgressKey: '', // 存储进度的key
  406. isShowPrize: false,
  407. prizeInfo: [],
  408. timeData: {},
  409. lotteryTime: 0,
  410. lotteryProducts: [],
  411. lotteryList: [],
  412. talklist: {},
  413. isShowLotteryPop: false,
  414. liveItem: {},
  415. isSending: false,
  416. welcomeTimer: null,
  417. redTimer: null,
  418. lotteryTimer: null,
  419. isShowLottery: false,
  420. isShowRedCard: false,
  421. redCard: null, //点击红包出现弹窗
  422. integral: {},
  423. lotteryInfo: {},
  424. goodsCard: {},
  425. redInfo: {},
  426. storeId: null,
  427. isFocus: false,
  428. shopping: false,
  429. inputInfo: '',
  430. showWelcomeMessage: false,
  431. scrollIntoView: '',
  432. isShowGoods: false,
  433. isShowRed: false,
  434. lastClickTime: 0,
  435. clickDelay: 300, // 300ms内只响应一次点击
  436. videoRetryCounts: {}, // 记录每个直播间的视频重试次数,格式: { liveId: 次数 }
  437. placeholderText: '说点什么...',
  438. liveUserTotal: null,
  439. viewPageSize: 10, // 每页数量
  440. viewPageNum: 1, // 当前页码
  441. viewLoading: false, // 是否正在加载
  442. viewNoMoreData: false, // 是否没有更多数据
  443. scrollHeight: 0,
  444. scrollTimer: null, // 滚动防抖定时器
  445. socketInstance: null, // 统一管理 socket 实例
  446. reconnectCount: 0,
  447. maxReconnectAttempts: 3,
  448. isManualClose: false, // 标记是否手动关闭
  449. showRed: true,
  450. searchTimer: null,
  451. reconnectTimer: null,
  452. isCollect: false,
  453. showPurchasePrompt: false,
  454. purchasePromptTimer: null,
  455. prevOrderCount: 0, // 用于记录上一次的购买人数
  456. videoUrl: null,
  457. showType: 1, //横屏1 竖屏2
  458. boxHeight: 300, //小黄车高度
  459. liveViewers: [], //观众
  460. likeName: 0,
  461. hlsPlayer: null, // HLS播放器实例,
  462. livingUrl: "",
  463. products: {},
  464. store: {},
  465. orderUser: {}, //正在购买
  466. userType: 0,
  467. timestamp: '',
  468. liveId: null,
  469. userinfo: '', //用户信息
  470. // path: 'http://192.168.10.166/dev-api', //余红奇
  471. // path: 'http://v56c9b8e.natappfree.cc', //余红奇
  472. // path: 'live.test.ylrztop.com/prod-api', //余红奇
  473. value: '',
  474. talkdisabled: false, //输入框是否禁用
  475. autoplay: false, //视频自动播放
  476. showadd: false,
  477. videoContext: '',
  478. livedata: {}, //直播间点赞、关注、在线人数数据
  479. };
  480. },
  481. onLoad(options) {
  482. this.initTime();
  483. console.log(options)
  484. if (options.liveId) {
  485. this.liveId = options.liveId; // 仅当 liveId 变化时更新
  486. }
  487. this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
  488. if (this.liveId == null) {
  489. uni.showToast({
  490. title: "未知错误,请联系管理员!",
  491. icon: 'none'
  492. });
  493. return;
  494. }
  495. console.log(this.liveId)
  496. // 初始化直播间列表
  497. this.getliving(this.liveId);
  498. this.initSocket();
  499. // this.getliveUser(false); // 调用获取在线用户接口
  500. const platform = uni.getWindowInfo().platform;
  501. // 初始化直播间列表
  502. if (['mp-weixin', 'mp-alipay', 'mp-baidu', 'mp-toutiao'].includes(platform)) {
  503. // 确保 API 存在再调用
  504. if (uni.showShareMenu) {
  505. uni.showShareMenu({
  506. withShareTicket: true, // 可选参数,根据需求配置
  507. success: () => {
  508. console.log('分享菜单显示成功');
  509. },
  510. fail: (err) => {
  511. console.error('分享菜单显示失败:', err);
  512. }
  513. });
  514. } else {
  515. console.warn('当前平台不支持 uni.showShareMenu');
  516. }
  517. }
  518. },
  519. onReady() {},
  520. onShareAppMessage() {
  521. return {
  522. title: this.livedata.liveName,
  523. path: '/pages/home/living',
  524. imageUrl: this.products.image,
  525. success(res) {
  526. console.log("分享成功", res);
  527. },
  528. fail(err) {
  529. console.error("分享失败", err);
  530. }
  531. };
  532. },
  533. computed: {
  534. filteredViewers() {
  535. // 若 liveViewers 是 null/undefined/非数组,返回空数组
  536. if (!Array.isArray(this.liveViewers)) {
  537. return [];
  538. }
  539. return this.liveViewers.slice(0, 3);
  540. },
  541. // payLimitTime() {
  542. // return this.order?.updateTime ?
  543. // dayjs(this.order.updateTime).add(2, 'day').format('YYYY-MM-DD HH:mm:ss') :
  544. // '';
  545. // }
  546. },
  547. onHide() {
  548. // 页面隐藏时保存视频进度
  549. this.saveVideoProgress();
  550. const currentLive = this.liveItem;
  551. if (currentLive) {
  552. this.pauseVideo(currentLive);
  553. this.clearTimeTimer(currentLive); // 隐藏时清除当前直播间定时器
  554. } // 隐藏时关闭所有连接
  555. this.closeAllWebSockets();
  556. if (this.lotteryList) {
  557. this.clearTimeTimer(this.lotteryList)
  558. }
  559. },
  560. mounted() {
  561. this.getCurrentActivities();
  562. },
  563. onUnload() {
  564. // 页面卸载时保存视频进度
  565. this.saveVideoProgress();
  566. // 清除定时器
  567. if (this.redTimer) {
  568. clearInterval(this.redTimer);
  569. this.redTimer = null;
  570. }
  571. if (this.lotteryTimer) {
  572. clearInterval(this.lotteryTimer);
  573. this.lotteryTimer = null;
  574. }
  575. if (this.welcomeTimer) {
  576. clearInterval(this.welcomeTimer);
  577. this.welcomeTimer = null;
  578. }
  579. // 关闭所有WebSocket连接
  580. // this.closeAllWebSockets();
  581. this.closeWebSocket();
  582. // this.socketInstances = {}; // 强制清空实例对象
  583. // 移除所有全局事件监听
  584. this.removeAllEventListeners();
  585. // 清理定时器
  586. this.clearAllTimers();
  587. // 销毁HLS播放器(如果使用了hls.js)
  588. if (this.hlsPlayer) {
  589. this.hlsPlayer.destroy();
  590. this.hlsPlayer = null;
  591. }
  592. // 移除所有全局事件监听
  593. this.removeAllEventListeners();
  594. // 清理定时器
  595. this.clearAllTimers();
  596. // 销毁HLS播放器(如果使用了hls.js)
  597. if (this.hlsPlayer) {
  598. this.hlsPlayer.destroy();
  599. this.hlsPlayer = null;
  600. }
  601. // 暂停视频
  602. const videoId = `myVideo_${this.liveId}`;
  603. const videoContext = uni.createVideoContext(videoId, this);
  604. if (videoContext) {
  605. videoContext.pause();
  606. }
  607. },
  608. watch: {
  609. // 监听orderUser.count的变化
  610. 'orderUser.count': {
  611. handler(newVal, oldVal) {
  612. if (newVal !== this.prevOrderCount) {
  613. this.prevOrderCount = newVal;
  614. this.showPurchaseMessage();
  615. }
  616. },
  617. immediate: true
  618. }
  619. },
  620. methods: {
  621. onVideoMetaLoaded(e) {
  622. console.log('视频元数据加载完成');
  623. // 设置存储key
  624. this.videoProgressKey = `videoProgress_${this.liveId}`;
  625. // 尝试从存储中获取保存的播放进度
  626. uni.getStorage({
  627. key: this.videoProgressKey,
  628. success: (res) => {
  629. console.log('获取到保存的播放进度:', res.data);
  630. this.videoCurrentTime = res.data;
  631. // 设置视频播放位置
  632. this.setVideoCurrentTime(this.videoCurrentTime);
  633. },
  634. fail: (err) => {
  635. console.log('没有找到保存的播放进度或获取失败', err);
  636. this.videoCurrentTime = 0;
  637. }
  638. });
  639. },
  640. // 视频数据加载完成
  641. onVideoLoaded(e) {
  642. console.log('视频数据加载完成');
  643. },
  644. // 视频时间更新
  645. onVideoTimeUpdate(e) {
  646. // 获取当前播放时间
  647. this.videoCurrentTime = e.detail.currentTime;
  648. // 每隔5秒保存一次进度(避免频繁存储)
  649. if (Math.floor(this.videoCurrentTime) % 5 === 0) {
  650. this.saveVideoProgress();
  651. }
  652. },
  653. // 视频暂停
  654. onVideoPause(e) {
  655. this.isVideoPlaying = false;
  656. // 暂停时保存进度
  657. this.saveVideoProgress();
  658. },
  659. // 视频播放
  660. onVideoPlay(e) {
  661. this.isVideoPlaying = true;
  662. },
  663. // 设置视频当前时间
  664. setVideoCurrentTime(time) {
  665. const videoId = `myVideo_${this.liveId}`;
  666. const videoContext = uni.createVideoContext(videoId, this);
  667. if (videoContext) {
  668. videoContext.seek(time);
  669. console.log(`设置视频播放位置: ${time}秒`);
  670. }
  671. },
  672. // 保存视频进度
  673. saveVideoProgress() {
  674. if (this.videoProgressKey) {
  675. uni.setStorage({
  676. key: this.videoProgressKey,
  677. data: this.videoCurrentTime,
  678. success: () => {},
  679. fail: (err) => {
  680. console.error('保存视频进度失败:', err);
  681. }
  682. });
  683. }
  684. },
  685. onChange(e) {
  686. this.timeData = e
  687. },
  688. // 参与抽奖
  689. onClaim() {
  690. let data = {
  691. liveId: this.liveId,
  692. // integral: this.integral,
  693. lotteryId: this.lotteryInfo.lotteryId,
  694. // userId: this.userinfo.userId
  695. }
  696. claim(data).then(res => {
  697. if (res.code == 200) {
  698. uni.showToast({
  699. title: res.msg,
  700. icon: 'none'
  701. });
  702. this.isShowLotteryPop = false
  703. } else {
  704. uni.showToast({
  705. title: res.msg,
  706. icon: 'none'
  707. });
  708. }
  709. },
  710. rej => {}
  711. );
  712. },
  713. // 点击抽奖图标
  714. onLottery() {
  715. if (this.lotteryTimer) {
  716. clearInterval(this.lotteryTimer);
  717. this.lotteryTimer = null;
  718. }
  719. if (!this.lotteryInfo) return;
  720. let data = {
  721. lotteryId: this.lotteryInfo.lotteryId
  722. }
  723. // 抽奖查询
  724. liveLottery(data).then(res => {
  725. this.isShowLottery = false
  726. this.isShowLotteryPop = true
  727. if (res.code == 200) {
  728. this.lotteryList = res.data
  729. this.lotteryProducts = res.data.products
  730. // this.startTimeTimer(this.lotteryList, "lottery");
  731. } else {
  732. uni.showToast({
  733. title: res.msg,
  734. icon: 'none'
  735. });
  736. }
  737. },
  738. rej => {}
  739. );
  740. },
  741. // 商品收藏
  742. onGoodsCollect(item) {
  743. console.log("商品收藏", item)
  744. if (!item || item.length === 0 || !item.goodsId) {
  745. return;
  746. }
  747. collectGoods(item.goodsId).then(res => {
  748. if (res.code == 200) {
  749. uni.showToast({
  750. title: res.msg,
  751. icon: 'none'
  752. });
  753. item.isFavorite = !item.isFavorite
  754. } else {
  755. uni.showToast({
  756. title: res.msg,
  757. icon: 'none'
  758. });
  759. }
  760. },
  761. rej => {}
  762. );
  763. },
  764. inputFocus() {
  765. this.isFocus = true
  766. },
  767. inputBlur() {
  768. this.isFocus = false
  769. },
  770. //正在购买
  771. async getliveOrder() {
  772. try {
  773. const res = await liveOrderUser(this.liveId);
  774. if (res.code === 200) {
  775. this.orderUser = res; // 同步全局变量
  776. }
  777. } catch (error) {
  778. console.error('获取正在购买用户失败:', error);
  779. }
  780. },
  781. openShop() {
  782. this.shopping = true
  783. },
  784. onLiveStateChange(e, liveItem) {
  785. // console.log('直播状态变化:', e.detail.code, e.detail);
  786. // 可以根据状态码处理不同的直播状态
  787. const stateCode = e.detail.code;
  788. // 2001: 已经连接服务器
  789. // 2002: 已经连接服务器,开始拉流
  790. // 2003: 网络接收到首个视频数据包(IDR)
  791. // 2004: 视频播放开始
  792. // 2005: 视频播放进度
  793. // 2006: 视频播放结束
  794. // 2007: 视频播放Loading
  795. // 2008: 解码器启动
  796. // -2301: 网络断连,且经多次重连抢救无效,更多重试请自行重启播放
  797. // -2302: 获取加速拉流地址失败
  798. }, // 直播错误事件
  799. onLiveError(e, liveItem) {
  800. this.videoError(e, liveItem);
  801. },
  802. // 红包 卡片 抽奖
  803. getCurrentActivities() {
  804. if (!this.liveId) return;
  805. currentActivities(this.liveId).then(res => {
  806. if (res.code == 200) {
  807. // 商品卡片
  808. // 红包
  809. if (res.red) {
  810. this.redInfo = res.red[0];
  811. }
  812. if (res.lottery) {
  813. this.lotteryInfo = res.lottery[0];
  814. }
  815. this.goodsCard = res.goods;
  816. // 抽奖
  817. this.lotteryTime = this.lotteryInfo?.duration * 60 * 1000
  818. console.log("毫秒", this.lotteryTime)
  819. if (this.goodsCard && this.goodsCard.status == 1) {
  820. this.isShowGoods = true
  821. } else {
  822. this.isShowGoods = false
  823. }
  824. if (this.redInfo && this.redInfo.redStatus == 1) {
  825. this.isShowRed = true
  826. } else {
  827. this.isShowRed = false
  828. }
  829. if (this.lotteryInfo && this.lotteryInfo.lotteryStatus == 1) {
  830. this.isShowLottery = true
  831. } else {
  832. this.isShowLottery = false
  833. }
  834. } else {
  835. uni.showToast({
  836. title: res.msg,
  837. icon: 'none'
  838. });
  839. }
  840. },
  841. rej => {}
  842. );
  843. },
  844. // 计算当前时间与 liveItem.startTime 的差值,并更新 totalTime
  845. calculateTimeDiff(item, type = "") {
  846. // 防御1:item 不存在直接返回
  847. if (!item) return;
  848. // 步骤1:提取对应场景的时间字符串(直播用startTime,抽奖用updateTime)
  849. let timeStr = "";
  850. if (type === "lottery") {
  851. timeStr = item || ""; // 抽奖场景:从item取updateTime
  852. } else {
  853. timeStr = item || ""; // 直播场景:从item取startTime
  854. }
  855. // 防御2:时间字符串为空,兜底显示
  856. if (!timeStr) {
  857. if (type === "lottery") {
  858. // this.lotteryTime = {
  859. // hours: "00",
  860. // minutes: "00",
  861. // seconds: "00"
  862. // };
  863. } else {
  864. this.$set(this.liveItem, "totalTime", "00:00:00");
  865. }
  866. return;
  867. }
  868. // 步骤2:转换时间格式(适配iOS,将 "-" 替换为 "/")
  869. const iosCompatibleTime = timeStr.replace(/-/g, "/");
  870. const time = new Date(iosCompatibleTime);
  871. // 防御3:时间解析失败(Invalid Date),兜底显示
  872. if (isNaN(time.getTime())) {
  873. if (type === "lottery") {
  874. this.lotteryTime = {
  875. hours: "00",
  876. minutes: "00",
  877. seconds: "00"
  878. };
  879. } else {
  880. this.$set(this.liveItem, "totalTime", "00:00:00");
  881. }
  882. console.warn("时间解析失败,原始格式:", timeStr);
  883. return;
  884. }
  885. // 步骤3:计算时间差(抽奖是「结束时间-当前时间」,直播是「当前时间-开始时间」)
  886. const now = new Date();
  887. let diffMs = 0;
  888. if (type === "lottery") {
  889. diffMs = Math.max(0, time - now); // 抽奖:倒计时(结束时间-现在)
  890. } else {
  891. diffMs = Math.max(0, now - time); // 直播:已播放时长(现在-开始时间)
  892. }
  893. // 步骤4:转换为 时:分:秒(补零处理)
  894. const totalSeconds = Math.floor(diffMs / 1000);
  895. const hours = this.padZero(Math.floor(totalSeconds / 3600));
  896. const minutes = this.padZero(Math.floor((totalSeconds % 3600) / 60));
  897. const seconds = this.padZero(totalSeconds % 60);
  898. // 步骤5:更新对应数据(响应式)
  899. if (type === "lottery") {
  900. // this.lotteryTime = {
  901. // hours,
  902. // minutes,
  903. // seconds
  904. // };
  905. } else {
  906. this.$set(this.liveItem, "totalTime", `${hours}:${minutes}:${seconds}`);
  907. }
  908. },
  909. padZero(num) {
  910. return num < 10 ? `0${num}` : num;
  911. },
  912. // 启动当前直播间的时间差值定时器
  913. startTimeTimer(item, type = '') {
  914. // 防御:若 item 不存在,直接返回
  915. if (!item) return;
  916. // 立即计算一次(避免等待1秒才显示)
  917. if (type === "lottery") {
  918. this.calculateTimeDiff(item.updateTime, "lottery");
  919. item.timeTimer = setInterval(() => {
  920. this.calculateTimeDiff(item.updateTime, "lottery");
  921. }, 1000);
  922. } else {
  923. this.calculateTimeDiff(item.startTime);
  924. item.timeTimer = setInterval(() => {
  925. this.calculateTimeDiff(item.startTime);
  926. }, 1000);
  927. }
  928. },
  929. // 清除指定直播间的时间定时器
  930. clearTimeTimer(item) {
  931. if (item.timeTimer) {
  932. clearInterval(item.timeTimer);
  933. item.timeTimer = null; // 清空定时器标识
  934. }
  935. },
  936. //抽奖时间
  937. // convertMinutesToHoursMinutes(totalMinutes) {
  938. // const hours = Math.floor(totalMinutes / 60);
  939. // const minutes = totalMinutes % 60;
  940. // const seconds = totalMinutes % 3600;
  941. // this.lotteryTime = {
  942. // hours,
  943. // minutes,
  944. // seconds
  945. // };
  946. // },
  947. toggleViewerList() {
  948. const now = Date.now()
  949. if (now - this.lastClickTime > this.clickDelay) {
  950. this.showadd = !this.showadd
  951. this.lastClickTime = now
  952. }
  953. },
  954. closeAllWebSockets() {
  955. this.isManualClose = true;
  956. // this.socketInstances = {};
  957. isSocketOpen = false;
  958. }, // 移除所有全局事件监听器
  959. removeAllEventListeners() {
  960. uni.$off('initSocket');
  961. uni.$off('sendMsg');
  962. uni.$off('closeWebSocket');
  963. uni.$off('refreshOrder');
  964. // 可以根据实际情况添加其他需要移除的事件
  965. }, // 清理所有定时器
  966. clearAllTimers() {
  967. if (this.intervalId) {
  968. clearInterval(this.intervalId);
  969. this.intervalId = null;
  970. }
  971. if (this.pingpangTimes) {
  972. clearInterval(this.pingpangTimes);
  973. this.pingpangTimes = null;
  974. }
  975. if (this.reconnectTimer) {
  976. clearInterval(this.reconnectTimer);
  977. this.reconnectTimer = null;
  978. }
  979. if (this.scrollTimer) {
  980. clearTimeout(this.scrollTimer);
  981. this.scrollTimer = null;
  982. }
  983. if (this.searchTimer) {
  984. clearTimeout(this.searchTimer);
  985. this.searchTimer = null;
  986. }
  987. if (this.purchasePromptTimer) {
  988. clearTimeout(this.purchasePromptTimer);
  989. this.purchasePromptTimer = null;
  990. }
  991. },
  992. // 播放视频
  993. playVideo(liveItem) {
  994. if (!liveItem) return;
  995. try {
  996. // 直播流使用live-player
  997. if (liveItem.liveType === 1 && liveItem.livingUrl) {
  998. const livePlayerId = `myLivePlayer_${this.liveId}`;
  999. const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
  1000. if (livePlayerContext) {
  1001. livePlayerContext.play();
  1002. }
  1003. }
  1004. // 回放视频使用video
  1005. else if (liveItem.liveType === 2 && liveItem.videoUrl) {
  1006. const videoId = `myVideo_${this.liveId}`;
  1007. const videoContext = uni.createVideoContext(videoId, this);
  1008. if (videoContext) {
  1009. videoContext.pause(() => {
  1010. videoContext.play();
  1011. });
  1012. }
  1013. }
  1014. } catch (error) {
  1015. console.error("播放视频失败:", error);
  1016. }
  1017. },
  1018. pauseVideo(liveItem) {
  1019. if (!liveItem) return;
  1020. try {
  1021. // 直播流使用live-player
  1022. if (liveItem.liveType === 1) {
  1023. const livePlayerId = `myLivePlayer_${this.liveId}`;
  1024. const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
  1025. if (livePlayerContext) {
  1026. livePlayerContext.pause();
  1027. }
  1028. }
  1029. // 回放视频使用video
  1030. else if (liveItem.liveType === 2) {
  1031. const videoId = `myVideo_${this.liveId}`;
  1032. const videoContext = uni.createVideoContext(videoId, this);
  1033. if (videoContext) {
  1034. videoContext.pause();
  1035. }
  1036. }
  1037. } catch (error) {
  1038. console.error("暂停视频失败:", error);
  1039. }
  1040. },
  1041. openViews() {
  1042. // 计算scroll-view高度
  1043. this.$nextTick(() => {
  1044. const query = uni.createSelectorQuery().in(this);
  1045. query.select('.view-box').boundingClientRect(data => {
  1046. if (data) {
  1047. // 减去标题和底部固定区域的高度
  1048. this.scrollHeight = data.height - 80 - 120; // 80是标题高度,120是底部高度
  1049. }
  1050. }).exec();
  1051. });
  1052. },
  1053. // 获取直播间用户
  1054. async getliveUser(isLoadMore = false) {
  1055. // 强制使用当前 liveId,避免使用旧值
  1056. this.viewLoading = true;
  1057. try {
  1058. const res = await watchUserList(this.liveId, this.viewPageSize, this.viewPageNum,
  1059. false);
  1060. if (res.code === 200) {
  1061. // 若请求期间已切换直播间,忽略旧数据
  1062. this.liveUserTotal = res.total;
  1063. if (res.rows.length === 0) {
  1064. this.viewNoMoreData = true;
  1065. return;
  1066. }
  1067. this.liveViewers = isLoadMore ? [...this.liveViewers, ...res.rows] : res
  1068. .rows; // 首次加载/切换直播间时重置数据
  1069. this.viewPageNum++;
  1070. // console.log("在线观众", this.liveViewers)
  1071. }
  1072. } catch (error) {
  1073. console.error('获取观众列表失败:', error);
  1074. } finally {
  1075. this.viewLoading = false;
  1076. }
  1077. },
  1078. // 滚动到底部触发
  1079. handleScrollToLower() {
  1080. // 清除上一次未执行的定时器,避免重复请求
  1081. if (this.scrollTimer) {
  1082. clearTimeout(this.scrollTimer);
  1083. }
  1084. // 延迟0.5秒(500毫秒)执行接口请求
  1085. this.scrollTimer = setTimeout(() => {
  1086. // this.getliveUser(true); // 加载更多数据
  1087. }, 1000); // 延迟时间:500毫秒
  1088. },
  1089. async getLiveMsg(liveItem) {
  1090. // 强化校验:确保 liveItem 存在且包含 liveId
  1091. if (!liveItem || !this.liveId) {
  1092. console.error('getLiveMsg 错误:无效的 liveItem', {
  1093. liveItem: liveItem,
  1094. currentIndex: this.currentSwiperIndex,
  1095. });
  1096. return; // 直接返回,不执行后续逻辑
  1097. }
  1098. try {
  1099. const res = await liveMsg(this.liveId, 30, 1);
  1100. if (res.code == 200) {
  1101. const rows = Array.isArray(res.rows) ? res.rows : [];
  1102. const reversedTalkList = [...rows].reverse();
  1103. this.talklist = reversedTalkList;
  1104. this.$nextTick(() => {
  1105. // 滚动到最新消息(反转后最新消息在数组最后一位,索引为 reversedTalkList.length - 1)
  1106. this.scrollIntoView = `list_${reversedTalkList.length - 1}`;
  1107. });
  1108. }
  1109. } catch (error) {
  1110. console.error("获取聊天记录失败:", error);
  1111. }
  1112. },
  1113. // 点击红包
  1114. onRed() {
  1115. if (!this.liveId) return;
  1116. if (!this.redInfo?.redId) return;
  1117. if (this.redTimer) {
  1118. clearInterval(this.redTimer);
  1119. this.redTimer = null;
  1120. }
  1121. let data = {
  1122. liveId: this.liveId,
  1123. userId: this.userinfo.userId,
  1124. redId: this.redInfo.redId,
  1125. }
  1126. liveRed(data).then(res => {
  1127. this.isShowRed = false
  1128. this.redCard = res
  1129. this.isShowRedCard = true
  1130. },
  1131. rej => {}
  1132. );
  1133. },
  1134. handleSearchInput() {
  1135. // 使用防抖优化性能,避免频繁请求
  1136. clearTimeout(this.searchTimer);
  1137. this.searchTimer = setTimeout(() => {
  1138. this.queryCollect();
  1139. }, 500); // 500毫秒延迟
  1140. },
  1141. // 显示购买提示信息
  1142. showPurchaseMessage() {
  1143. // 清除之前的定时器
  1144. if (this.purchasePromptTimer) {
  1145. clearTimeout(this.purchasePromptTimer);
  1146. }
  1147. // 显示提示
  1148. this.showPurchasePrompt = true;
  1149. // 2秒后自动隐藏
  1150. this.purchasePromptTimer = setTimeout(() => {
  1151. this.showPurchasePrompt = false;
  1152. }, 2000);
  1153. },
  1154. truncateString(str, maxLength) {
  1155. return str.length > maxLength ? str.slice(0, maxLength) + '...' : str;
  1156. },
  1157. // 去订单列表
  1158. goOrderList() {
  1159. uni.navigateTo({
  1160. url: "/pages_shop/order"
  1161. })
  1162. },
  1163. // 初始化HLS播放器
  1164. initHlsPlayer() {
  1165. if (Hls.isSupported() && this.livingUrl) {
  1166. const video = document.getElementById('myVideo');
  1167. if (video) {
  1168. this.hlsPlayer = new Hls();
  1169. this.hlsPlayer.loadSource(this.livingUrl);
  1170. this.hlsPlayer.attachMedia(video);
  1171. this.hlsPlayer.on(Hls.Events.MANIFEST_PARSED, () => {
  1172. video.play();
  1173. });
  1174. }
  1175. }
  1176. },
  1177. // 视频错误处理
  1178. videoError(e, liveItem) {
  1179. if (!liveItem || !this.liveId) return;
  1180. // 初始化重试计数
  1181. if (this.videoRetryCounts[liveItem.liveId] === undefined) {
  1182. this.videoRetryCounts[liveItem.liveId] = 0;
  1183. }
  1184. // 限制重试次数
  1185. if (this.videoRetryCounts[liveItem.liveId] >= 3) {
  1186. console.error(`直播间 ${this.liveId} 视频加载失败,停止重试`);
  1187. // 显示错误提示
  1188. uni.showToast({
  1189. title: "视频加载失败,请检查网络",
  1190. icon: 'none',
  1191. duration: 2000
  1192. });
  1193. return;
  1194. }
  1195. this.videoRetryCounts[this.liveId]++;
  1196. // 延迟重试
  1197. setTimeout(() => {
  1198. if (this.liveId === this.liveId) {
  1199. console.log(`第${this.videoRetryCounts[this.liveId]}次重试播放视频`);
  1200. this.playVideo(liveItem);
  1201. }
  1202. }, 2000);
  1203. },
  1204. // 修改获取直播信息方法
  1205. async getliving(liveId) {
  1206. const param = {
  1207. id: liveId
  1208. };
  1209. try {
  1210. const res = await getlive(param);
  1211. if (res.code !== 200) {
  1212. uni.showToast({
  1213. title: res.msg,
  1214. icon: 'none'
  1215. });
  1216. return;
  1217. }
  1218. this.liveItem = res.data;
  1219. this.talklist = res.data.talklist;
  1220. // 强制更新视频源(覆盖旧值)
  1221. if (res.data.liveType === 2) {
  1222. // 回放视频
  1223. this.$set(this.liveItem, 'videoUrl', res.data.videoUrl);
  1224. this.$set(this.liveItem, 'livingUrl', ''); // 清空直播流
  1225. } else if (res.data.liveType === 1) {
  1226. // 直播流
  1227. this.$set(this.liveItem, 'livingUrl', res.data.flvHlsUrl);
  1228. this.$set(this.liveItem, 'videoUrl', ''); // 清空回放视频
  1229. } else {
  1230. // 未开播
  1231. this.$set(this.liveItem, 'livingUrl', '');
  1232. this.$set(this.liveItem, 'videoUrl', '');
  1233. }
  1234. this.startTimeTimer(this.liveItem);
  1235. await this.getLiveMsg(this.liveItem);
  1236. await this.getliveViewData(this.liveItem);
  1237. this.$set(this.liveItem, 'autoplay', res.data.liveType !== 0);
  1238. this.$set(this.liveItem, 'showType', res.data.showType);
  1239. this.storeId = res.storeId;
  1240. } catch (err) {
  1241. console.error("获取直播信息失败:", err);
  1242. uni.showToast({
  1243. title: "获取直播信息失败",
  1244. icon: 'none'
  1245. });
  1246. }
  1247. }, // 设置视频播放
  1248. maskString(str, maskChar = '*') {
  1249. // 如果str是undefined或null,直接返回空字符串
  1250. if (!str) return '';
  1251. // 确保str是字符串(如果是数字等类型,先转为字符串)
  1252. const strVal = String(str);
  1253. return strVal.split('').map((char, index) => (index === 0 ? char : maskChar)).join(
  1254. '');
  1255. },
  1256. getPureDecimal(num, precision = 6) {
  1257. const decimalPart = Math.abs(num).toFixed(precision).split('.')[1];
  1258. return decimalPart?.replace(/0+$/, '') || ''; // 移除末尾多余的0
  1259. },
  1260. // 返回上一个页面并关闭WebSocket
  1261. goBack() {
  1262. // 暂停当前视频
  1263. const currentLive = this.liveItem;
  1264. if (currentLive) {
  1265. this.pauseVideo(currentLive);
  1266. }
  1267. // 关闭所有WebSocket连接
  1268. this.closeWebSocket();
  1269. // 导航返回
  1270. const pages = getCurrentPages();
  1271. if (pages.length > 1) {
  1272. uni.navigateBack();
  1273. } else {
  1274. uni.reLaunch({
  1275. url: '/pages/list/index'
  1276. });
  1277. }
  1278. },
  1279. // 点赞
  1280. async onLike(liveItem) {
  1281. if (!liveItem || !this.liveId) return;
  1282. try {
  1283. const res = await liveDataLike(this.liveId);
  1284. if (res?.like) {
  1285. liveItem.liveViewData.like++; // 只更新当前直播间的点赞数
  1286. } else {
  1287. uni.showToast({
  1288. title: res.msg,
  1289. icon: 'none'
  1290. });
  1291. }
  1292. } catch (error) {
  1293. console.error('点赞失败:', error);
  1294. }
  1295. },
  1296. //直播间点赞、关注、在线人数数据
  1297. async getliveViewData(liveItem) {
  1298. if (!liveItem || !this.liveId) return;
  1299. try {
  1300. const res = await getLiveViewData(this.liveId);
  1301. if (res.code == 200) {
  1302. // 强制响应式更新,确保数据实时显示
  1303. this.$set(liveItem, 'liveViewData', res);
  1304. }
  1305. } catch (error) {
  1306. console.error("获取直播间数据失败:", error);
  1307. // 失败时兜底,避免显示异常
  1308. this.$set(liveItem, 'liveViewData', {
  1309. like: 0,
  1310. watchCount: 0
  1311. });
  1312. }
  1313. },
  1314. // 去购买,跳商品详情
  1315. goShop(productId, goodsId) {
  1316. // const currentLive = this.liveItem;
  1317. if (!this.liveId) return;
  1318. uni.navigateTo({
  1319. url: '/pages_shop/goods?productId=' + productId + '&liveId=' +
  1320. this
  1321. .liveId +
  1322. '&goodsId=' + goodsId + '&storeId=' + this.storeId
  1323. })
  1324. },
  1325. // 查询店铺
  1326. async queryCollect() {
  1327. if (!this.liveId) return;
  1328. if (this.inputInfo == null) this.inputInfo = ''
  1329. try {
  1330. const res = await liveStore(this.liveId, this.inputInfo);
  1331. if (res.code === 200) {
  1332. // 数据绑定到当前 liveItem,避免全局污染
  1333. this.products = res.data;
  1334. }
  1335. } catch (error) {
  1336. console.error('获取小黄车商品失败:', error);
  1337. }
  1338. },
  1339. // 时间戳
  1340. initTime() {
  1341. const now = new Date();
  1342. this.timestamp = now.getTime(); // 例如:'2023-04-01 12:00:00'
  1343. },
  1344. openCart() {
  1345. this.queryCollect()
  1346. this.shopping = true
  1347. },
  1348. close() {
  1349. this.showadd = false
  1350. },
  1351. // 关闭小黄车
  1352. closeShop() {
  1353. this.shopping = false;
  1354. },
  1355. getEWechatSdk() {
  1356. // 只在H5平台执行
  1357. // #ifdef H5
  1358. let eWechatSdk = '';
  1359. if (/(Android)/i.test(navigator.userAgent)) {
  1360. eWechatSdk = 'jWeixin';
  1361. } else if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  1362. eWechatSdk = 'wx';
  1363. } else {
  1364. eWechatSdk = 'jWeixin';
  1365. }
  1366. uni.setStorageSync("wxSdk", eWechatSdk);
  1367. // #endif
  1368. },
  1369. // 修改关闭WebSocket方法
  1370. closeWebSocket() {
  1371. this.socket?.close();
  1372. },
  1373. initSocket() {
  1374. if (this.liveId == null) return;
  1375. // 设置正在连接的直播间ID
  1376. // this.connectingLiveId = liveId;
  1377. // 生成签名
  1378. const signature = CryptoJS.HmacSHA256(
  1379. `${this.liveId}${this.userinfo.userId}${this.userType}${this.timestamp}`,
  1380. this.timestamp.toString()
  1381. ).toString(CryptoJS.enc.Hex);
  1382. try {
  1383. const socketTask = uni.connectSocket({
  1384. url: `${wsUrl}?userId=${this.userinfo.userId}&liveId=${this.liveId}&userType=${this.userType}&timestamp=${this.timestamp}&signature=${signature}`,
  1385. success: () => {},
  1386. fail: (err) => {}
  1387. });
  1388. socketTask.onOpen((res) => {
  1389. this.socket = socketTask;
  1390. });
  1391. socketTask.onMessage((res) => {
  1392. // 找到对应的直播间并更新数据
  1393. const targetLive = this.liveItem;
  1394. if (targetLive) {
  1395. this.handleSocketMessage(res, targetLive);
  1396. }
  1397. });
  1398. } catch (e) {
  1399. console.error('创建 WebSocket 异常:', e);
  1400. }
  1401. },
  1402. // 处理Socket消息
  1403. handleSocketMessage(message, liveItem) {
  1404. let data = JSON.parse(message.data)
  1405. const socketMessage = data.data // 服务端返回的消息体
  1406. if (data.code == 200) {
  1407. const messageData = {
  1408. ...socketMessage,
  1409. cmd: socketMessage.cmd || '', // 确保cmd字段存在
  1410. ts: Date.now() // 新增时间戳,用于排序(可选)
  1411. };
  1412. // 处理服务端返回的sendMsg消息,加入本地列表
  1413. if (socketMessage.cmd == 'sendMsg') {
  1414. const oldList = this.talklist || [];
  1415. // 创建新数组并添加元素
  1416. const newList = [...oldList, messageData];
  1417. // 1. 将消息追加到当前直播间的talklist中(响应式更新)
  1418. this.talklist = newList;
  1419. // 2. 延迟下一帧滚动到最新消息(确保DOM已更新)
  1420. this.$nextTick(() => {
  1421. const lastIndex = this.talklist.length - 1;
  1422. this.scrollIntoView = `list_${lastIndex}`;
  1423. });
  1424. } else if (socketMessage.cmd == 'red') {
  1425. this.redInfo = JSON.parse(socketMessage.data);
  1426. if (socketMessage.status == 1) {
  1427. this.isShowRed = true
  1428. let time = this.redInfo.duration
  1429. this.redTimer = setInterval(() => {
  1430. this.isShowRed = false
  1431. }, time * 60000)
  1432. } else {
  1433. this.isShowRed = false
  1434. }
  1435. } else if (socketMessage.cmd == 'goods') {
  1436. this.goodsCard = JSON.parse(socketMessage.data);
  1437. if (socketMessage.status == 1) {
  1438. this.isShowGoods = true
  1439. } else {
  1440. this.isShowGoods = false
  1441. }
  1442. } else if (socketMessage.cmd == 'lottery') {
  1443. this.lotteryInfo = JSON.parse(socketMessage.data);
  1444. if (socketMessage.status == 1) {
  1445. this.isShowLottery = true
  1446. let time = this.lotteryInfo.duration
  1447. this.lotteryTimer = setInterval(() => {
  1448. this.isShowLottery = false
  1449. }, time * 60000)
  1450. this.lotteryTime = time * 60 * 1000
  1451. // console.log("毫秒",this.lotteryTime)
  1452. // this.convertMinutesToHoursMinutes(time)
  1453. } else {
  1454. this.isShowLottery = false
  1455. }
  1456. } else if (socketMessage.cmd == 'entry' || socketMessage.cmd ==
  1457. 'out') {
  1458. const oldList = this.talklist || [];
  1459. // 创建新数组并添加元素
  1460. const newList = [...oldList, messageData];
  1461. // 1. 将消息追加到当前直播间的talklist中(响应式更新)
  1462. this.talklist = newList;
  1463. this.showWelcomeMessage = false;
  1464. this.showWelcomeMessage = true;
  1465. this.getliveUser(false);
  1466. if (this.welcomeTimer) clearTimeout(this.welcomeTimer);
  1467. this.welcomeTimer = setTimeout(() => {
  1468. this.showWelcomeMessage = false;
  1469. }, 1000);
  1470. } else if (socketMessage.cmd == 'Integral') {
  1471. this.integral = {
  1472. msg: socketMessage.msg,
  1473. status: true
  1474. }
  1475. } else if (socketMessage.cmd == 'LotteryDetail') {
  1476. this.prizeInfo = JSON.parse(socketMessage.data);
  1477. this.isShowPrize = socketMessage.status === 1;
  1478. } else if (socketMessage.cmd == 'blockUser') {
  1479. uni.removeStorage({
  1480. key: 'AppToken',
  1481. success: () => {
  1482. uni.reLaunch({
  1483. url: '/pages/auth/login'
  1484. });
  1485. }
  1486. });
  1487. }
  1488. } else {
  1489. uni.showToast({
  1490. title: data.msg,
  1491. icon: 'none'
  1492. });
  1493. }
  1494. },
  1495. sendMsg() {
  1496. if (!this.liveId) return;
  1497. // 防止连续点击发送两次(短时锁定)
  1498. if (this.isSending) return;
  1499. this.isSending = true;
  1500. setTimeout(() => {
  1501. this.isSending = false;
  1502. }, 800); // 800ms 内禁止再次发送
  1503. const text = (this.value || '').trim();
  1504. if (!text) {
  1505. uni.showToast({
  1506. title: "不能发送空消息",
  1507. icon: 'none'
  1508. });
  1509. return;
  1510. }
  1511. const liveId = this.liveId;
  1512. const socketItem = this.socket;
  1513. this.value = ''; // 立即清空输入框,提升体验
  1514. // 构造发送给服务端的消息数据
  1515. const data = {
  1516. liveId,
  1517. userId: this.userinfo.userId,
  1518. userType: 0,
  1519. cmd: "sendMsg", // 指令标识,服务端会根据此返回sendMsg消息
  1520. msg: text,
  1521. nickName: this.userinfo.nickName,
  1522. avatar: this.userinfo.avatar
  1523. };
  1524. // 发送socket消息
  1525. try {
  1526. this.socket.send({
  1527. data: JSON.stringify(data),
  1528. success: () => {
  1529. // 发送成功无需额外操作,等待服务端返回消息后再更新列表
  1530. },
  1531. fail: (err) => {
  1532. uni.showToast({
  1533. title: err,
  1534. icon: 'none'
  1535. });
  1536. // 发送失败时可恢复输入框内容
  1537. this.value = text;
  1538. }
  1539. });
  1540. } catch (err) {}
  1541. }
  1542. }
  1543. };
  1544. </script>
  1545. <style scoped lang="scss">
  1546. .live-player {
  1547. width: 100%;
  1548. height: 100%;
  1549. }
  1550. .swiper-wrapper {
  1551. position: relative;
  1552. width: 100%;
  1553. height: 100vh;
  1554. overflow: hidden;
  1555. background-color: #000000;
  1556. }
  1557. .swiper-container {
  1558. width: 100%;
  1559. height: 100vh;
  1560. }
  1561. .container {
  1562. width: 100%;
  1563. height: 100%;
  1564. position: relative;
  1565. transition: opacity 0.3s ease;
  1566. transform: translateZ(0); // 开启GPU加速
  1567. will-change: opacity; // 告诉浏览器提前优化该属性
  1568. }
  1569. .loading-tip {
  1570. position: absolute;
  1571. top: 50%;
  1572. left: 50%;
  1573. transform: translate(-50%, -50%);
  1574. display: flex;
  1575. flex-direction: column;
  1576. align-items: center;
  1577. justify-content: center;
  1578. z-index: 10;
  1579. .loading-text {
  1580. color: #ffffff;
  1581. font-size: 28rpx;
  1582. margin-top: 20rpx;
  1583. }
  1584. }
  1585. .loading-more,
  1586. .no-more {
  1587. display: flex;
  1588. justify-content: center;
  1589. align-items: center;
  1590. padding: 20rpx 0;
  1591. color: #999;
  1592. font-size: 24rpx;
  1593. }
  1594. .loading-more {
  1595. flex-direction: column;
  1596. }
  1597. /* button自带样式清除 */
  1598. .student-orther-icon button::after {
  1599. border: none !important;
  1600. padding: 0 !important;
  1601. margin: 0 !important;
  1602. }
  1603. .student-orther-icon button {
  1604. background-color: transparent !important;
  1605. padding: 0 !important;
  1606. line-height: inherit !important;
  1607. margin: 0 !important;
  1608. width: auto !important;
  1609. font-weight: 500 !important;
  1610. border-radius: none !important;
  1611. }
  1612. .welcome-message {
  1613. position: fixed;
  1614. width: 100%;
  1615. bottom: 700rpx;
  1616. left: 50%;
  1617. transform: translateX(-50%);
  1618. color: white;
  1619. padding: 10px 20px;
  1620. border-radius: 20px;
  1621. z-index: 10;
  1622. transition: opacity 0.3s ease;
  1623. }
  1624. @keyframes fadeOut {
  1625. from {
  1626. opacity: 1;
  1627. }
  1628. to {
  1629. opacity: 0;
  1630. }
  1631. }
  1632. .send {
  1633. background-color: #fafafa;
  1634. border-radius: 28rpx;
  1635. padding: 14rpx 16rpx;
  1636. color: #181818;
  1637. font-weight: 500;
  1638. }
  1639. // .container {
  1640. // position: relative;
  1641. // width: 100%;
  1642. // height: 100vh;
  1643. // overflow: hidden;
  1644. // }
  1645. // .talktext {
  1646. // border-radius: 8rpx;
  1647. // background-color: rgba(255, 255, 255, 0.1);
  1648. // view {
  1649. // width: 100%;
  1650. // }
  1651. // }
  1652. .talk-list {
  1653. border-radius: 30rpx;
  1654. background-color: rgba(33, 33, 33, 0.5);
  1655. padding: 10rpx 30rpx;
  1656. }
  1657. // .zoom-button-active {
  1658. // transform: scale(1.5);
  1659. // }
  1660. // .background-image {
  1661. // position: absolute;
  1662. // top: 0;
  1663. // left: -40rpx;
  1664. // width: 110%;
  1665. // height: 110%;
  1666. // object-fit: cover;
  1667. // filter: blur(20px);
  1668. // z-index: 0;
  1669. // }
  1670. // .background-images {
  1671. // position: absolute;
  1672. // top: 0;
  1673. // left: -40rpx;
  1674. // width: 110%;
  1675. // height: 110%;
  1676. // object-fit: cover;
  1677. // filter: blur(20px);
  1678. // z-index: 6;
  1679. // }
  1680. // .blackbg {
  1681. // position: absolute;
  1682. // top: 0;
  1683. // left: 0;
  1684. // width: 100%;
  1685. // height: 100%;
  1686. // background: rgba(0, 0, 0, 0.7);
  1687. // object-fit: cover;
  1688. // filter: blur(10px);
  1689. // z-index: 1;
  1690. // }
  1691. .content {
  1692. position: relative;
  1693. z-index: 2;
  1694. height: 100%;
  1695. width: 100%;
  1696. top: 0;
  1697. left: 0;
  1698. display: flex;
  1699. flex-direction: column;
  1700. justify-content: space-between;
  1701. .activity-box {
  1702. position: fixed;
  1703. top: 220rpx;
  1704. left: 30rpx;
  1705. z-index: 5;
  1706. display: flex;
  1707. align-items: center;
  1708. .item-box {
  1709. border-radius: 16rpx;
  1710. background-color: rgba(77, 77, 77, 0.5);
  1711. width: 80rpx;
  1712. height: 90rpx;
  1713. margin-right: 20rpx;
  1714. position: relative;
  1715. .tip {
  1716. position: absolute;
  1717. width: 100%;
  1718. bottom: 0;
  1719. color: #fafcff;
  1720. font-size: 20rpx;
  1721. background-color: rgba(15, 15, 15, 0.8);
  1722. border-radius: 16rpx;
  1723. text-align: center;
  1724. }
  1725. .item {
  1726. margin: 0 auto;
  1727. padding: 10rpx 0;
  1728. image {
  1729. height: 100%;
  1730. }
  1731. }
  1732. }
  1733. }
  1734. .siderow-group {
  1735. position: absolute;
  1736. top: 65%;
  1737. right: 30rpx;
  1738. z-index: 9;
  1739. display: flex;
  1740. flex-direction: column;
  1741. align-items: center;
  1742. .side-item {
  1743. font-weight: 500;
  1744. font-size: 24rpx;
  1745. color: #FFFFFF;
  1746. margin-bottom: 32rpx;
  1747. text-align: center;
  1748. .button {
  1749. background-color: transparent;
  1750. margin: 0;
  1751. line-height: 1;
  1752. padding: 0;
  1753. }
  1754. .image {
  1755. width: 72rpx;
  1756. height: 72rpx;
  1757. }
  1758. }
  1759. }
  1760. .side-group {
  1761. position: absolute;
  1762. // top: 30%;
  1763. top: 65%;
  1764. right: 30rpx;
  1765. z-index: 9;
  1766. display: flex;
  1767. flex-direction: column;
  1768. align-items: center;
  1769. .side-item {
  1770. font-weight: 500;
  1771. font-size: 24rpx;
  1772. color: #FFFFFF;
  1773. margin-bottom: 32rpx;
  1774. text-align: center;
  1775. .button {
  1776. background-color: transparent;
  1777. margin: 0;
  1778. line-height: 1;
  1779. padding: 0;
  1780. }
  1781. .image {
  1782. width: 72rpx;
  1783. height: 72rpx;
  1784. }
  1785. }
  1786. }
  1787. .content-top {
  1788. width: 100%;
  1789. margin-top: 48rpx;
  1790. display: flex;
  1791. justify-content: space-between;
  1792. padding: 0 24rpx;
  1793. box-sizing: border-box;
  1794. .sum {
  1795. width: 80rpx;
  1796. height: 52rpx;
  1797. background: rgba(0, 0, 0, 0.5);
  1798. border-radius: 26rpx 26rpx 26rpx 26rpx;
  1799. font-size: 24rpx;
  1800. color: #FFFFFF;
  1801. text-align: center;
  1802. line-height: 52rpx;
  1803. }
  1804. }
  1805. .follow-btn {
  1806. padding: 8rpx 16rpx;
  1807. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  1808. border-radius: 26rpx;
  1809. font-weight: 500;
  1810. font-size: 26rpx;
  1811. color: #FFFFFF;
  1812. }
  1813. }
  1814. .input-box {
  1815. position: fixed;
  1816. bottom: 20rpx;
  1817. }
  1818. .videolist {
  1819. position: relative;
  1820. .video {
  1821. height: 100vh;
  1822. /* 占屏幕高度的80% */
  1823. width: 100%;
  1824. background-color: rgba(57, 57, 57, 0.4);
  1825. .time {
  1826. color: #ffffff;
  1827. font-size: 20rpx;
  1828. margin-left: 10rpx;
  1829. }
  1830. .videotop {
  1831. width: 100%;
  1832. height: 100%;
  1833. }
  1834. .video_row {
  1835. width: 100%;
  1836. max-height: 500rpx;
  1837. overflow: hidden;
  1838. margin-top: 360rpx;
  1839. }
  1840. }
  1841. }
  1842. .prize-card {
  1843. width: 504rpx;
  1844. padding: 40rpx;
  1845. box-sizing: border-box;
  1846. display: flex;
  1847. flex-direction: column;
  1848. align-items: center;
  1849. .title {
  1850. font-size: 34rpx;
  1851. font-weight: 500;
  1852. margin: 0rpx 0 40rpx;
  1853. }
  1854. .prize-content {
  1855. display: flex;
  1856. flex-direction: column;
  1857. .name {
  1858. font-size: 32rpx;
  1859. font-weight: 600;
  1860. }
  1861. .txt {
  1862. font-size: 28rpx;
  1863. color: #C32008;
  1864. }
  1865. }
  1866. .button {
  1867. width: 392rpx;
  1868. height: 96rpx;
  1869. line-height: 96rpx;
  1870. background: linear-gradient(180deg, #FFF4D5 0%, #FFE5B1 100%);
  1871. border-radius: 48rpx 48rpx 48rpx 48rpx;
  1872. font-weight: 600;
  1873. font-size: 36rpx;
  1874. color: #C32008;
  1875. text-align: center;
  1876. }
  1877. }
  1878. .red-card {
  1879. width: 504rpx;
  1880. height: 636rpx;
  1881. position: relative;
  1882. image {
  1883. position: absolute;
  1884. width: 100%;
  1885. height: 100%;
  1886. }
  1887. .red-content {
  1888. position: relative;
  1889. z-index: 5;
  1890. display: flex;
  1891. flex-direction: column;
  1892. align-items: center;
  1893. .title {
  1894. font-size: 36rpx;
  1895. color: #FF3A1E;
  1896. margin: 180rpx 0 90rpx;
  1897. }
  1898. // .title {
  1899. // font-size: 36rpx;
  1900. // color: #FF3A1E;
  1901. // margin: 90rpx 0 20rpx;
  1902. // }
  1903. // .money {
  1904. // font-weight: 500;
  1905. // font-size: 32rpx;
  1906. // color: #FF3A1E;
  1907. // .bold{
  1908. // font-weight: bold;
  1909. // font-size: 128rpx;
  1910. // }
  1911. // }
  1912. .txt {
  1913. font-size: 28rpx;
  1914. color: #FFECC3;
  1915. margin: 80rpx 0 40rpx;
  1916. }
  1917. .button {
  1918. width: 392rpx;
  1919. height: 96rpx;
  1920. line-height: 96rpx;
  1921. background: linear-gradient(180deg, #FFF4D5 0%, #FFE5B1 100%);
  1922. border-radius: 48rpx 48rpx 48rpx 48rpx;
  1923. font-weight: 600;
  1924. font-size: 36rpx;
  1925. color: #C32008;
  1926. text-align: center;
  1927. }
  1928. }
  1929. }
  1930. .integral-box {
  1931. width: 500rpx;
  1932. display: flex;
  1933. flex-direction: column;
  1934. align-items: center;
  1935. border-radius: 20rpx;
  1936. overflow: hidden;
  1937. .top {
  1938. width: 100%;
  1939. position: relative;
  1940. .title {
  1941. width: 100%;
  1942. font-weight: 600;
  1943. font-size: 40rpx;
  1944. color: #FFFFFF;
  1945. text-shadow: 0px 4px 8px rgba(255, 89, 2, 0.8);
  1946. position: absolute;
  1947. top: 50rpx;
  1948. text-align: center;
  1949. }
  1950. .photo {
  1951. width: 100%;
  1952. }
  1953. }
  1954. .item {
  1955. padding: 20rpx;
  1956. .title {
  1957. font-weight: 500;
  1958. font-size: 32rpx;
  1959. text-align: center;
  1960. }
  1961. .button {
  1962. font-size: 32rpx;
  1963. margin-top: 20rpx;
  1964. background: linear-gradient(270deg, #ff4702 0%, #fe6304 100%);
  1965. color: #fff;
  1966. text-align: center;
  1967. padding: 18rpx 60rpx;
  1968. border-radius: 10rpx;
  1969. font-weight: 500;
  1970. }
  1971. }
  1972. }
  1973. .goods {
  1974. position: fixed;
  1975. top: 50%;
  1976. left: 50%;
  1977. transform: translate(-50%, -50%);
  1978. z-index: 5;
  1979. background-color: #fff;
  1980. border-radius: 20rpx;
  1981. overflow: hidden;
  1982. width: 400rpx;
  1983. padding: 4rpx;
  1984. .top {
  1985. position: absolute;
  1986. top: 4rpx;
  1987. display: flex;
  1988. justify-content: space-between;
  1989. align-items: center;
  1990. color: #fff;
  1991. width: 100%;
  1992. padding-right: 10rpx;
  1993. box-sizing: border-box;
  1994. .left {
  1995. background-color: rgba(0, 0, 0, 0.8);
  1996. padding: 12rpx;
  1997. font-size: 26rpx;
  1998. display: flex;
  1999. justify-content: space-between;
  2000. align-items: center;
  2001. border-radius: 10rpx;
  2002. }
  2003. }
  2004. .photo {
  2005. width: 100%;
  2006. height: 400rpx;
  2007. border-radius: 16rpx 16rpx 0 0;
  2008. overflow: hidden;
  2009. }
  2010. .item {
  2011. padding: 4rpx;
  2012. .price {
  2013. font-size: 34rpx;
  2014. .red {
  2015. color: #FF5701;
  2016. font-weight: 600;
  2017. margin-right: 10rpx;
  2018. }
  2019. .del {
  2020. color: #828282;
  2021. font-weight: 500;
  2022. font-size: 28rpx;
  2023. text-decoration: line-through
  2024. }
  2025. }
  2026. .title {
  2027. font-weight: 500;
  2028. font-size: 34rpx;
  2029. margin: 10rpx 0 12rpx;
  2030. }
  2031. .button {
  2032. background: linear-gradient(270deg, #ff4702 0%, #fe6304 100%);
  2033. color: #fff;
  2034. text-align: center;
  2035. padding: 16rpx 0;
  2036. border-radius: 10rpx;
  2037. font-weight: 500;
  2038. font-size: 34rpx;
  2039. }
  2040. }
  2041. }
  2042. .icon-bg {
  2043. background-color: rgba(57, 57, 57, 0.8);
  2044. border-radius: 50%;
  2045. width: 88rpx;
  2046. height: 88rpx;
  2047. display: flex;
  2048. justify-content: center;
  2049. align-items: center;
  2050. transition: transform 0.2s ease;
  2051. .button {
  2052. background-color: transparent;
  2053. margin: 0;
  2054. line-height: 1;
  2055. padding: 0;
  2056. }
  2057. }
  2058. .list {
  2059. width: 80%;
  2060. margin-bottom: 20rpx;
  2061. animation: xxxawdawd .2s;
  2062. }
  2063. @keyframes xxxawdawd {
  2064. from {
  2065. margin-top: 0rpx;
  2066. opacity: 0;
  2067. }
  2068. to {
  2069. margin-top: 20rpx;
  2070. opacity: 1;
  2071. }
  2072. }
  2073. .shop-prompt {
  2074. position: absolute;
  2075. bottom: 750rpx;
  2076. left: 24rpx;
  2077. padding: 6rpx 20rpx;
  2078. background: rgba(230, 154, 34, 0.7);
  2079. border-radius: 24rpx;
  2080. z-index: 9;
  2081. font-weight: 500;
  2082. color: #FFFFFF;
  2083. transition: opacity 0.3s ease;
  2084. }
  2085. .red-box {
  2086. .button {
  2087. margin: 0 auto;
  2088. width: 80%;
  2089. line-height: 88rpx;
  2090. height: 88rpx;
  2091. background: linear-gradient(90deg, #FF5701 0%, #FFB501 100%);
  2092. box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(238, 124, 80, 0.2);
  2093. border-radius: 44rpx 44rpx 44rpx 44rpx;
  2094. font-weight: 600;
  2095. font-size: 32rpx;
  2096. color: #FFFFFF;
  2097. text-align: center;
  2098. }
  2099. }
  2100. .view-box {
  2101. position: relative;
  2102. height: 40vh;
  2103. /* 设置弹出层高度为视窗高度的70% */
  2104. padding: 40rpx 0rpx 120rpx;
  2105. box-sizing: border-box;
  2106. display: flex;
  2107. flex-direction: column;
  2108. .scroll-content {
  2109. flex: 1;
  2110. overflow-y: auto;
  2111. padding: 0 40rpx;
  2112. }
  2113. .bottom {
  2114. padding: 20rpx 40rpx;
  2115. position: absolute;
  2116. bottom: 0;
  2117. width: 100%;
  2118. box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(195, 195, 195, 0.3);
  2119. background: #fff;
  2120. }
  2121. }
  2122. // 抽奖
  2123. .answerpop {
  2124. background: linear-gradient(to right, #fff7f8, #fee1e2);
  2125. margin-top: 30rpx;
  2126. padding: 10rpx 20rpx;
  2127. width: calc(100% - 40rpx);
  2128. border-radius: 20rpx;
  2129. display: flex;
  2130. align-items: center;
  2131. justify-content: space-between;
  2132. box-shadow: 2px 2px 4px 0 rgba(255, 124, 126, 0.1);
  2133. .answera {
  2134. display: flex;
  2135. justify-content: center;
  2136. background-color: #fff;
  2137. padding: 20rpx 0;
  2138. width: 35%;
  2139. border-radius: 40rpx;
  2140. align-items: center;
  2141. margin: 10rpx 0;
  2142. box-shadow: 2px 2px 4px 0 rgba(72, 72, 72, 0.1);
  2143. image {
  2144. width: 40rpx;
  2145. height: 40rpx;
  2146. margin-right: 10rpx;
  2147. }
  2148. }
  2149. }
  2150. // 抽奖
  2151. .prize-box {
  2152. position: relative;
  2153. .nav-img {
  2154. width: 311rpx;
  2155. position: absolute;
  2156. top: -122rpx;
  2157. left: 50%;
  2158. transform: translateX(-50%);
  2159. }
  2160. .bg-img {
  2161. position: absolute;
  2162. top: 0;
  2163. left: 0;
  2164. width: 100%;
  2165. height: 100%;
  2166. z-index: 1;
  2167. }
  2168. .prize-content {
  2169. position: relative;
  2170. z-index: 2;
  2171. padding: 24rpx 0 68rpx;
  2172. .white-item {
  2173. width: 40rpx;
  2174. height: 40rpx;
  2175. text-align: center;
  2176. overflow: hidden;
  2177. background: #FFFFFF;
  2178. box-shadow: inset 0rpx 2rpx 8rpx 0rpx #FFEBB2;
  2179. border-radius: 8rpx;
  2180. margin: 4rpx;
  2181. font-weight: 600;
  2182. font-size: 24rpx;
  2183. color: #F85D22;
  2184. line-height: 40rpx;
  2185. }
  2186. .item-group {
  2187. width: 100%;
  2188. // position: absolute;
  2189. // top: 250rpx;
  2190. // left: 0;
  2191. // width: 100%;
  2192. // height: 500rpx;
  2193. }
  2194. // .item-group {
  2195. // position: absolute;
  2196. // top: 250rpx;
  2197. // left: 0;
  2198. // width: 100%;
  2199. // display: flex;
  2200. // align-items: center;
  2201. // overflow: hidden;
  2202. // overflow-x: auto; // 仅横向滚动
  2203. // overflow-y: hidden;
  2204. // gap: 20rpx;
  2205. // padding: 0 20rpx; // 左右留间隙,避免item贴边
  2206. // scroll-behavior: smooth; // 平滑滚动(关键)
  2207. // scrollbar-width: none; // 隐藏滚动条(可选,美化)
  2208. // -ms-overflow-style: none; // IE隐藏滚动条
  2209. // .item {
  2210. // flex-shrink: 0;
  2211. // width: 348rpx;
  2212. // height: 348rpx;
  2213. // background: #FFFFFF;
  2214. // box-shadow: 0rpx 12rpx 19rpx 2rpx rgba(219, 73, 22, 0.6);
  2215. // border-radius: 24rpx 24rpx 24rpx 24rpx;
  2216. // border: 4rpx solid #FFCA96;
  2217. // display: flex;
  2218. // flex-direction: column;
  2219. // align-items: center;
  2220. // box-sizing: border-box;
  2221. // padding: 20rpx 0;
  2222. // .title {
  2223. // font-weight: 500;
  2224. // font-size: 32rpx;
  2225. // color: #222222;
  2226. // margin: 20rpx 0 20rpx;
  2227. // }
  2228. // .txt {
  2229. // font-size: 24rpx;
  2230. // color: #757575;
  2231. // }
  2232. // }
  2233. // .center {
  2234. // width: 440rpx;
  2235. // height: 450rpx;
  2236. // }
  2237. // }
  2238. .point-group {
  2239. margin: 20rpx 0 50rpx;
  2240. display: flex;
  2241. gap: 6rpx;
  2242. .item {
  2243. width: 20rpx;
  2244. height: 8rpx;
  2245. background: rgba(255, 255, 255, 0.5);
  2246. border-radius: 4rpx 4rpx 4rpx 4rpx;
  2247. }
  2248. .selected {
  2249. background: #FFEB66;
  2250. }
  2251. }
  2252. .button {
  2253. margin-top: 30rpx;
  2254. width: 520rpx;
  2255. height: 88rpx;
  2256. line-height: 88rpx;
  2257. background: linear-gradient(180deg, #FFF4D6 0%, #FFEB66 100%);
  2258. box-shadow: 0rpx 10rpx 8rpx 4rpx rgba(246, 82, 25, 0.5);
  2259. border-radius: 44rpx;
  2260. font-weight: 500;
  2261. font-size: 36rpx;
  2262. color: #F4410B;
  2263. text-align: center;
  2264. }
  2265. }
  2266. }
  2267. .shoppop {
  2268. padding: 22rpx 16rpx;
  2269. .shoppop-top {
  2270. display: flex;
  2271. justify-content: space-between;
  2272. align-items: center;
  2273. padding: 0 16rpx 22rpx;
  2274. .search-input {
  2275. width: 414rpx;
  2276. height: 76rpx;
  2277. background: #FFFFFF;
  2278. border-radius: 36rpx;
  2279. margin-left: 20rpx;
  2280. padding: 0 32rpx;
  2281. box-sizing: border-box;
  2282. font-size: 24rpx;
  2283. margin-right: 24rpx;
  2284. }
  2285. .search-top {
  2286. font-size: 20rpx;
  2287. color: #222222;
  2288. }
  2289. }
  2290. .shop-list {
  2291. overflow: hidden;
  2292. .list-item {
  2293. display: flex;
  2294. align-items: center;
  2295. padding: 20rpx 16rpx;
  2296. background: #FFFFFF;
  2297. border-radius: 16rpx;
  2298. margin-bottom: 16rpx;
  2299. .goods-img {
  2300. width: 200rpx;
  2301. height: 200rpx;
  2302. border-radius: 16rpx;
  2303. overflow: hidden;
  2304. position: relative;
  2305. margin-right: 24rpx;
  2306. image {
  2307. width: 100%;
  2308. height: 100%;
  2309. }
  2310. .goods-label {
  2311. position: absolute;
  2312. top: 0;
  2313. width: 64rpx;
  2314. height: 40rpx;
  2315. background: rgba(0, 0, 0, 0.5);
  2316. border-radius: 16rpx 0rpx 16rpx 0rpx;
  2317. text-align: center;
  2318. font-weight: 500;
  2319. font-size: 28rpx;
  2320. color: #FFFFFF;
  2321. }
  2322. }
  2323. .goods-right {
  2324. flex: 1;
  2325. .goods-title {
  2326. font-weight: 500;
  2327. font-size: 30rpx;
  2328. color: #000000;
  2329. margin-bottom: 10rpx;
  2330. }
  2331. .goods-details {
  2332. font-size: 24rpx;
  2333. color: #999999;
  2334. margin: 10rpx 0 20rpx;
  2335. }
  2336. .goods-people {
  2337. font-size: 22rpx;
  2338. color: #E69A22;
  2339. height: 56rpx;
  2340. }
  2341. .goods-shop {
  2342. display: flex;
  2343. justify-content: space-between;
  2344. .nummber {
  2345. color: #FF5C03;
  2346. font-size: 22rpx;
  2347. font-weight: 500;
  2348. }
  2349. .btn-group {
  2350. text-align: center;
  2351. line-height: 56rpx;
  2352. .collect-btn {
  2353. width: 72rpx;
  2354. background: #F5F7FA;
  2355. border-radius: 8rpx 0rpx 0rpx 8rpx;
  2356. }
  2357. .shop-btn {
  2358. width: 152rpx;
  2359. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  2360. border-radius: 0rpx 8rpx 8rpx 0rpx;
  2361. font-weight: 500;
  2362. font-size: 30rpx;
  2363. color: #FFFFFF;
  2364. }
  2365. }
  2366. }
  2367. }
  2368. }
  2369. }
  2370. }
  2371. :deep(.u-list-item) {
  2372. width: 100%;
  2373. display: flex;
  2374. align-items: center;
  2375. }
  2376. :deep(.u-safe-area-inset-bottom) {
  2377. padding-bottom: 0
  2378. }
  2379. </style>