living.vue 57 KB

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