living.vue 56 KB

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