list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <view class="content">
  3. <view class="info">
  4. <image class="info-bg" src="/static/images/live_broadcast_bg.png"></image>
  5. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  6. <view class="shop-block">
  7. <view class="shop">
  8. <image class="w40 h40" src="/static/images/shopping_car.png"></image>
  9. </view>
  10. </view>
  11. <view class="vedio-block">
  12. <view class="top">
  13. <view class="tab-wrapper">
  14. <!-- 直播 -->
  15. <view class="tab-item" :class="{ active: activeTab === 0 }" @click="switchTab(0)">
  16. <text class="tab-text">直播中</text>
  17. <image class="line" v-if="activeTab === 0" src="/static/images/header_tabs_icon.png"
  18. alt="" />
  19. </view>
  20. <!-- 直播预告-->
  21. <view class="tab-item" :class="{ active: activeTab === 1 }" @click="switchTab(1)">
  22. <text class="tab-text">直播预告</text>
  23. <image class="line" v-if="activeTab === 1" src="/static/images/header_tabs_icon.png"
  24. alt="" />
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 视频文章列表 -->
  29. <mescroll-body bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  30. :down="downOption" :up="upOption">
  31. <view class="list" v-if="activeTab === 0">
  32. <view class="list-item" @click="goLive(item)" v-for="(item,index) in list" :key="index">
  33. <image class="img" v-if="item.liveImgUrl" :src="item.liveImgUrl" mode="widthFix"></image>
  34. <!-- 重庆 · 优选标签 -->
  35. <view class="lable">
  36. <view class="play-lable">
  37. <image class="icon" src="/static/images/play.gif"></image>
  38. </view>
  39. <view class="place-label">
  40. 重庆 · 优选
  41. </view>
  42. </view>
  43. <!-- 直播中标签 -->
  44. <view class="live-lable" v-if="false">
  45. <image class="icon" src="/static/images/play.gif"></image>
  46. <text>直播中</text>
  47. </view>
  48. <view class="info-block">
  49. <view class="title ellipsis2">冰乳绿豆糕 冰冰凉凉谁吃谁迷糊! 谁懂,...冰乳绿豆糕 冰冰凉凉谁吃谁迷糊!</view>
  50. <view class="item">
  51. <view class="flex">
  52. <image class="head" src="/static/images/img.png"></image>
  53. <text class="name">崔医生</text>
  54. </view>
  55. <view class="flex">
  56. <image class="icon" src="/static/images/watch_number_icon.png"></image>
  57. <text>141</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="list" v-if="activeTab === 1">
  64. <view class="list-item2" @click="goLive(item)" v-for="(item,index) in list" :key="index">
  65. <view class="img-box">
  66. <view class="time-block">
  67. <view class="date">9/11</view>
  68. <view class="time">20:00开播</view>
  69. </view>
  70. <image class="img" v-if="item.liveImgUrl" :src="item.liveImgUrl">
  71. </image>
  72. </view>
  73. <!-- <image class="video-icon" src="/static/images/video_icon.png"></image> -->
  74. <view class="info-block">
  75. <view class="title ellipsis2">冰乳绿豆糕 冰冰凉凉谁吃谁迷糊! 谁懂,...冰乳绿豆糕 冰冰凉凉谁吃谁迷糊!冰乳绿豆糕 冰冰凉凉谁吃谁迷糊!
  76. </view>
  77. <view class="shop-item">
  78. <image class="head" src="/static/images/img.png"></image>
  79. <text class="name">芳华悦选旗舰店</text>
  80. </view>
  81. <view class="item">
  82. <view class="flex">
  83. <image class="icon" src="/static/images/reservation_icon.png"></image>
  84. <text class="name">245人已预约</text>
  85. </view>
  86. <view class="button">预约</view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </mescroll-body>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import {
  98. liveList
  99. } from '@/api/living.js'
  100. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  101. export default {
  102. mixins: [MescrollMixin],
  103. data() {
  104. return {
  105. activeTab: 0,
  106. // 状态栏的高度
  107. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  108. list: [],
  109. downOption: {
  110. offset: 80,
  111. use: true,
  112. auto: false
  113. },
  114. upOption: {
  115. use: true,
  116. auto: true,
  117. page: {
  118. num: 0,
  119. size: 10
  120. }
  121. },
  122. mescroll: null,
  123. }
  124. },
  125. onLoad() {
  126. // if (!uni.getStorageSync("AppToken")) {
  127. // uni.navigateTo({
  128. // url: '/pages/auth/login'
  129. // });
  130. // }
  131. },
  132. onUnload() {
  133. },
  134. methods: {
  135. switchTab(tab) {
  136. if (this.activeTab === tab) return;
  137. this.activeTab = tab;
  138. this.$emit('change', tab);
  139. },
  140. mescrollInit(mescroll) {
  141. this.mescroll = mescroll;
  142. },
  143. // 下拉刷新回调
  144. downCallback(mescroll) {
  145. this.list = [];
  146. mescroll.resetUpScroll();
  147. },
  148. // 上拉加载回调
  149. upCallback(mescroll) {
  150. const pageNum = mescroll.num;
  151. const pageSize = mescroll.size;
  152. let data = {
  153. pageSize: pageSize,
  154. pageNum: pageNum,
  155. }
  156. liveList(data).then(res => {
  157. if (!res) {
  158. mescroll.endErr();
  159. return;
  160. }
  161. if (res.code == 200) {
  162. let curPageData = Array.isArray(res.data.list) ? res.data.list : [];
  163. let totalSize = Number(res.data.total) || 0;
  164. if (pageNum === 1) {
  165. this.list = [];
  166. }
  167. this.list = this.list.concat(curPageData);
  168. mescroll.endBySize(curPageData.length, totalSize);
  169. } else {
  170. mescroll.endErr();
  171. uni.showToast({
  172. title: res.msg,
  173. icon: 'none'
  174. });
  175. }
  176. }).catch(err => {
  177. mescroll.endErr();
  178. });
  179. },
  180. goLive(item) {
  181. uni.navigateTo({
  182. url: `./living?liveId=${item.liveId}`
  183. });
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .ellipsis2 {
  190. display: -webkit-box;
  191. -webkit-box-orient: vertical;
  192. -webkit-line-clamp: 2;
  193. overflow: hidden;
  194. word-break: break-all;
  195. }
  196. .content {
  197. background: #F5F7FA;
  198. min-height: 100vh;
  199. .info {
  200. width: 100%;
  201. height: 600rpx;
  202. position: relative;
  203. z-index: 0;
  204. .shop-block {
  205. display: flex;
  206. justify-content: flex-end;
  207. .shop {
  208. width: 64rpx;
  209. height: 64rpx;
  210. padding: 12rpx;
  211. margin-right: 210rpx;
  212. border-radius: 32rpx 32rpx 32rpx 32rpx;
  213. border: 1rpx solid #E9E9E9;
  214. box-sizing: border-box;
  215. background: #FFFFFF;
  216. }
  217. }
  218. .info-bg {
  219. position: absolute;
  220. z-index: -1;
  221. width: 100%;
  222. height: 100%;
  223. }
  224. .data-block {
  225. padding: 0 20rpx;
  226. margin-top: 30rpx;
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. .number-block {
  231. display: flex;
  232. .item {
  233. margin-right: 32rpx;
  234. display: flex;
  235. flex-direction: column;
  236. align-items: center;
  237. .number-item {
  238. font-family: Roboto, Roboto;
  239. font-weight: 600;
  240. font-size: 36rpx;
  241. color: #FFFFFF;
  242. }
  243. .txt-item {
  244. margin-top: 6rpx;
  245. font-size: 26rpx;
  246. color: rgba(255, 255, 255, 0.7);
  247. }
  248. }
  249. }
  250. .button {
  251. width: 144rpx;
  252. height: 56rpx;
  253. background: #FFFFFF;
  254. border-radius: 28rpx 28rpx 28rpx 28rpx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. font-size: 24rpx;
  259. color: #02B176;
  260. .icon {
  261. width: 24rpx;
  262. height: 24rpx;
  263. margin-right: 4rpx;
  264. }
  265. }
  266. }
  267. .shop-icon {
  268. display: flex;
  269. justify-content: flex-end;
  270. margin: 12rpx 210rpx 0 0;
  271. }
  272. //视频
  273. .vedio-block {
  274. position: relative;
  275. z-index: 1;
  276. padding: 26rpx 0;
  277. .top {
  278. display: flex;
  279. }
  280. .tab-wrapper {
  281. display: flex;
  282. height: 88rpx;
  283. padding: 0 40rpx;
  284. position: relative;
  285. .tab-item {
  286. display: flex;
  287. flex-direction: column;
  288. align-items: center;
  289. justify-content: center;
  290. position: relative;
  291. font-size: 32rpx;
  292. color: #333333;
  293. margin-right: 44rpx;
  294. &.active {
  295. font-weight: 600;
  296. font-size: 40rpx;
  297. }
  298. .tab-text {
  299. font-size: 32rpx;
  300. transition: all 0.3s ease;
  301. }
  302. .line {
  303. width: 68rpx;
  304. height: 28rpx;
  305. position: absolute;
  306. top: 44rpx;
  307. z-index: -1;
  308. }
  309. }
  310. }
  311. .icon {
  312. display: flex;
  313. justify-content: flex-end;
  314. }
  315. @keyframes slideIn {
  316. from {
  317. opacity: 0;
  318. transform: translateX(-50%) scaleX(0.5);
  319. }
  320. to {
  321. opacity: 1;
  322. transform: translateX(-50%) scaleX(1);
  323. }
  324. }
  325. .list {
  326. padding: 24rpx 24rpx;
  327. display: flex;
  328. justify-content: space-between;
  329. flex-wrap: wrap;
  330. .list-item {
  331. width: 342rpx;
  332. margin-bottom: 18rpx;
  333. position: relative;
  334. display: flex;
  335. flex-direction: column;
  336. border-radius: 16rpx 16rpx 16rpx 16rpx;
  337. .lable {
  338. position: absolute;
  339. left: 16rpx;
  340. top: 16rpx;
  341. display: flex;
  342. text-align: center;
  343. border-radius: 6rpx 6rpx 6rpx 6rpx;
  344. overflow: hidden;
  345. .play-lable {
  346. width: 40rpx;
  347. height: 40rpx;
  348. line-height: 40rpx;
  349. font-size: 20rpx;
  350. color: #FFFFFF;
  351. background: linear-gradient(136deg, #38D97D 0%, #02B176 100%);
  352. display: flex;
  353. justify-content: center;
  354. align-items: center;
  355. .icon {
  356. width: 24rpx;
  357. height: 24rpx;
  358. }
  359. }
  360. .place-label {
  361. width: 106rpx;
  362. height: 40rpx;
  363. background: rgba(0, 0, 0, 0.6);
  364. line-height: 40rpx;
  365. font-size: 20rpx;
  366. color: #FFFFFF;
  367. }
  368. }
  369. .live-lable {
  370. position: absolute;
  371. left: 16rpx;
  372. top: 16rpx;
  373. display: flex;
  374. width: 104rpx;
  375. height: 40rpx;
  376. background: #FA341E;
  377. align-items: center;
  378. justify-content: center;
  379. border-radius: 6rpx 6rpx 6rpx 6rpx;
  380. font-size: 20rpx;
  381. color: #FFFFFF;
  382. .icon {
  383. width: 24rpx;
  384. height: 24rpx;
  385. margin-right: 4rpx;
  386. }
  387. }
  388. .img {
  389. width: 100%;
  390. border-radius: 16rpx 16rpx 0rpx 0rpx;
  391. }
  392. .info-block {
  393. border-radius: 0rpx 0rpx 16rpx 16rpx;
  394. padding: 12rpx 20rpx 20rpx;
  395. box-sizing: border-box;
  396. width: 100%;
  397. background: #FFFFFF;
  398. display: flex;
  399. flex-direction: column;
  400. .title {
  401. font-weight: 500;
  402. font-size: 28rpx;
  403. color: #333333;
  404. margin-bottom: 20rpx;
  405. }
  406. .item {
  407. display: flex;
  408. justify-content: space-between;
  409. align-items: center;
  410. margin-bottom: 20rpx;
  411. .flex {
  412. display: flex;
  413. align-items: center;
  414. font-size: 22rpx;
  415. color: #999999;
  416. }
  417. .icon {
  418. width: 32rpx;
  419. height: 32rpx;
  420. margin-right: 4rpx;
  421. }
  422. .head {
  423. width: 32rpx;
  424. height: 32rpx;
  425. border-radius: 50%;
  426. margin-right: 8rpx;
  427. }
  428. .name {
  429. color: #757575;
  430. }
  431. }
  432. text {
  433. white-space: nowrap;
  434. overflow: hidden;
  435. text-overflow: ellipsis;
  436. }
  437. }
  438. }
  439. .list-item2 {
  440. width: 100%;
  441. margin-bottom: 18rpx;
  442. position: relative;
  443. display: flex;
  444. align-items: center;
  445. justify-content: space-between;
  446. margin-bottom: 20rpx;
  447. border-radius: 16rpx 16rpx 16rpx 16rpx;
  448. background: #ffffff;
  449. padding: 24rpx;
  450. .img-box {
  451. position: relative;
  452. width: 280rpx;
  453. height: 220rpx;
  454. overflow: hidden;
  455. flex-shrink: 0;
  456. border-radius: 16rpx 16rpx 16rpx 16rpx;
  457. margin-right: 24rpx;
  458. .time-block {
  459. position: absolute;
  460. left: 16rpx;
  461. top: 16rpx;
  462. display: flex;
  463. text-align: center;
  464. border-radius: 6rpx 6rpx 6rpx 6rpx;
  465. overflow: hidden;
  466. .date {
  467. width: 56rpx;
  468. height: 40rpx;
  469. line-height: 40rpx;
  470. font-size: 20rpx;
  471. color: #FFFFFF;
  472. background: #F4A007;
  473. }
  474. .time {
  475. width: 110rpx;
  476. height: 40rpx;
  477. background: rgba(0, 0, 0, 0.6);
  478. line-height: 40rpx;
  479. font-size: 20rpx;
  480. color: #FFFFFF;
  481. }
  482. }
  483. .img {
  484. width: 100%;
  485. height: 100%;
  486. }
  487. }
  488. .info-block {
  489. padding: 12rpx 20rpx 20rpx;
  490. box-sizing: border-box;
  491. width: 100%;
  492. display: flex;
  493. flex-direction: column;
  494. .title {
  495. font-weight: 500;
  496. font-size: 32rpx;
  497. color: #333333;
  498. margin-bottom: 12rpx;
  499. }
  500. .shop-item {
  501. display: flex;
  502. font-size: 24rpx;
  503. color: #666666;
  504. align-items: center;
  505. margin-bottom: 34rpx;
  506. .icon {
  507. width: 32rpx;
  508. height: 32rpx;
  509. margin-right: 12rpx;
  510. }
  511. .head {
  512. width: 32rpx;
  513. height: 32rpx;
  514. border-radius: 50%;
  515. margin-right: 8rpx;
  516. }
  517. .name {
  518. color: #757575;
  519. }
  520. }
  521. .item {
  522. display: flex;
  523. justify-content: space-between;
  524. align-items: center;
  525. font-size: 22rpx;
  526. color: #999999;
  527. .flex {
  528. display: flex;
  529. align-items: center;
  530. }
  531. .icon {
  532. width: 24rpx;
  533. height: 24rpx;
  534. margin-right: 8rpx;
  535. }
  536. .button {
  537. width: 136rpx;
  538. height: 64rpx;
  539. background: linear-gradient(136deg, #38D97D 0%, #02B176 100%);
  540. border-radius: 32rpx 32rpx 32rpx 32rpx;
  541. font-weight: 500;
  542. font-size: 28rpx;
  543. color: #FFFFFF;
  544. text-align: center;
  545. line-height: 64rpx;
  546. }
  547. .name {
  548. color: #757575;
  549. }
  550. }
  551. text {
  552. white-space: nowrap;
  553. overflow: hidden;
  554. text-overflow: ellipsis;
  555. }
  556. }
  557. }
  558. .list-item:nth-child(2n) {
  559. margin-right: 0;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. </style>