living.vue 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067
  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: 100rpx;">
  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. <!-- <view class="side-item">
  35. <image @click="goStore(liveItem)" src="/static/images/live/shop.png"></image>
  36. <view>店铺</view>
  37. </view> -->
  38. <view class="side-item">
  39. <button open-type="share" class="button">
  40. <image class="image" src="/static/images/share.png" mode="widthFix"></image>
  41. </button>
  42. <view>分享</view>
  43. </view>
  44. </view>
  45. <!-- 红包内容 -->
  46. <view class="hongbao-box" v-if="liveItem.redInfo?.redStatus==1&&isShowRed">
  47. <view class="u-flex-y-center">
  48. <view class="tip">领红包</view>
  49. <view class="item">
  50. <image @click="onRed(liveItem)" src="/static/images/redbag.png" mode="widthFix">
  51. </image>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- <view class="shop-prompt f30 u-flex-y-center" v-if="showPurchasePrompt&&orderUser?.count">-->
  56. <!-- <image class="w32 h32 mr8" src="/static/images/live/shopping.png"></image>-->
  57. <!-- <text> {{orderUser.userName ? maskString(orderUser.userName) : ''}} 等-->
  58. <!-- {{orderUser.count || 0}}-->
  59. <!-- 人正在去购买</text>-->
  60. <!-- </view>-->
  61. <view class="videolist" style="margin: auto 0">
  62. <view class="video" style="height:100vh">
  63. <!-- 视频组件 -->
  64. <live-player v-if=" liveItem.livingUrl && liveItem.liveType === 1"
  65. :id="'myLivePlayer_' + liveItem.liveId"
  66. :class="liveItem.showType == 1 ? 'video_row' : 'videotop'" :src="liveItem.livingUrl"
  67. autoplay mode="live" object-fit="contain" :waiting="false" :muted="false"
  68. :orientation="liveItem.showType == 1 ? 'horizontal' : 'vertical'"
  69. @statechange="onLiveStateChange($event, liveItem)" @error="onLiveError($event, liveItem)"
  70. class="live-player"></live-player>
  71. <!-- <video v-if="currentSwiperIndex === index && liveItem.livingUrl"
  72. :id="'myVideo_' + liveItem.liveId"
  73. :class="liveItem.showType == 1 ? 'video_row' : 'videotop'" :src="liveItem.livingUrl"
  74. :controls='false' object-fit='contain' :custom-cache="false"
  75. :enable-progress-gesture="false" vslide-gesture-in-fullscreen='true'
  76. :show-center-play-btn="false" :http-cache="false" @error="videoError">
  77. </video> -->
  78. <video v-if=" liveItem.videoUrl" :class="liveItem.showType == 1 ? 'video_row' : 'videotop'"
  79. :src="liveItem.videoUrl" :autoplay="true" :controls='false' object-fit='contain'
  80. :custom-cache="false" :enable-progress-gesture="false" vslide-gesture-in-fullscreen='true'
  81. :show-center-play-btn="false" :http-cache="false" loop @error="videoError">
  82. </video>
  83. <view v-if="liveItem.videoUrl" class="time">{{liveItem.totalTime}}</view>
  84. </view>
  85. </view>
  86. <!-- 底部聊天区域 -->
  87. <view class="pb40 mt90" style="position: fixed;bottom: 120rpx;width: 100%;">
  88. <view class="w100 h300 mt20">
  89. <scroll-view enable-flex scroll-y="true" class="talk p20 scrolly flex-1 column"
  90. style="width: calc(100% - 40rpx);height: calc(100% - 40rpx);"
  91. :scroll-into-view="liveItem.scrollIntoView">
  92. <view>
  93. <view class="list justify-start" v-for="(item,talkIndex) in liveItem.talklist"
  94. :key="talkIndex" v-show="item.cmd=='announcement'">
  95. <view class="talk-list ml16 justify-start">
  96. <view class="fs30">
  97. <text class='colorf'>
  98. {{item.msg}}直播间{{liveItem.messageContent}}</text>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="list justify-start" v-for="(item,talkIndex) in liveItem.talklist"
  104. :key="talkIndex" :id="`list_${talkIndex}`"
  105. v-show="item.cmd!='red'&&item.cmd!='out'&&item.cmd!='entry'">
  106. <view class="talk-list ml16 justify-start">
  107. <view class="fs30">
  108. <text style="color: #FFDA73;">{{item.nickName}}:</text>
  109. <text class='colorf'>{{item.msg}}</text>
  110. </view>
  111. </view>
  112. </view>
  113. <view v-if="liveItem.showWelcomeMessage" class="welcome-message">
  114. <view class="list justify-start" v-for="(item,talkIndex) in liveItem.talklist"
  115. :key="talkIndex" v-show="item.cmd=='entry'||item.cmd=='out'">
  116. <view class="talk-list ml16 justify-start">
  117. <view class="fs30">
  118. <text style="color: #ff89d6;">{{item.nickName}} </text>
  119. <text class='colorf'>
  120. {{item.msg}}直播间{{liveItem.messageContent}}</text>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </scroll-view>
  126. </view>
  127. <!-- 底部输入框和操作按钮 -->
  128. <view class="justify-between p24 input-box">
  129. <view class="u-flex-y-center w580"
  130. style="background:rgba(57, 57, 57, 1);padding:10rpx 14rpx 10rpx 32rpx;box-sizing:border-box;border-radius:36rpx;">
  131. <u-input :placeholder="liveItem.placeholderText" border="none"
  132. customStyle='font-size:24rpx;' v-model="liveItem.value" shape='circle' color='#fff'
  133. placeholderStyle='color:#e7e7e7' class="ml20">
  134. </u-input>
  135. <view class="send" @click="sendMsg(liveItem)">发送</view>
  136. </view>
  137. <view class="justify-between mr15 align-center">
  138. <view class="icon-bg ml20" @click="openCart(liveItem)">
  139. <image src="/static/images/shopping.png" class="w58 h58"></image>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. <u-popup :show="liveItem.goodsCard?.isShow" @close="!liveItem.goodsCard?.isShow" round='20rpx' mode="center"
  146. bgColor='#ffffff'>
  147. <view class="goods">
  148. <view class="top">
  149. <view class="left">
  150. <image class="w30 h30 mr8" src="/static/images/signal.png"></image>讲解中
  151. </view>
  152. <image class="w30 h30" src="/static/images/close.png" @click="liveItem.goodsCard.isShow=false">
  153. </image>
  154. </view>
  155. <image class="photo" :src="liveItem.goodsCard?.imgUrl"></image>
  156. <view class="item">
  157. <view class="price"><text class="red">¥{{liveItem.goodsCard?.price}} </text><text
  158. class="del">¥{{liveItem.goodsCard?.otPrice}}</text></view>
  159. <view class="title oneline-hide">{{liveItem.goodsCard?.productName}}</view>
  160. <view class="button" @click="goShop(liveItem.goodsCard?.productId,liveItem.goodsCard?.goodsId)">
  161. 立即抢购
  162. </view>
  163. </view>
  164. </view>
  165. </u-popup>
  166. <!-- 抽奖 -->
  167. <!-- <u-popup :show="true" @close="" round='40rpx' bgColor='#fff'>
  168. <view class=" p20 bgf" style="border-radius: 40rpx;height: fit-content;">
  169. <view class="u-flex-row-reverse u-flex">
  170. <u-icon name="close" size="18" @click=""></u-icon>
  171. </view>
  172. <view class="column align-center h400">
  173. <view class="fs36 " style="color: #000000;font-weight: bold;">答题获取红包/积分奖励</view>
  174. <view class="answerpop" @click="noredanswer">
  175. <view class="color6 w350 fs24">
  176. 观看直播参与抽奖
  177. </view>
  178. <view class="answera">参与抽奖</view>
  179. </view>
  180. </view>
  181. </view>
  182. </u-popup> -->
  183. <u-popup :show="liveItem.integral?.status" @close="!liveItem.integral?.status" round='20rpx' mode="center"
  184. bgColor='#ffffff'>
  185. <view class="integral-box">
  186. <view class="top">
  187. <view class="title">观看视频领芳华币</view>
  188. <image class="photo" src="/static/images/integral.png" mode="widthFix"></image>
  189. </view>
  190. <view class="item">
  191. <view class="title ">{{liveItem.integral?.msg}}</view>
  192. <view class="button" @click="liveItem.integral.status=flase">确认</view>
  193. </view>
  194. </view>
  195. </u-popup>
  196. <!-- 观众列表弹窗 -->
  197. <u-popup :show="showadd" @close="close" @open="openViews" round='20rpx' bgColor='#ffffff'>
  198. <view class="view-box">
  199. <view class="t-c fs30">在线观众</view>
  200. <scroll-view scroll-y class="scroll-content" :style="{height: scrollHeight + 'px'}"
  201. @scrolltolower="handleScrollToLower">
  202. <view class="fs24 u-flex-y-center mb20" v-for="(item,index) in liveViewers" :key="index">
  203. <view
  204. :style="{color: index === 0 ? '#FF3B30' : index === 1 ? '#FF9500' : index === 2 ? '#FFCC00' : '#8E8E93',fontWeight: index < 3 ? 'bold' : 'normal',width: '50rpx'}"
  205. class="mr10">{{index+1}}</view>
  206. <u-avatar :src="item.avatar||$img.logo" size="32"></u-avatar>
  207. <text class="ml16">{{item.nickName||"未命名"}}</text>
  208. </view>
  209. <view class="no-more" v-if="viewNoMoreData && liveViewers.length > 0">
  210. <text>没有更多了</text>
  211. </view>
  212. </scroll-view>
  213. </view>
  214. </u-popup>
  215. <!-- 商品弹窗 -->
  216. <u-popup :show="liveItem.shopping" @close="closeShop" @open="openShop" round='20rpx' bgColor='f3f5f9'>
  217. <view class="shoppop">
  218. <view class="shoppop-top">
  219. <u-avatar :src="store.logoUrl" size="36" class="ml16"></u-avatar>
  220. <view class="search-input u-flex-y-center">
  221. <image class="w24 mr16" src="/static/images/search.png" mode="widthFix">
  222. </image>
  223. <input placeholder="请搜索商品" v-model="liveItem.inputInfo" @input="handleSearchInput" />
  224. </view>
  225. <view class="t-c search-top" @click="goOrderList(liveItem)">
  226. <image class="w48 h48" src="/static/images/order.png"></image>
  227. <view>订单</view>
  228. </view>
  229. </view>
  230. <scroll-view enable-flex scroll-y class="shop-list" :style="{ height: boxHeight + 'px' }">
  231. <view class="list-item" v-for="(item,index) in products" :key="index">
  232. <view class="goods-img">
  233. <image :src="item.imgUrl" mode="widthFix"></image>
  234. <view class="goods-label">{{index+1}}</view>
  235. </view>
  236. <view class="goods-right">
  237. <view class="goods-title">{{item.productName}}</view>
  238. <view class="goods-people">{{item.sales}} 人已购</view>
  239. <view class="goods-shop">
  240. <text class="nummber"><text style="font-size: 20rpx;font-weight: 600;">¥</text><text
  241. style="font-size: 36rpx;font-weight: bold;">{{Math.trunc(item.price)}}</text>.{{getPureDecimal(item.price)?getPureDecimal(item.price):'00'}}/日</text>
  242. <view class="btn-group u-flex-y-center">
  243. <view class="collect-btn">
  244. <image v-if="item.isFavorite" @click="onGoodsCollect(item)" class="w36 h36"
  245. src="/static/images/collect_select.png">
  246. </image>
  247. <image v-else @click="onGoodsCollect(item)" class="w36 h36"
  248. src="/static/images/collect.png">
  249. </image>
  250. </view>
  251. <view v-if="item.status==1" class="shop-btn"
  252. @click="goShop(item.productId,item.goodsId)">去购买 </view>
  253. <view v-else-if="item.status==0" class="shop-btn">
  254. 已下架</view>
  255. </view>
  256. </view>
  257. </view>
  258. </view>
  259. </scroll-view>
  260. </view>
  261. </u-popup>
  262. </view>
  263. </view>
  264. </template>
  265. <script>
  266. import Hls from 'hls.js';
  267. import CryptoJS from 'crypto-js'
  268. import {
  269. liveList
  270. } from '@/api/list'
  271. import {
  272. liveRed, // 点击领红包
  273. liveDataLike, // 点赞
  274. collectStore, // 店铺收藏/取消收藏
  275. collectGoods, // 商品收藏/取消收藏
  276. // store, // 查询店铺
  277. // showGoods, //弹出商品卡片
  278. // follow, // 关注/取消关注
  279. watchUserList, //获取直播间用户(展示在线用户)
  280. liveMsg, //获取最近聊天记录
  281. // 小黄车
  282. liveStore, //店铺展示,
  283. // liveGoodsDetail, //商品详情,
  284. liveOrderUser, //正在购买
  285. getLiveInfo, //获取直播间信息接口
  286. getLiveViewData, //直播间点赞、关注、在线人数数据
  287. currentActivities //红包 卡片 抽奖
  288. } from '@/api/live'
  289. import {
  290. liveOrderList, // 订单列表
  291. } from '@/api/order'
  292. import parse from '/uni_modules/uview-plus/libs/config/props/parse';
  293. import {
  294. LiveWS
  295. } from '@/utils/liveWS.js'
  296. import {
  297. getlive,
  298. // gettextlist,
  299. getAnswerlist,
  300. submitAnswer
  301. } from '@/api/home'
  302. var wsUrl = "wss://live.test.ylrztop.com/ws/live-api/app/webSocket"; //余红奇
  303. // var wsUrl = "ws://192.168.10.166:7114/app/webSocket"; //余红奇
  304. var pingpangTimes = null;
  305. var initTimes = null;
  306. var isSocketOpen = false;
  307. var socket = null;
  308. export default {
  309. data() {
  310. return {
  311. liveItem: {
  312. liveId: null,
  313. shopping: false,
  314. inputInfo: '',
  315. goodsList: [],
  316. goodsTotal: 0,
  317. goodsPageNum: 1,
  318. goodsPageSize: 10,
  319. goodsLoading: false,
  320. goodsNoMoreData: false,
  321. goodsScrollHeight: 0,
  322. goodsScrollTimer: null,
  323. goodsCurrentIndex: 0,
  324. goodsCurrentPage: 1,
  325. talkList: [],
  326. showWelcomeMessage: false,
  327. redInfo: null,
  328. scrollIntoView: null,
  329. },
  330. timer: null,
  331. isShowRed: false,
  332. // 新增:滑动节流相关变量
  333. lastSwiperChangeTime: 0, // 上次切换时间戳
  334. swiperChangeThrottle: 300, // 切换节流阈值(毫秒)
  335. lastClickTime: 0,
  336. clickDelay: 300, // 300ms内只响应一次点击
  337. connectingLiveId: null, // 记录正在连接的直播间ID
  338. swiperDuration: 0, // 初始化为0,首次加载无动画
  339. videoRetryCounts: {}, // 记录每个直播间的视频重试次数,格式: { liveId: 次数 }
  340. // preloading: false, // 预加载状态
  341. liveUserTotal: null,
  342. viewPageSize: 10, // 每页数量
  343. viewPageNum: 1, // 当前页码
  344. viewLoading: false, // 是否正在加载
  345. viewNoMoreData: false, // 是否没有更多数据
  346. scrollHeight: 0,
  347. scrollTimer: null, // 滚动防抖定时器
  348. socketInstance: null, // 统一管理 socket 实例
  349. reconnectCount: 0,
  350. maxReconnectAttempts: 3,
  351. isManualClose: false, // 标记是否手动关闭
  352. showRed: true,
  353. searchTimer: null,
  354. reconnectTimer: null,
  355. isCollect: false,
  356. showPurchasePrompt: false,
  357. purchasePromptTimer: null,
  358. prevOrderCount: 0, // 用于记录上一次的购买人数
  359. videoUrl: null,
  360. showType: 1, //横屏1 竖屏2
  361. boxHeight: 300, //小黄车高度
  362. liveViewers: [], //观众
  363. likeName: 0,
  364. hlsPlayer: null, // HLS播放器实例,
  365. livingUrl: "",
  366. products: {},
  367. store: {},
  368. orderUser: {}, //正在购买
  369. userType: 0,
  370. timestamp: '',
  371. liveId: null,
  372. userinfo: '', //用户信息
  373. // path: 'http://192.168.10.166/dev-api', //余红奇
  374. // path: 'http://v56c9b8e.natappfree.cc', //余红奇
  375. // path: 'live.test.ylrztop.com/prod-api', //余红奇
  376. // value: '',
  377. talkdisabled: false, //输入框是否禁用
  378. autoplay: false, //视频自动播放
  379. showadd: false,
  380. scrollIntoView: '',
  381. videoContext: '',
  382. livedata: {}, //直播间点赞、关注、在线人数数据
  383. };
  384. },
  385. onLoad(options) {
  386. this.initTime();
  387. console.log(options)
  388. if (options.liveId) {
  389. this.liveId = options.liveId; // 仅当 liveId 变化时更新
  390. }
  391. this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
  392. if (this.liveId == null) {
  393. uni.showToast({
  394. title: "未知错误,请联系管理员!",
  395. icon: 'none'
  396. });
  397. return;
  398. }
  399. console.log(this.liveId)
  400. // 初始化直播间列表
  401. this.getliving(this.liveId);
  402. this.initSocket(this.liveId);
  403. // this.getliveUser(false); // 调用获取在线用户接口
  404. const platform = uni.getWindowInfo().platform;
  405. // 初始化直播间列表
  406. if (['mp-weixin', 'mp-alipay', 'mp-baidu', 'mp-toutiao'].includes(platform)) {
  407. // 确保 API 存在再调用
  408. if (uni.showShareMenu) {
  409. uni.showShareMenu({
  410. withShareTicket: true, // 可选参数,根据需求配置
  411. success: () => {
  412. console.log('分享菜单显示成功');
  413. },
  414. fail: (err) => {
  415. console.error('分享菜单显示失败:', err);
  416. }
  417. });
  418. } else {
  419. console.warn('当前平台不支持 uni.showShareMenu');
  420. }
  421. }
  422. },
  423. onReady() {},
  424. onShareAppMessage() {
  425. return {
  426. title: this.livedata.liveName,
  427. path: '/pages/home/living',
  428. imageUrl: this.products.image,
  429. success(res) {
  430. console.log("分享成功", res);
  431. },
  432. fail(err) {
  433. console.error("分享失败", err);
  434. }
  435. };
  436. },
  437. computed: {
  438. filteredViewers() {
  439. // 若 liveViewers 是 null/undefined/非数组,返回空数组
  440. if (!Array.isArray(this.liveViewers)) {
  441. return [];
  442. }
  443. return this.liveViewers.slice(0, 3);
  444. }
  445. },
  446. onHide() {
  447. const currentLive = this.liveItem;
  448. if (currentLive) {
  449. this.pauseVideo(currentLive);
  450. this.clearTimeTimer(currentLive); // 隐藏时清除当前直播间定时器
  451. } // 隐藏时关闭所有连接
  452. this.closeAllWebSockets();
  453. },
  454. onUnload() {
  455. // 关闭所有WebSocket连接
  456. // this.closeAllWebSockets();
  457. this.closeWebSocket();
  458. this.socketInstances = {}; // 强制清空实例对象
  459. // 移除所有全局事件监听
  460. this.removeAllEventListeners();
  461. // 清理定时器
  462. this.clearAllTimers();
  463. // 销毁HLS播放器(如果使用了hls.js)
  464. if (this.hlsPlayer) {
  465. this.hlsPlayer.destroy();
  466. this.hlsPlayer = null;
  467. }
  468. this.list.forEach(liveItem => {
  469. const videoId = `myVideo_${liveItem.liveId}`;
  470. const videoContext = uni.createVideoContext(videoId, this);
  471. if (videoContext) {
  472. videoContext.pause(); // 仅暂停视频即可
  473. }
  474. });
  475. },
  476. watch: {
  477. // 监听orderUser.count的变化
  478. 'orderUser.count': {
  479. handler(newVal, oldVal) {
  480. if (newVal !== this.prevOrderCount) {
  481. this.prevOrderCount = newVal;
  482. this.showPurchaseMessage();
  483. }
  484. },
  485. immediate: true
  486. }
  487. },
  488. methods: {
  489. openShop() {
  490. this.queryCollect()
  491. this.liveItem.shopping = true
  492. },
  493. onLiveStateChange(e, liveItem) {
  494. // console.log('直播状态变化:', e.detail.code, e.detail);
  495. // 可以根据状态码处理不同的直播状态
  496. const stateCode = e.detail.code;
  497. // 2001: 已经连接服务器
  498. // 2002: 已经连接服务器,开始拉流
  499. // 2003: 网络接收到首个视频数据包(IDR)
  500. // 2004: 视频播放开始
  501. // 2005: 视频播放进度
  502. // 2006: 视频播放结束
  503. // 2007: 视频播放Loading
  504. // 2008: 解码器启动
  505. // -2301: 网络断连,且经多次重连抢救无效,更多重试请自行重启播放
  506. // -2302: 获取加速拉流地址失败
  507. }, // 直播错误事件
  508. onLiveError(e, liveItem) {
  509. this.videoError(e, liveItem);
  510. },
  511. // 红包 卡片 抽奖
  512. getCurrentActivities(liveItem) {
  513. if (!liveItem.liveId) return;
  514. // const res = currentActivities(liveId);
  515. currentActivities(liveItem.liveId).then(res => {
  516. if (res.code == 200) {
  517. // 商品卡片
  518. this.$set(liveItem, 'goodsCard', res.goods);
  519. // 红包
  520. this.$set(liveItem, 'redInfo', res.red[0]);
  521. this.isShowRed = true
  522. // 抽奖
  523. this.$set(liveItem, 'lottery', res.lottery);
  524. } else {
  525. uni.showToast({
  526. title: res.msg,
  527. icon: 'none'
  528. });
  529. }
  530. },
  531. rej => {}
  532. );
  533. },
  534. // 计算当前时间与 liveItem.startTime 的差值,并更新 totalTime
  535. calculateTimeDiff(liveItem) {
  536. if (!liveItem.startTime) {
  537. liveItem.totalTime = '00小时00分钟00秒';
  538. return;
  539. }
  540. const iosCompatibleTime = liveItem.startTime
  541. .replace(/-/g, '/')
  542. .replace(' ', ' ');
  543. const startTime = new Date(liveItem.startTime);
  544. const now = new Date();
  545. if (isNaN(startTime.getTime())) {
  546. console.warn(`iOS 时间解析失败,原始时间:${liveItem.startTime},转换后:${iosCompatibleTime}`);
  547. liveItem.totalTime = '00小时00分钟00秒';
  548. return;
  549. }
  550. const diffMs = Math.max(0, now - startTime);
  551. const totalSeconds = Math.floor(diffMs / 1000);
  552. const hours = this.padZero(Math.floor(totalSeconds / 3600));
  553. const minutes = this.padZero(Math.floor((totalSeconds % 3600) / 60));
  554. const seconds = this.padZero(totalSeconds % 60);
  555. this.$set(liveItem, 'totalTime', `${hours}:${minutes}:${seconds}`);
  556. },
  557. padZero(num) {
  558. return num < 10 ? `0${num}` : num;
  559. },
  560. // 启动当前直播间的时间差值定时器
  561. startTimeTimer(liveItem) {
  562. // 先清除当前直播间的旧定时器(避免重复)
  563. if (liveItem.timeTimer) {
  564. clearInterval(liveItem.timeTimer);
  565. }
  566. // 立即计算一次(避免等待1秒才显示)
  567. this.calculateTimeDiff(liveItem);
  568. // 每秒更新一次(实时刷新)
  569. liveItem.timeTimer = setInterval(() => {
  570. this.calculateTimeDiff(liveItem);
  571. }, 1000);
  572. },
  573. // 清除指定直播间的时间定时器
  574. clearTimeTimer(liveItem) {
  575. if (liveItem.timeTimer) {
  576. clearInterval(liveItem.timeTimer);
  577. liveItem.timeTimer = null; // 清空定时器标识
  578. }
  579. },
  580. toggleViewerList() {
  581. const now = Date.now()
  582. if (now - this.lastClickTime > this.clickDelay) {
  583. this.showadd = !this.showadd
  584. this.lastClickTime = now
  585. }
  586. },
  587. closeAllWebSockets() {
  588. this.isManualClose = true;
  589. // 关闭所有连接
  590. Object.keys(this.socketInstances).forEach(liveId => {
  591. try {
  592. if (this.socketInstances[liveId] && this.socketInstances[liveId].instance) {
  593. this.socketInstances[liveId].instance.close({
  594. code: 1000,
  595. reason: '页面关闭'
  596. });
  597. console.log(`直播间 ${liveId} WebSocket 已关闭`);
  598. }
  599. } catch (e) {
  600. console.error(`关闭直播间 ${liveId} WebSocket 时出错:`, e);
  601. }
  602. });
  603. this.socketInstances = {};
  604. isSocketOpen = false;
  605. }, // 移除所有全局事件监听器
  606. removeAllEventListeners() {
  607. uni.$off('initSocket');
  608. uni.$off('sendMsg');
  609. uni.$off('closeWebSocket');
  610. uni.$off('refreshOrder');
  611. // 可以根据实际情况添加其他需要移除的事件
  612. }, // 清理所有定时器
  613. clearAllTimers() {
  614. if (this.intervalId) {
  615. clearInterval(this.intervalId);
  616. this.intervalId = null;
  617. }
  618. if (this.pingpangTimes) {
  619. clearInterval(this.pingpangTimes);
  620. this.pingpangTimes = null;
  621. }
  622. if (this.reconnectTimer) {
  623. clearInterval(this.reconnectTimer);
  624. this.reconnectTimer = null;
  625. }
  626. if (this.scrollTimer) {
  627. clearTimeout(this.scrollTimer);
  628. this.scrollTimer = null;
  629. }
  630. if (this.searchTimer) {
  631. clearTimeout(this.searchTimer);
  632. this.searchTimer = null;
  633. }
  634. if (this.purchasePromptTimer) {
  635. clearTimeout(this.purchasePromptTimer);
  636. this.purchasePromptTimer = null;
  637. }
  638. },
  639. // 播放视频
  640. playVideo(liveItem) {
  641. if (!liveItem) return;
  642. try {
  643. // 直播流使用live-player
  644. if (liveItem.liveType === 1 && liveItem.livingUrl) {
  645. const livePlayerId = `myLivePlayer_${liveItem.liveId}`;
  646. const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
  647. if (livePlayerContext) {
  648. livePlayerContext.play();
  649. }
  650. }
  651. // 回放视频使用video
  652. else if (liveItem.liveType === 2 && liveItem.videoUrl) {
  653. const videoId = `myVideo_${liveItem.liveId}`;
  654. const videoContext = uni.createVideoContext(videoId, this);
  655. if (videoContext) {
  656. videoContext.pause(() => {
  657. videoContext.play();
  658. });
  659. }
  660. }
  661. } catch (error) {
  662. console.error("播放视频失败:", error);
  663. }
  664. },
  665. pauseVideo(liveItem) {
  666. if (!liveItem) return;
  667. try {
  668. // 直播流使用live-player
  669. if (liveItem.liveType === 1) {
  670. const livePlayerId = `myLivePlayer_${liveItem.liveId}`;
  671. const livePlayerContext = uni.createLivePlayerContext(livePlayerId, this);
  672. if (livePlayerContext) {
  673. livePlayerContext.pause();
  674. }
  675. }
  676. // 回放视频使用video
  677. else if (liveItem.liveType === 2) {
  678. const videoId = `myVideo_${liveItem.liveId}`;
  679. const videoContext = uni.createVideoContext(videoId, this);
  680. if (videoContext) {
  681. videoContext.pause();
  682. }
  683. }
  684. } catch (error) {
  685. console.error("暂停视频失败:", error);
  686. }
  687. },
  688. openViews() {
  689. // 计算scroll-view高度
  690. this.$nextTick(() => {
  691. const query = uni.createSelectorQuery().in(this);
  692. query.select('.view-box').boundingClientRect(data => {
  693. if (data) {
  694. // 减去标题和底部固定区域的高度
  695. this.scrollHeight = data.height - 80 - 120; // 80是标题高度,120是底部高度
  696. }
  697. }).exec();
  698. });
  699. },
  700. // 重置直播间数据
  701. resetLiveData() {
  702. // 保留不需要重置的数据(如用户信息等)
  703. const keepData = {
  704. userinfo: this.userinfo,
  705. list: this.list,
  706. currentSwiperIndex: this.currentSwiperIndex
  707. };
  708. // 重置其他直播间特定数据
  709. this.liveUserTotal = null;
  710. // this.liveViewData = {};
  711. this.liveViewers = [];
  712. this.livingUrl = "";
  713. this.videoUrl = null;
  714. this.products = {};
  715. this.store = {};
  716. this.orderUser = {};
  717. this.talklist = [];
  718. this.livedata = {};
  719. // this.isFollow = false;
  720. this.shopping = false;
  721. this.inputInfo = ''
  722. // 恢复需要保留的数据
  723. Object.assign(this, keepData);
  724. },
  725. // 获取直播间用户
  726. async getliveUser(isLoadMore = false) {
  727. // 强制使用当前 liveId,避免使用旧值
  728. const currentLiveId = this.liveId;
  729. if (!currentLiveId) return;
  730. // if (this.viewLoading || this.viewNoMoreData) return;
  731. this.viewLoading = true;
  732. try {
  733. const res = await watchUserList(currentLiveId, this.viewPageSize, this.viewPageNum, false);
  734. if (res.code === 200) {
  735. // 若请求期间已切换直播间,忽略旧数据
  736. if (this.liveId !== currentLiveId) return;
  737. this.liveUserTotal = res.total;
  738. if (res.rows.length === 0) {
  739. this.viewNoMoreData = true;
  740. return;
  741. }
  742. this.liveViewers = isLoadMore ? [...this.liveViewers, ...res.rows] : res
  743. .rows; // 首次加载/切换直播间时重置数据
  744. this.viewPageNum++;
  745. // console.log("在线观众", this.liveViewers)
  746. }
  747. } catch (error) {
  748. console.error('获取观众列表失败:', error);
  749. } finally {
  750. this.viewLoading = false;
  751. }
  752. },
  753. // 滚动到底部触发
  754. handleScrollToLower() {
  755. // 清除上一次未执行的定时器,避免重复请求
  756. if (this.scrollTimer) {
  757. clearTimeout(this.scrollTimer);
  758. }
  759. // 延迟0.5秒(500毫秒)执行接口请求
  760. this.scrollTimer = setTimeout(() => {
  761. // this.getliveUser(true); // 加载更多数据
  762. }, 1000); // 延迟时间:500毫秒
  763. },
  764. async getLiveMsg(liveItem) {
  765. // 强化校验:确保 liveItem 存在且包含 liveId
  766. if (!liveItem || !liveItem.liveId) {
  767. console.error('getLiveMsg 错误:无效的 liveItem', {
  768. liveItem: liveItem,
  769. currentIndex: this.currentSwiperIndex,
  770. listLength: this.list.length
  771. });
  772. return; // 直接返回,不执行后续逻辑
  773. }
  774. try {
  775. const res = await liveMsg(liveItem.liveId, 30, 1);
  776. if (res.code == 200) {
  777. const rows = Array.isArray(res.rows) ? res.rows : [];
  778. const reversedTalkList = [...rows].reverse();
  779. this.$set(liveItem, 'talklist', reversedTalkList);
  780. this.$nextTick(() => {
  781. // 滚动到最新消息(反转后最新消息在数组最后一位,索引为 reversedTalkList.length - 1)
  782. this.$set(liveItem, 'scrollIntoView', `list_${reversedTalkList.length - 1}`);
  783. });
  784. }
  785. } catch (error) {
  786. console.error("获取聊天记录失败:", error);
  787. }
  788. },
  789. // 点击红包
  790. onRed(item) {
  791. // console.log("点了this.liveId", item)
  792. if (!item.liveId) return;
  793. if (!item.redInfo?.redId) return;
  794. let data = {
  795. liveId: item.liveId,
  796. userId: this.userinfo.userId,
  797. redId: item.redInfo.redId,
  798. }
  799. liveRed(data).then(res => {
  800. this.isShowRed = false
  801. if (res.code == 200) {
  802. console.log(this.isShowRed)
  803. console.log("点了this.liveId", liveItem.redInfo)
  804. uni.showToast({
  805. title: res.msg,
  806. icon: 'none'
  807. });
  808. } else {
  809. uni.showToast({
  810. title: res.msg,
  811. icon: 'none'
  812. });
  813. }
  814. },
  815. rej => {}
  816. );
  817. },
  818. handleSearchInput() {
  819. // 使用防抖优化性能,避免频繁请求
  820. clearTimeout(this.searchTimer);
  821. this.searchTimer = setTimeout(() => {
  822. this.queryCollect();
  823. }, 500); // 500毫秒延迟
  824. },
  825. // 显示购买提示信息
  826. showPurchaseMessage() {
  827. // 清除之前的定时器
  828. if (this.purchasePromptTimer) {
  829. clearTimeout(this.purchasePromptTimer);
  830. }
  831. // 显示提示
  832. this.showPurchasePrompt = true;
  833. // 2秒后自动隐藏
  834. this.purchasePromptTimer = setTimeout(() => {
  835. this.showPurchasePrompt = false;
  836. }, 2000);
  837. },
  838. truncateString(str, maxLength) {
  839. return str.length > maxLength ? str.slice(0, maxLength) + '...' : str;
  840. },
  841. // 去订单列表
  842. goOrderList() {
  843. uni.navigateTo({
  844. url: "/pages_shop/order"
  845. })
  846. },
  847. // 初始化HLS播放器
  848. initHlsPlayer() {
  849. if (Hls.isSupported() && this.livingUrl) {
  850. const video = document.getElementById('myVideo');
  851. if (video) {
  852. this.hlsPlayer = new Hls();
  853. this.hlsPlayer.loadSource(this.livingUrl);
  854. this.hlsPlayer.attachMedia(video);
  855. this.hlsPlayer.on(Hls.Events.MANIFEST_PARSED, () => {
  856. video.play();
  857. });
  858. }
  859. }
  860. },
  861. // 视频错误处理
  862. videoError(e, liveItem) {
  863. if (!liveItem || liveItem.liveId !== this.liveId) return;
  864. // 初始化重试计数
  865. if (this.videoRetryCounts[liveItem.liveId] === undefined) {
  866. this.videoRetryCounts[liveItem.liveId] = 0;
  867. }
  868. // 限制重试次数
  869. if (this.videoRetryCounts[liveItem.liveId] >= 3) {
  870. console.error(`直播间 ${liveItem.liveId} 视频加载失败,停止重试`);
  871. // 显示错误提示
  872. uni.showToast({
  873. title: "视频加载失败,请检查网络",
  874. icon: 'none',
  875. duration: 2000
  876. });
  877. return;
  878. }
  879. this.videoRetryCounts[liveItem.liveId]++;
  880. // 延迟重试
  881. setTimeout(() => {
  882. if (liveItem.liveId === this.liveId) {
  883. console.log(`第${this.videoRetryCounts[liveItem.liveId]}次重试播放视频`);
  884. this.playVideo(liveItem);
  885. }
  886. }, 2000);
  887. },
  888. // 修改获取直播信息方法
  889. async getliving(liveId) {
  890. const param = {
  891. id: liveId
  892. };
  893. try {
  894. const res = await getlive(param);
  895. if (res.code !== 200) {
  896. uni.showToast({
  897. title: res.msg,
  898. icon: 'none'
  899. });
  900. return;
  901. }
  902. this.liveItem = res.data;
  903. this.liveItem.talklist = []
  904. // 强制更新视频源(覆盖旧值)
  905. if (res.data.liveType === 2) {
  906. // 回放视频
  907. this.$set(this.liveItem, 'videoUrl', res.data.videoUrl);
  908. this.$set(this.liveItem, 'livingUrl', ''); // 清空直播流
  909. this.$set(this.liveItem, 'placeholderText', "说点什么...");
  910. } else if (res.data.liveType === 1) {
  911. // 直播流
  912. this.$set(this.liveItem, 'livingUrl', res.data.flvHlsUrl);
  913. this.$set(this.liveItem, 'videoUrl', ''); // 清空回放视频
  914. this.$set(this.liveItem, 'placeholderText', "说点什么...");
  915. } else {
  916. // 未开播
  917. this.$set(this.liveItem, 'livingUrl', '');
  918. this.$set(this.liveItem, 'videoUrl', '');
  919. }
  920. await this.getLiveMsg(this.liveItem);
  921. await this.getliveViewData(this.liveItem);
  922. this.getCurrentActivities(this.liveItem);
  923. this.$set(this.liveItem, 'autoplay', res.data.liveType !== 0);
  924. this.$set(this.liveItem, 'showType', res.data.showType);
  925. this.$set(this.liveItem, 'storeId', res.storeId);
  926. } catch (err) {
  927. console.error("获取直播信息失败:", err);
  928. uni.showToast({
  929. title: "获取直播信息失败",
  930. icon: 'none'
  931. });
  932. }
  933. }, // 设置视频播放
  934. maskString(str, maskChar = '*') {
  935. // 如果str是undefined或null,直接返回空字符串
  936. if (!str) return '';
  937. // 确保str是字符串(如果是数字等类型,先转为字符串)
  938. const strVal = String(str);
  939. return strVal.split('').map((char, index) => (index === 0 ? char : maskChar)).join('');
  940. },
  941. getPureDecimal(num, precision = 6) {
  942. const decimalPart = Math.abs(num).toFixed(precision).split('.')[1];
  943. return decimalPart?.replace(/0+$/, '') || ''; // 移除末尾多余的0
  944. },
  945. // 返回上一个页面并关闭WebSocket
  946. goBack() {
  947. // 暂停当前视频
  948. const currentLive = this.liveItem;
  949. if (currentLive) {
  950. this.pauseVideo(currentLive);
  951. }
  952. // 关闭所有WebSocket连接
  953. this.closeWebSocket();
  954. // 导航返回
  955. const pages = getCurrentPages();
  956. if (pages.length > 1) {
  957. uni.navigateBack();
  958. } else {
  959. uni.reLaunch({
  960. url: '/pages/list/index'
  961. });
  962. }
  963. },
  964. // 点赞
  965. async onLike(liveItem) {
  966. if (!liveItem || !liveItem.liveId) return;
  967. try {
  968. const res = await liveDataLike(liveItem.liveId);
  969. if (res?.like) {
  970. liveItem.liveViewData.like++; // 只更新当前直播间的点赞数
  971. } else {
  972. uni.showToast({
  973. title: res.msg,
  974. icon: 'none'
  975. });
  976. }
  977. } catch (error) {
  978. console.error('点赞失败:', error);
  979. }
  980. },
  981. //直播间点赞、关注、在线人数数据
  982. async getliveViewData(liveItem) {
  983. if (!liveItem || !liveItem.liveId) return;
  984. try {
  985. const res = await getLiveViewData(liveItem.liveId);
  986. if (res.code == 200) {
  987. // 强制响应式更新,确保数据实时显示
  988. this.$set(liveItem, 'liveViewData', res);
  989. }
  990. } catch (error) {
  991. console.error("获取直播间数据失败:", error);
  992. // 失败时兜底,避免显示异常
  993. this.$set(liveItem, 'liveViewData', {
  994. like: 0,
  995. watchCount: 0
  996. });
  997. }
  998. },
  999. // 去购买,跳商品详情
  1000. goShop(productId, goodsId) {
  1001. const currentLive = this.liveItem;
  1002. if (!currentLive || !currentLive.liveId) return;
  1003. uni.navigateTo({
  1004. url: '/pages_shop/goods?productId=' + productId + '&liveId=' + currentLive.liveId +
  1005. '&goodsId=' + goodsId + '&storeId=' + currentLive.storeId
  1006. })
  1007. },
  1008. // 查询店铺
  1009. async queryCollect() {
  1010. const currentLive = this.liveItem;
  1011. if (!currentLive || !currentLive.liveId) return;
  1012. const {
  1013. storeId
  1014. } = currentLive;
  1015. if (!storeId) return;
  1016. if (currentLive.inputInfo == null) currentLive.inputInfo = ''
  1017. try {
  1018. const res = await liveStore(currentLive.liveId, currentLive.inputInfo);
  1019. if (res.code === 200) {
  1020. // 数据绑定到当前 liveItem,避免全局污染
  1021. this.$set(currentLive, 'products', res.data);
  1022. // this.$set(currentLive, 'store', res.data);
  1023. // 同步更新全局变量(供弹窗使用)
  1024. this.products = res.data;
  1025. // this.store = res.data;
  1026. }
  1027. } catch (error) {
  1028. console.error('获取小黄车商品失败:', error);
  1029. }
  1030. },
  1031. // 时间戳
  1032. initTime() {
  1033. const now = new Date();
  1034. this.timestamp = now.getTime(); // 例如:'2023-04-01 12:00:00'
  1035. },
  1036. openCart(liveItem) {
  1037. if (!liveItem.storeId) {
  1038. uni.showToast({
  1039. title: "当前直播间暂未开通店铺",
  1040. icon: 'none'
  1041. });
  1042. return;
  1043. }
  1044. liveItem.shopping = true
  1045. },
  1046. close() {
  1047. this.showadd = false
  1048. },
  1049. // 关闭小黄车
  1050. closeShop() {
  1051. // 通过当前swiper索引获取当前直播间实例
  1052. const currentLive = this.liveItem;
  1053. if (currentLive) {
  1054. this.$set(currentLive, 'shopping', false);
  1055. }
  1056. },
  1057. getEWechatSdk() {
  1058. // 只在H5平台执行
  1059. // #ifdef H5
  1060. let eWechatSdk = '';
  1061. if (/(Android)/i.test(navigator.userAgent)) {
  1062. eWechatSdk = 'jWeixin';
  1063. } else if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  1064. eWechatSdk = 'wx';
  1065. } else {
  1066. eWechatSdk = 'jWeixin';
  1067. }
  1068. uni.setStorageSync("wxSdk", eWechatSdk);
  1069. // #endif
  1070. },
  1071. // 修改关闭WebSocket方法
  1072. closeWebSocket() {
  1073. this.socket?.close();
  1074. },
  1075. initSocket(liveId) {
  1076. if (liveId == null) return;
  1077. // 设置正在连接的直播间ID
  1078. this.connectingLiveId = liveId;
  1079. // 生成签名
  1080. const signature = CryptoJS.HmacSHA256(
  1081. `${liveId}${this.userinfo.userId}${this.userType}${this.timestamp}`,
  1082. this.timestamp.toString()
  1083. ).toString(CryptoJS.enc.Hex);
  1084. try {
  1085. const socketTask = uni.connectSocket({
  1086. url: `${wsUrl}?userId=${this.userinfo.userId}&liveId=${liveId}&userType=${this.userType}&timestamp=${this.timestamp}&signature=${signature}`,
  1087. success: () => {},
  1088. fail: (err) => {}
  1089. });
  1090. socketTask.onOpen((res) => {
  1091. this.socket = socketTask;
  1092. });
  1093. socketTask.onMessage((res) => {
  1094. // 找到对应的直播间并更新数据
  1095. const targetLive = this.liveItem;
  1096. if (targetLive) {
  1097. this.handleSocketMessage(res, targetLive);
  1098. }
  1099. });
  1100. socketTask.onError((err) => {
  1101. console.log(err)
  1102. });
  1103. socketTask.onClose(() => {
  1104. console.log(`WebSocket 连接已关闭: ${liveId}`);
  1105. this.connectingLiveId = null;
  1106. });
  1107. } catch (e) {
  1108. console.error('创建 WebSocket 异常:', e);
  1109. this.connectingLiveId = null;
  1110. this.scheduleReconnect(liveId);
  1111. }
  1112. },
  1113. // 处理Socket消息
  1114. handleSocketMessage(message, liveItem) {
  1115. let data = JSON.parse(message.data)
  1116. const socketMessage = data.data // 服务端返回的消息体
  1117. if (data.code == 200) {
  1118. const messageData = {
  1119. ...socketMessage,
  1120. cmd: socketMessage.cmd || '', // 确保cmd字段存在
  1121. ts: Date.now() // 新增时间戳,用于排序(可选)
  1122. };
  1123. // 处理服务端返回的sendMsg消息,加入本地列表
  1124. if (socketMessage.cmd == 'sendMsg') {
  1125. // 1. 将消息追加到当前直播间的talklist中(响应式更新)
  1126. this.$set(liveItem, 'talklist', [...(liveItem.talklist || []), messageData]);
  1127. // 2. 延迟下一帧滚动到最新消息(确保DOM已更新)
  1128. this.$nextTick(() => {
  1129. const lastIndex = liveItem.talklist.length - 1;
  1130. this.$set(liveItem, 'scrollIntoView', `list_${lastIndex}`);
  1131. });
  1132. } else if (socketMessage.cmd == 'red') {
  1133. this.$set(liveItem, 'redInfo', JSON.parse(socketMessage.data));
  1134. this.isShowRed = true
  1135. this.timer = setInterval(() => {
  1136. this.isShowRed = true
  1137. }, liveItem.redInfo.duration * 1000)
  1138. } else if (socketMessage.cmd == 'entry' || socketMessage.cmd == 'out') {
  1139. this.$set(liveItem, 'talklist', [...liveItem.talklist, messageData]);
  1140. this.$set(liveItem, 'showWelcomeMessage', false);
  1141. this.$set(liveItem, 'showWelcomeMessage', true);
  1142. this.getliveUser(false);
  1143. if (liveItem.welcomeTimer) clearTimeout(liveItem.welcomeTimer);
  1144. liveItem.welcomeTimer = setTimeout(() => {
  1145. this.$set(liveItem, 'showWelcomeMessage', false);
  1146. }, 1000);
  1147. } else if (socketMessage.cmd == 'Integral') {
  1148. let integral = {
  1149. msg: socketMessage.msg,
  1150. status: true
  1151. }
  1152. this.$set(liveItem, 'integral', integral);
  1153. } else if (socketMessage.cmd == 'blockUser') {
  1154. uni.removeStorage({
  1155. key: 'AppToken',
  1156. success: () => {
  1157. uni.reLaunch({
  1158. url: '/pages/auth/login'
  1159. });
  1160. }
  1161. });
  1162. } else if (socketMessage.cmd == 'goods') {
  1163. this.$set(liveItem, 'goodsCard', JSON.parse(socketMessage.data));
  1164. }
  1165. } else {
  1166. uni.showToast({
  1167. title: data.msg,
  1168. icon: 'none'
  1169. });
  1170. }
  1171. },
  1172. sendMsg(liveItem) {
  1173. if (!liveItem || !liveItem.liveId) return;
  1174. // 防止连续点击发送两次(短时锁定)
  1175. if (liveItem.isSending) return;
  1176. liveItem.isSending = true;
  1177. setTimeout(() => {
  1178. liveItem.isSending = false;
  1179. }, 800); // 800ms 内禁止再次发送
  1180. const text = (liveItem.value || '').trim();
  1181. if (!text) {
  1182. uni.showToast({
  1183. title: "不能发送空消息",
  1184. icon: 'none'
  1185. });
  1186. return;
  1187. }
  1188. const liveId = liveItem.liveId;
  1189. const socketItem = this.socket;
  1190. this.$set(liveItem, 'value', ''); // 立即清空输入框,提升体验
  1191. // 构造发送给服务端的消息数据
  1192. const data = {
  1193. liveId,
  1194. userId: this.userinfo.userId,
  1195. userType: 0,
  1196. cmd: "sendMsg", // 指令标识,服务端会根据此返回sendMsg消息
  1197. msg: text,
  1198. nickName: this.userinfo.nickName,
  1199. avatar: this.userinfo.avatar
  1200. };
  1201. // 发送socket消息
  1202. try {
  1203. this.socket.send({
  1204. data: JSON.stringify(data),
  1205. success: () => {
  1206. // 发送成功无需额外操作,等待服务端返回消息后再更新列表
  1207. },
  1208. fail: (err) => {
  1209. uni.showToast({
  1210. title: err,
  1211. icon: 'none'
  1212. });
  1213. // 发送失败时可恢复输入框内容
  1214. this.$set(liveItem, 'value', text);
  1215. }
  1216. });
  1217. } catch (err) {}
  1218. }
  1219. }
  1220. };
  1221. </script>
  1222. <style scoped lang="scss">
  1223. .live-player {
  1224. width: 100%;
  1225. height: 100%;
  1226. }
  1227. .swiper-wrapper {
  1228. position: relative;
  1229. width: 100%;
  1230. height: 100vh;
  1231. overflow: hidden;
  1232. background-color: #000000;
  1233. }
  1234. .swiper-container {
  1235. width: 100%;
  1236. height: 100vh;
  1237. }
  1238. .container {
  1239. width: 100%;
  1240. height: 100%;
  1241. position: relative;
  1242. transition: opacity 0.3s ease;
  1243. transform: translateZ(0); // 开启GPU加速
  1244. will-change: opacity; // 告诉浏览器提前优化该属性
  1245. }
  1246. .loading-tip {
  1247. position: absolute;
  1248. top: 50%;
  1249. left: 50%;
  1250. transform: translate(-50%, -50%);
  1251. display: flex;
  1252. flex-direction: column;
  1253. align-items: center;
  1254. justify-content: center;
  1255. z-index: 10;
  1256. .loading-text {
  1257. color: #ffffff;
  1258. font-size: 28rpx;
  1259. margin-top: 20rpx;
  1260. }
  1261. }
  1262. .loading-more,
  1263. .no-more {
  1264. display: flex;
  1265. justify-content: center;
  1266. align-items: center;
  1267. padding: 20rpx 0;
  1268. color: #999;
  1269. font-size: 24rpx;
  1270. }
  1271. .loading-more {
  1272. flex-direction: column;
  1273. }
  1274. .preload-indicator {
  1275. position: absolute;
  1276. top: 50%;
  1277. right: 30rpx;
  1278. transform: translateY(-50%);
  1279. z-index: 100;
  1280. background: rgba(0, 0, 0, 0.5);
  1281. border-radius: 50%;
  1282. padding: 16rpx;
  1283. }
  1284. /* button自带样式清除 */
  1285. .student-orther-icon button::after {
  1286. border: none !important;
  1287. padding: 0 !important;
  1288. margin: 0 !important;
  1289. }
  1290. .student-orther-icon button {
  1291. background-color: transparent !important;
  1292. padding: 0 !important;
  1293. line-height: inherit !important;
  1294. margin: 0 !important;
  1295. width: auto !important;
  1296. font-weight: 500 !important;
  1297. border-radius: none !important;
  1298. }
  1299. .welcome-message {
  1300. position: fixed;
  1301. width: 100%;
  1302. bottom: 460rpx;
  1303. left: 50%;
  1304. transform: translateX(-50%);
  1305. color: white;
  1306. padding: 10px 20px;
  1307. border-radius: 20px;
  1308. // animation: fadeOut 1s ease 1s forwards;
  1309. z-index: 1000;
  1310. transition: opacity 0.3s ease;
  1311. }
  1312. @keyframes fadeOut {
  1313. from {
  1314. opacity: 1;
  1315. }
  1316. to {
  1317. opacity: 0;
  1318. }
  1319. }
  1320. .send {
  1321. background-color: #fafafa;
  1322. border-radius: 28rpx;
  1323. padding: 14rpx 16rpx;
  1324. color: #181818;
  1325. font-weight: 500;
  1326. }
  1327. // .container {
  1328. // position: relative;
  1329. // width: 100%;
  1330. // height: 100vh;
  1331. // overflow: hidden;
  1332. // }
  1333. // .talktext {
  1334. // border-radius: 8rpx;
  1335. // background-color: rgba(255, 255, 255, 0.1);
  1336. // view {
  1337. // width: 100%;
  1338. // }
  1339. // }
  1340. .talk-list {
  1341. border-radius: 30rpx;
  1342. background-color: rgba(33, 33, 33, 0.5);
  1343. padding: 10rpx 30rpx;
  1344. }
  1345. // .zoom-button-active {
  1346. // transform: scale(1.5);
  1347. // }
  1348. // .background-image {
  1349. // position: absolute;
  1350. // top: 0;
  1351. // left: -40rpx;
  1352. // width: 110%;
  1353. // height: 110%;
  1354. // object-fit: cover;
  1355. // filter: blur(20px);
  1356. // z-index: 0;
  1357. // }
  1358. // .background-images {
  1359. // position: absolute;
  1360. // top: 0;
  1361. // left: -40rpx;
  1362. // width: 110%;
  1363. // height: 110%;
  1364. // object-fit: cover;
  1365. // filter: blur(20px);
  1366. // z-index: 6;
  1367. // }
  1368. // .blackbg {
  1369. // position: absolute;
  1370. // top: 0;
  1371. // left: 0;
  1372. // width: 100%;
  1373. // height: 100%;
  1374. // background: rgba(0, 0, 0, 0.7);
  1375. // object-fit: cover;
  1376. // filter: blur(10px);
  1377. // z-index: 1;
  1378. // }
  1379. .content {
  1380. position: relative;
  1381. z-index: 2;
  1382. height: 100%;
  1383. width: 100%;
  1384. top: 0;
  1385. left: 0;
  1386. display: flex;
  1387. flex-direction: column;
  1388. justify-content: space-between;
  1389. .hongbao-box {
  1390. position: fixed;
  1391. top: 200rpx;
  1392. left: 30rpx;
  1393. z-index: 5;
  1394. border-radius: 16rpx;
  1395. background-color: rgba(77, 77, 77, 0.5);
  1396. width: 90rpx;
  1397. height: 100rpx;
  1398. .tip {
  1399. position: absolute;
  1400. width: 100%;
  1401. bottom: 0;
  1402. color: #fafcff;
  1403. font-size: 20rpx;
  1404. background-color: rgba(15, 15, 15, 0.8);
  1405. border-radius: 16rpx;
  1406. text-align: center;
  1407. }
  1408. .item {
  1409. padding: 10rpx 4rpx;
  1410. image {
  1411. width: 80rpx;
  1412. height: 100%;
  1413. }
  1414. }
  1415. }
  1416. .siderow-group {
  1417. position: absolute;
  1418. top: 65%;
  1419. right: 30rpx;
  1420. z-index: 9;
  1421. display: flex;
  1422. flex-direction: column;
  1423. align-items: center;
  1424. .side-item {
  1425. font-weight: 500;
  1426. font-size: 24rpx;
  1427. color: #FFFFFF;
  1428. margin-bottom: 32rpx;
  1429. text-align: center;
  1430. .button {
  1431. background-color: transparent;
  1432. margin: 0;
  1433. line-height: 1;
  1434. padding: 0;
  1435. }
  1436. .image {
  1437. width: 72rpx;
  1438. height: 72rpx;
  1439. }
  1440. }
  1441. }
  1442. .side-group {
  1443. position: absolute;
  1444. // top: 30%;
  1445. top: 65%;
  1446. right: 30rpx;
  1447. z-index: 9;
  1448. display: flex;
  1449. flex-direction: column;
  1450. align-items: center;
  1451. .side-item {
  1452. font-weight: 500;
  1453. font-size: 24rpx;
  1454. color: #FFFFFF;
  1455. margin-bottom: 32rpx;
  1456. text-align: center;
  1457. .button {
  1458. background-color: transparent;
  1459. margin: 0;
  1460. line-height: 1;
  1461. padding: 0;
  1462. }
  1463. .image {
  1464. width: 72rpx;
  1465. height: 72rpx;
  1466. }
  1467. }
  1468. }
  1469. .content-top {
  1470. width: 100%;
  1471. margin-top: 68rpx;
  1472. display: flex;
  1473. justify-content: space-between;
  1474. padding: 0 24rpx;
  1475. box-sizing: border-box;
  1476. .sum {
  1477. width: 80rpx;
  1478. height: 52rpx;
  1479. background: rgba(0, 0, 0, 0.5);
  1480. border-radius: 26rpx 26rpx 26rpx 26rpx;
  1481. font-size: 24rpx;
  1482. color: #FFFFFF;
  1483. text-align: center;
  1484. line-height: 52rpx;
  1485. }
  1486. }
  1487. .follow-btn {
  1488. padding: 8rpx 16rpx;
  1489. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  1490. border-radius: 26rpx;
  1491. font-weight: 500;
  1492. font-size: 26rpx;
  1493. color: #FFFFFF;
  1494. }
  1495. }
  1496. .input-box {
  1497. position: fixed;
  1498. bottom: 20rpx;
  1499. }
  1500. .videolist {
  1501. position: relative;
  1502. .video {
  1503. height: 100vh;
  1504. /* 占屏幕高度的80% */
  1505. width: 100%;
  1506. background-color: rgba(57, 57, 57, 0.4);
  1507. .time {
  1508. color: #ffffff;
  1509. font-size: 20rpx;
  1510. margin-left: 10rpx;
  1511. }
  1512. .videotop {
  1513. width: 100%;
  1514. height: 100%;
  1515. }
  1516. .video_row {
  1517. width: 100%;
  1518. max-height: 500rpx;
  1519. overflow: hidden;
  1520. margin-top: 360rpx;
  1521. }
  1522. }
  1523. }
  1524. .integral-box {
  1525. width: 300rpx;
  1526. display: flex;
  1527. flex-direction: column;
  1528. align-items: center;
  1529. border-radius: 20rpx;
  1530. overflow: hidden;
  1531. .top {
  1532. width: 100%;
  1533. position: relative;
  1534. .title {
  1535. width: 100%;
  1536. font-weight: 600;
  1537. font-size: 30rpx;
  1538. color: #FFFFFF;
  1539. text-shadow: 0px 4px 8px rgba(255, 89, 2, 0.8);
  1540. position: absolute;
  1541. top: 30rpx;
  1542. text-align: center;
  1543. }
  1544. .photo {
  1545. width: 100%;
  1546. }
  1547. }
  1548. .item {
  1549. padding: 20rpx;
  1550. .title {
  1551. font-weight: 500;
  1552. font-size: 30rpx;
  1553. text-align: center;
  1554. }
  1555. .button {
  1556. margin-top: 20rpx;
  1557. background: linear-gradient(270deg, #ff4702 0%, #fe6304 100%);
  1558. color: #fff;
  1559. text-align: center;
  1560. padding: 16rpx 30rpx;
  1561. border-radius: 10rpx;
  1562. font-weight: 500;
  1563. }
  1564. }
  1565. }
  1566. .goods {
  1567. position: fixed;
  1568. // bottom: 160rpx;
  1569. // right: 10rpx;
  1570. top: 50%;
  1571. left: 50%;
  1572. transform: translate(-50%, -50%);
  1573. z-index: 5;
  1574. background-color: #fff;
  1575. border-radius: 20rpx;
  1576. overflow: hidden;
  1577. width: 300rpx;
  1578. // width: 220rpx;
  1579. padding: 4rpx;
  1580. .top {
  1581. position: absolute;
  1582. top: 4rpx;
  1583. display: flex;
  1584. justify-content: space-between;
  1585. align-items: center;
  1586. color: #fff;
  1587. width: 100%;
  1588. padding-right: 10rpx;
  1589. box-sizing: border-box;
  1590. .left {
  1591. background-color: rgba(0, 0, 0, 0.8);
  1592. padding: 10rpx;
  1593. font-size: 20rpx;
  1594. display: flex;
  1595. justify-content: space-between;
  1596. align-items: center;
  1597. border-radius: 10rpx;
  1598. }
  1599. }
  1600. .photo {
  1601. width: 100%;
  1602. height: 250rpx;
  1603. border-radius: 16rpx 16rpx 0 0;
  1604. overflow: hidden;
  1605. }
  1606. .item {
  1607. padding: 4rpx;
  1608. .price {
  1609. .red {
  1610. color: #FF5701;
  1611. font-weight: 600;
  1612. margin-right: 10rpx;
  1613. }
  1614. .del {
  1615. color: #828282;
  1616. font-weight: 500;
  1617. font-size: 24rpx;
  1618. text-decoration: line-through
  1619. }
  1620. }
  1621. .title {
  1622. font-weight: 500;
  1623. font-size: 26rpx;
  1624. margin: 10rpx 0 12rpx;
  1625. }
  1626. .button {
  1627. background: linear-gradient(270deg, #ff4702 0%, #fe6304 100%);
  1628. color: #fff;
  1629. text-align: center;
  1630. padding: 16rpx 0;
  1631. border-radius: 10rpx;
  1632. font-weight: 500;
  1633. }
  1634. }
  1635. }
  1636. .icon-bg {
  1637. background-color: rgba(57, 57, 57, 0.8);
  1638. border-radius: 50%;
  1639. width: 88rpx;
  1640. height: 88rpx;
  1641. display: flex;
  1642. justify-content: center;
  1643. align-items: center;
  1644. transition: transform 0.2s ease;
  1645. .button {
  1646. background-color: transparent;
  1647. margin: 0;
  1648. line-height: 1;
  1649. padding: 0;
  1650. }
  1651. }
  1652. .list {
  1653. width: 80%;
  1654. margin-bottom: 20rpx;
  1655. animation: xxxawdawd .2s;
  1656. }
  1657. @keyframes xxxawdawd {
  1658. from {
  1659. margin-top: 0rpx;
  1660. opacity: 0;
  1661. }
  1662. to {
  1663. margin-top: 20rpx;
  1664. opacity: 1;
  1665. }
  1666. }
  1667. .shop-prompt {
  1668. position: absolute;
  1669. bottom: 600rpx;
  1670. left: 24rpx;
  1671. padding: 6rpx 20rpx;
  1672. background: rgba(230, 154, 34, 0.7);
  1673. border-radius: 24rpx;
  1674. z-index: 9;
  1675. font-weight: 500;
  1676. color: #FFFFFF;
  1677. transition: opacity 0.3s ease;
  1678. }
  1679. .red-box {
  1680. .button {
  1681. margin: 0 auto;
  1682. width: 80%;
  1683. line-height: 88rpx;
  1684. height: 88rpx;
  1685. background: linear-gradient(90deg, #FF5701 0%, #FFB501 100%);
  1686. box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(238, 124, 80, 0.2);
  1687. border-radius: 44rpx 44rpx 44rpx 44rpx;
  1688. font-weight: 600;
  1689. font-size: 32rpx;
  1690. color: #FFFFFF;
  1691. text-align: center;
  1692. }
  1693. }
  1694. .view-box {
  1695. position: relative;
  1696. height: 40vh;
  1697. /* 设置弹出层高度为视窗高度的70% */
  1698. padding: 40rpx 0rpx 120rpx;
  1699. box-sizing: border-box;
  1700. display: flex;
  1701. flex-direction: column;
  1702. .scroll-content {
  1703. flex: 1;
  1704. overflow-y: auto;
  1705. padding: 0 40rpx;
  1706. }
  1707. .bottom {
  1708. padding: 20rpx 40rpx;
  1709. position: absolute;
  1710. bottom: 0;
  1711. width: 100%;
  1712. box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(195, 195, 195, 0.3);
  1713. background: #fff;
  1714. }
  1715. }
  1716. // 抽奖
  1717. .answerpop {
  1718. background: linear-gradient(to right, #fff7f8, #fee1e2);
  1719. margin-top: 30rpx;
  1720. padding: 10rpx 20rpx;
  1721. width: calc(100% - 40rpx);
  1722. border-radius: 20rpx;
  1723. display: flex;
  1724. align-items: center;
  1725. justify-content: space-between;
  1726. box-shadow: 2px 2px 4px 0 rgba(255, 124, 126, 0.1);
  1727. .answera {
  1728. display: flex;
  1729. justify-content: center;
  1730. background-color: #fff;
  1731. padding: 20rpx 0;
  1732. width: 35%;
  1733. border-radius: 40rpx;
  1734. align-items: center;
  1735. margin: 10rpx 0;
  1736. box-shadow: 2px 2px 4px 0 rgba(72, 72, 72, 0.1);
  1737. image {
  1738. width: 40rpx;
  1739. height: 40rpx;
  1740. margin-right: 10rpx;
  1741. }
  1742. }
  1743. }
  1744. .shoppop {
  1745. padding: 22rpx 16rpx;
  1746. .shoppop-top {
  1747. display: flex;
  1748. justify-content: space-between;
  1749. align-items: center;
  1750. padding: 0 16rpx 22rpx;
  1751. .search-input {
  1752. width: 414rpx;
  1753. height: 76rpx;
  1754. background: #FFFFFF;
  1755. border-radius: 36rpx;
  1756. margin-left: 20rpx;
  1757. padding: 0 32rpx;
  1758. box-sizing: border-box;
  1759. font-size: 24rpx;
  1760. margin-right: 24rpx;
  1761. }
  1762. .search-top {
  1763. font-size: 20rpx;
  1764. color: #222222;
  1765. }
  1766. }
  1767. .shop-list {
  1768. overflow: hidden;
  1769. .list-item {
  1770. display: flex;
  1771. align-items: center;
  1772. padding: 20rpx 16rpx;
  1773. background: #FFFFFF;
  1774. border-radius: 16rpx;
  1775. margin-bottom: 16rpx;
  1776. .goods-img {
  1777. width: 200rpx;
  1778. height: 200rpx;
  1779. border-radius: 16rpx;
  1780. overflow: hidden;
  1781. position: relative;
  1782. margin-right: 24rpx;
  1783. image {
  1784. width: 100%;
  1785. height: 100%;
  1786. }
  1787. .goods-label {
  1788. position: absolute;
  1789. top: 0;
  1790. width: 64rpx;
  1791. height: 40rpx;
  1792. background: rgba(0, 0, 0, 0.5);
  1793. border-radius: 16rpx 0rpx 16rpx 0rpx;
  1794. text-align: center;
  1795. font-weight: 500;
  1796. font-size: 28rpx;
  1797. color: #FFFFFF;
  1798. }
  1799. }
  1800. .goods-right {
  1801. flex: 1;
  1802. .goods-title {
  1803. font-weight: 500;
  1804. font-size: 30rpx;
  1805. color: #000000;
  1806. margin-bottom: 10rpx;
  1807. }
  1808. .goods-details {
  1809. font-size: 24rpx;
  1810. color: #999999;
  1811. margin: 10rpx 0 20rpx;
  1812. }
  1813. .goods-people {
  1814. font-size: 22rpx;
  1815. color: #E69A22;
  1816. height: 56rpx;
  1817. }
  1818. .goods-shop {
  1819. display: flex;
  1820. justify-content: space-between;
  1821. .nummber {
  1822. color: #FF5C03;
  1823. font-size: 22rpx;
  1824. font-weight: 500;
  1825. }
  1826. .btn-group {
  1827. text-align: center;
  1828. line-height: 56rpx;
  1829. .collect-btn {
  1830. width: 72rpx;
  1831. background: #F5F7FA;
  1832. border-radius: 8rpx 0rpx 0rpx 8rpx;
  1833. }
  1834. .shop-btn {
  1835. width: 152rpx;
  1836. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  1837. border-radius: 0rpx 8rpx 8rpx 0rpx;
  1838. font-weight: 500;
  1839. font-size: 30rpx;
  1840. color: #FFFFFF;
  1841. }
  1842. }
  1843. }
  1844. }
  1845. }
  1846. }
  1847. }
  1848. :deep(.u-list-item) {
  1849. width: 100%;
  1850. display: flex;
  1851. align-items: center;
  1852. }
  1853. :deep(.u-safe-area-inset-bottom) {
  1854. padding-bottom: 0
  1855. }
  1856. </style>