living.vue 66 KB

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