living.vue 56 KB

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