living.vue 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109
  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. } else if (redata.data.cmd == 'live_start') {
  1387. // 直播开始
  1388. } else if (redata.data.cmd == 'live_end') {
  1389. // 直播结束
  1390. }
  1391. } catch (e) {
  1392. console.error('解析消息失败:', e);
  1393. }
  1394. })
  1395. },
  1396. scheduleReconnect() {
  1397. if (this.isManualClose || this.reconnectCount >= this.maxReconnectAttempts) return;
  1398. this.reconnectCount++;
  1399. const delay = Math.min(3000 * this.reconnectCount, 30000);
  1400. console.log(`将在 ${delay}ms 后重连 (尝试 ${this.reconnectCount}/${this.maxReconnectAttempts})`);
  1401. this.reconnectTimer = setTimeout(() => {
  1402. this.initSocket();
  1403. }, delay);
  1404. },
  1405. sendMsg() {
  1406. if (!isSocketOpen) {
  1407. uni.showToast({
  1408. title: "连接未建立,请稍后再试",
  1409. icon: 'none'
  1410. });
  1411. return;
  1412. }
  1413. if (!this.socketInstance) {
  1414. uni.showToast({
  1415. title: "连接异常",
  1416. icon: 'none'
  1417. });
  1418. return;
  1419. }
  1420. const data = {
  1421. liveId: this.liveId,
  1422. userId: this.userinfo.userId,
  1423. userType: 0,
  1424. cmd: "sendMsg",
  1425. msg: this.value,
  1426. nickName: this.userinfo.nickName,
  1427. avatar: this.userinfo.avatar
  1428. };
  1429. if (!this.value.trim()) { // 优化空消息判断
  1430. uni.showToast({
  1431. title: "不能发送空消息",
  1432. icon: 'none'
  1433. });
  1434. return;
  1435. }
  1436. // 使用正确的实例 this.socketInstance 发送消息
  1437. this.socketInstance.send({
  1438. data: JSON.stringify(data),
  1439. success: () => {
  1440. console.log("发送成功");
  1441. this.value = ''; // 清空输入框
  1442. },
  1443. fail: (err) => {
  1444. console.error("发送失败:", err);
  1445. uni.showToast({
  1446. title: "发送失败,请重试",
  1447. icon: 'none'
  1448. });
  1449. }
  1450. });
  1451. },
  1452. },
  1453. };
  1454. </script>
  1455. <style scoped lang="scss">
  1456. .loading-more,
  1457. .no-more {
  1458. display: flex;
  1459. justify-content: center;
  1460. align-items: center;
  1461. padding: 20rpx 0;
  1462. color: #999;
  1463. font-size: 24rpx;
  1464. }
  1465. .loading-more {
  1466. flex-direction: column;
  1467. }
  1468. /* button自带样式清除 */
  1469. .student-orther-icon button::after {
  1470. border: none !important;
  1471. padding: 0 !important;
  1472. margin: 0 !important;
  1473. }
  1474. .student-orther-icon button {
  1475. background-color: transparent !important;
  1476. padding: 0 !important;
  1477. line-height: inherit !important;
  1478. margin: 0 !important;
  1479. width: auto !important;
  1480. font-weight: 500 !important;
  1481. border-radius: none !important;
  1482. }
  1483. // 抽奖
  1484. // .answerpop {
  1485. // background: linear-gradient(to right, #fff7f8, #fee1e2);
  1486. // margin-top: 30rpx;
  1487. // padding: 10rpx 20rpx;
  1488. // width: calc(100% - 40rpx);
  1489. // border-radius: 20rpx;
  1490. // display: flex;
  1491. // align-items: center;
  1492. // justify-content: space-between;
  1493. // box-shadow: 2px 2px 4px 0 rgba(255, 124, 126, 0.1);
  1494. // .answera {
  1495. // display: flex;
  1496. // justify-content: center;
  1497. // background-color: #fff;
  1498. // padding: 20rpx 0;
  1499. // width: 35%;
  1500. // border-radius: 40rpx;
  1501. // align-items: center;
  1502. // margin: 10rpx 0;
  1503. // box-shadow: 2px 2px 4px 0 rgba(72, 72, 72, 0.1);
  1504. // image {
  1505. // width: 40rpx;
  1506. // height: 40rpx;
  1507. // margin-right: 10rpx;
  1508. // }
  1509. // }
  1510. // }
  1511. // .submitbtn {
  1512. // width: 260rpx;
  1513. // margin: 0 auto;
  1514. // text-align: center;
  1515. // border-radius: 80rpx;
  1516. // padding: 20rpx 0;
  1517. // color: #fff;
  1518. // background-color: #ff5c03;
  1519. // }
  1520. // .itemanswer {
  1521. // padding: 20rpx 20rpx;
  1522. // text-align: center;
  1523. // border-radius: 80rpx;
  1524. // border: 2rpx solid #dddddd;
  1525. // margin: 12rpx 0;
  1526. // color: #555;
  1527. // width: calc(100% - 40rpx);
  1528. // }
  1529. // .answeract {
  1530. // background-color: rgba(0, 202, 166, 1);
  1531. // color: #fff;
  1532. // }
  1533. // .answerbox {
  1534. // width: 600rpx;
  1535. // border-radius: 20rpx;
  1536. // }
  1537. .welcome-message {
  1538. position: fixed;
  1539. width: 100%;
  1540. bottom: 120rpx;
  1541. left: 50%;
  1542. transform: translateX(-50%);
  1543. color: white;
  1544. padding: 10px 20px;
  1545. border-radius: 20px;
  1546. animation: fadeOut 1s ease 1s forwards;
  1547. z-index: 1000;
  1548. }
  1549. @keyframes fadeOut {
  1550. from {
  1551. opacity: 1;
  1552. }
  1553. to {
  1554. opacity: 0;
  1555. }
  1556. }
  1557. // .container {
  1558. // position: relative;
  1559. // width: 100%;
  1560. // height: 100vh;
  1561. // overflow: hidden;
  1562. // }
  1563. // .talktext {
  1564. // border-radius: 8rpx;
  1565. // background-color: rgba(255, 255, 255, 0.1);
  1566. // view {
  1567. // width: 100%;
  1568. // }
  1569. // }
  1570. .talk-list {
  1571. border-radius: 30rpx;
  1572. background-color: rgba(33, 33, 33, 0.5);
  1573. padding: 10rpx 30rpx;
  1574. }
  1575. // .zoom-button-active {
  1576. // transform: scale(1.5);
  1577. // }
  1578. // .background-image {
  1579. // position: absolute;
  1580. // top: 0;
  1581. // left: -40rpx;
  1582. // width: 110%;
  1583. // height: 110%;
  1584. // object-fit: cover;
  1585. // filter: blur(20px);
  1586. // z-index: 0;
  1587. // }
  1588. // .background-images {
  1589. // position: absolute;
  1590. // top: 0;
  1591. // left: -40rpx;
  1592. // width: 110%;
  1593. // height: 110%;
  1594. // object-fit: cover;
  1595. // filter: blur(20px);
  1596. // z-index: 6;
  1597. // }
  1598. // .blackbg {
  1599. // position: absolute;
  1600. // top: 0;
  1601. // left: 0;
  1602. // width: 100%;
  1603. // height: 100%;
  1604. // background: rgba(0, 0, 0, 0.7);
  1605. // object-fit: cover;
  1606. // filter: blur(10px);
  1607. // z-index: 1;
  1608. // }
  1609. .content {
  1610. position: relative;
  1611. z-index: 2;
  1612. height: 100%;
  1613. width: 100%;
  1614. top: 0;
  1615. left: 0;
  1616. display: flex;
  1617. flex-direction: column;
  1618. justify-content: space-between;
  1619. .content-top {
  1620. width: 100%;
  1621. margin-top: 150rpx;
  1622. display: flex;
  1623. align-items: center;
  1624. justify-content: space-between;
  1625. padding: 0 24rpx;
  1626. box-sizing: border-box;
  1627. .sum {
  1628. width: 80rpx;
  1629. height: 52rpx;
  1630. background: rgba(0, 0, 0, 0.5);
  1631. border-radius: 26rpx 26rpx 26rpx 26rpx;
  1632. font-size: 24rpx;
  1633. color: #FFFFFF;
  1634. text-align: center;
  1635. line-height: 52rpx;
  1636. }
  1637. }
  1638. .follow-btn {
  1639. padding: 8rpx 16rpx;
  1640. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  1641. border-radius: 26rpx;
  1642. font-weight: 500;
  1643. font-size: 26rpx;
  1644. color: #FFFFFF;
  1645. }
  1646. }
  1647. .videolist {
  1648. position: relative;
  1649. }
  1650. .video {
  1651. height: 100vh;
  1652. /* 占屏幕高度的80% */
  1653. width: 100%;
  1654. background-color: rgba(0, 0, 0, 0.8);
  1655. }
  1656. .videotop {
  1657. width: 100%;
  1658. height: 100%;
  1659. }
  1660. .video_row {
  1661. width: 100%;
  1662. max-height: 500rpx;
  1663. overflow: hidden;
  1664. margin-top: 360rpx;
  1665. }
  1666. .popup-video {
  1667. position: absolute;
  1668. top: 30%;
  1669. height: 500rpx;
  1670. display: flex;
  1671. flex-direction: column;
  1672. align-items: center;
  1673. justify-content: center;
  1674. width: 100%;
  1675. color: #fff;
  1676. z-index: 9;
  1677. .more {
  1678. background-color: #3280fe;
  1679. border-radius: 80rpx;
  1680. width: 280rpx;
  1681. text-align: center;
  1682. height: 60rpx;
  1683. line-height: 60rpx;
  1684. }
  1685. }
  1686. .icon-bg {
  1687. background-color: rgba(157, 157, 157, 0.8);
  1688. border-radius: 50%;
  1689. width: 72rpx;
  1690. height: 72rpx;
  1691. display: flex;
  1692. justify-content: center;
  1693. align-items: center;
  1694. transition: transform 0.2s ease;
  1695. }
  1696. .list {
  1697. width: 80%;
  1698. margin-bottom: 20rpx;
  1699. animation: xxxawdawd .2s;
  1700. }
  1701. @keyframes xxxawdawd {
  1702. from {
  1703. margin-top: 0rpx;
  1704. opacity: 0;
  1705. }
  1706. to {
  1707. margin-top: 20rpx;
  1708. opacity: 1;
  1709. }
  1710. }
  1711. .shop-prompt {
  1712. position: absolute;
  1713. bottom: 600rpx;
  1714. left: 24rpx;
  1715. padding: 6rpx 20rpx;
  1716. background: rgba(230, 154, 34, 0.7);
  1717. border-radius: 24rpx;
  1718. z-index: 9;
  1719. font-weight: 500;
  1720. font-size: 26rpx;
  1721. color: #FFFFFF;
  1722. transition: opacity 0.3s ease;
  1723. }
  1724. .siderow-group {
  1725. position: absolute;
  1726. top: 56%;
  1727. right: 50rpx;
  1728. z-index: 9;
  1729. display: flex;
  1730. flex-direction: column;
  1731. align-items: center;
  1732. .side-item {
  1733. font-weight: 500;
  1734. font-size: 24rpx;
  1735. color: #FFFFFF;
  1736. margin-bottom: 32rpx;
  1737. text-align: center;
  1738. button {
  1739. background-color: transparent;
  1740. margin: 0;
  1741. line-height: 1;
  1742. padding: 0;
  1743. }
  1744. image {
  1745. width: 72rpx;
  1746. height: 72rpx;
  1747. }
  1748. }
  1749. }
  1750. .side-group {
  1751. position: absolute;
  1752. // top: 30%;
  1753. top: 56%;
  1754. right: 50rpx;
  1755. z-index: 9;
  1756. display: flex;
  1757. flex-direction: column;
  1758. align-items: center;
  1759. .side-item {
  1760. font-weight: 500;
  1761. font-size: 24rpx;
  1762. color: #FFFFFF;
  1763. margin-bottom: 32rpx;
  1764. text-align: center;
  1765. button {
  1766. background-color: transparent;
  1767. margin: 0;
  1768. line-height: 1;
  1769. padding: 0;
  1770. }
  1771. image {
  1772. width: 72rpx;
  1773. height: 72rpx;
  1774. }
  1775. }
  1776. }
  1777. .red-box {
  1778. .button {
  1779. margin: 0 auto;
  1780. width: 80%;
  1781. line-height: 88rpx;
  1782. height: 88rpx;
  1783. background: linear-gradient(90deg, #FF5701 0%, #FFB501 100%);
  1784. box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(238, 124, 80, 0.2);
  1785. border-radius: 44rpx 44rpx 44rpx 44rpx;
  1786. font-weight: 600;
  1787. font-size: 32rpx;
  1788. color: #FFFFFF;
  1789. text-align: center;
  1790. }
  1791. }
  1792. .view-box {
  1793. position: relative;
  1794. height: 40vh;
  1795. /* 设置弹出层高度为视窗高度的70% */
  1796. padding: 40rpx 0rpx 120rpx;
  1797. box-sizing: border-box;
  1798. display: flex;
  1799. flex-direction: column;
  1800. .scroll-content {
  1801. flex: 1;
  1802. overflow-y: auto;
  1803. padding: 0 40rpx;
  1804. }
  1805. .bottom {
  1806. padding: 20rpx 40rpx;
  1807. position: absolute;
  1808. bottom: 0;
  1809. width: 100%;
  1810. box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(195, 195, 195, 0.3);
  1811. background: #fff;
  1812. }
  1813. }
  1814. .shoppop {
  1815. padding: 22rpx 16rpx;
  1816. .shoppop-top {
  1817. display: flex;
  1818. justify-content: space-between;
  1819. align-items: center;
  1820. padding: 0 16rpx 22rpx;
  1821. .search-input {
  1822. width: 414rpx;
  1823. height: 76rpx;
  1824. background: #FFFFFF;
  1825. border-radius: 36rpx;
  1826. margin-left: 20rpx;
  1827. padding: 0 32rpx;
  1828. box-sizing: border-box;
  1829. font-size: 24rpx;
  1830. margin-right: 24rpx;
  1831. }
  1832. .search-top {
  1833. font-size: 18rpx;
  1834. color: #222222;
  1835. }
  1836. }
  1837. .shop-list {
  1838. overflow: hidden;
  1839. .list-item {
  1840. display: flex;
  1841. align-items: center;
  1842. padding: 20rpx 16rpx;
  1843. background: #FFFFFF;
  1844. border-radius: 16rpx;
  1845. margin-bottom: 16rpx;
  1846. .goods-img {
  1847. width: 200rpx;
  1848. height: 200rpx;
  1849. border-radius: 16rpx;
  1850. overflow: hidden;
  1851. position: relative;
  1852. margin-right: 24rpx;
  1853. image {
  1854. width: 100%;
  1855. height: 100%;
  1856. }
  1857. .goods-label {
  1858. position: absolute;
  1859. top: 0;
  1860. width: 64rpx;
  1861. height: 40rpx;
  1862. background: rgba(0, 0, 0, 0.5);
  1863. border-radius: 16rpx 0rpx 16rpx 0rpx;
  1864. text-align: center;
  1865. font-weight: 500;
  1866. font-size: 28rpx;
  1867. color: #FFFFFF;
  1868. }
  1869. }
  1870. .goods-right {
  1871. flex: 1;
  1872. .goods-title {
  1873. font-weight: 500;
  1874. font-size: 28rpx;
  1875. color: #000000;
  1876. }
  1877. .goods-details {
  1878. font-size: 24rpx;
  1879. color: #999999;
  1880. margin: 10rpx 0 20rpx;
  1881. }
  1882. .goods-people {
  1883. font-size: 22rpx;
  1884. color: #E69A22;
  1885. height: 56rpx;
  1886. }
  1887. .goods-shop {
  1888. display: flex;
  1889. justify-content: space-between;
  1890. .nummber {
  1891. color: #FF5C03;
  1892. font-size: 22rpx;
  1893. font-weight: 500;
  1894. }
  1895. .btn-group {
  1896. text-align: center;
  1897. line-height: 56rpx;
  1898. .collect-btn {
  1899. width: 72rpx;
  1900. background: #F5F7FA;
  1901. border-radius: 8rpx 0rpx 0rpx 8rpx;
  1902. }
  1903. .shop-btn {
  1904. width: 152rpx;
  1905. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  1906. border-radius: 0rpx 8rpx 8rpx 0rpx;
  1907. font-weight: 500;
  1908. font-size: 26rpx;
  1909. color: #FFFFFF;
  1910. }
  1911. }
  1912. }
  1913. }
  1914. }
  1915. }
  1916. }
  1917. :deep(.u-list-item) {
  1918. width: 100%;
  1919. display: flex;
  1920. align-items: center;
  1921. }
  1922. :deep(.u-safe-area-inset-bottom) {
  1923. padding-bottom: 0
  1924. }
  1925. </style>