living.vue 57 KB

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