alive.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <view class="">
  3. <!-- #ifdef H5 -->
  4. <view class="live" v-if="isIframe">
  5. <view v-if="isIframe && liveList.length>0">
  6. <view class="title-box" v-if="titleInfo.length">
  7. <text class="title">{{$t(titleInfo[0].val)}}</text>
  8. <navigator class="more">{{$t(`查看更多`)}}<text class="iconfont icon-jiantou"></text></navigator>
  9. </view>
  10. <view class="live-wrapper-a">
  11. <navigator class="live-item-a" v-for="(item,index) in liveList" :key="index"
  12. :url="'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.room_id+'&custom_params='+custom_params"
  13. hover-class="none">
  14. <view class="img-box">
  15. <view class="bgblue" v-if="item.live_status == 102">
  16. <view class="txt">{{$t(`预告`)}}</view>
  17. <view class="msg">{{item.show_time}}</view>
  18. </view>
  19. <view class="label bggary" v-if="item.live_status==103">
  20. <text class="iconfont icon-huifang"></text>
  21. <text>{{$t(`回放`)}}</text>
  22. </view>
  23. <view class="label bgred" v-if="item.live_status==101">
  24. <text class="iconfont icon-zhibozhong"></text>
  25. <text>{{$t(`进行中`)}}</text>
  26. </view>
  27. <image :src="item.share_img"></image>
  28. </view>
  29. <view class="info">
  30. <view class="title line1">{{$t(item.name)}}</view>
  31. <!-- <view class="people">
  32. <image :src="item.anchor_img" alt="">
  33. <text>{{item.anchor_name}}</text>
  34. </view> -->
  35. <!-- <view class="goods-wrapper">
  36. <block v-if="item.goods.length<=3">
  37. <view class="goods-item" v-for="(goods,index) in item.goods" :key="index">
  38. <image :src="goods.cover_img" alt="">
  39. <text class="line1">¥{{goods.price}}</text>
  40. </view>
  41. </block>
  42. <block v-if=" item.goods.length>3">
  43. <view class="goods-item" v-for="(goods,index) in item.goods" :key="index"
  44. v-if="index<2">
  45. <image :src="goods.cover_img" alt="">
  46. <text class="line1">¥{{goods.price}}</text>
  47. </view>
  48. <view class="goods-item">
  49. <image :src="item.goods[item.goods.length-1].cover_img" alt="">
  50. <view class="num">+{{item.goods.length}}</view>
  51. </view>
  52. </block>
  53. <block v-if="item.goods.length == 0">
  54. <view class="empty-goods">暂无商品</view>
  55. </block>
  56. </view> -->
  57. </view>
  58. </navigator>
  59. </view>
  60. </view>
  61. <view v-if="isIframe && !liveList.length">
  62. <view class="title-box" v-if="titleInfo.length">
  63. <text class="title">{{titleInfo[0].val}}</text>
  64. <navigator class="more">{{$t(`查看更多`)}}<text class="iconfont icon-jiantou"></text></navigator>
  65. </view>
  66. <view class="live-wrapper-a">
  67. <view class="empty-img">{{$t(`暂无数据`)}}</view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- #endif -->
  72. <!-- #ifdef MP -->
  73. <view class="live" v-if="isShow && liveList.length>0">
  74. <view class="skeleton-rect">
  75. <view class="title-box" v-if="titleInfo.length">
  76. <view class='text'>
  77. <view class='title line1'>
  78. {{titleInfo[0].val}}
  79. </view>
  80. <view class='line1 txt-btn'>{{$t(`精彩内容`)}}</view>
  81. </view>
  82. <navigator hover-class="none" url="/pages/columnGoods/live_list/index" class="more">{{$t(`更多`)}}<text
  83. class="iconfont icon-jiantou"></text></navigator>
  84. </view>
  85. <view class="live-wrapper-a">
  86. <navigator class="live-item-a" v-for="(item,index) in liveList" :key="index"
  87. :url="'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.room_id+'&custom_params='+custom_params"
  88. hover-class="none">
  89. <view class="img-box">
  90. <view class="bgblue" v-if="item.live_status == 102">
  91. <view class="txt">{{$t(`预告`)}}</view>
  92. <view class="msg">{{item.show_time}}</view>
  93. </view>
  94. <view class="label bggary" v-if="item.live_status==103">
  95. <text class="iconfont icon-huifang"></text>
  96. <text>{{$t(`回放`)}}</text>
  97. </view>
  98. <view class="label bgred" v-if="item.live_status==101">
  99. <text class="iconfont icon-zhibozhong"></text>
  100. <text>{{$t(`进行中`)}}</text>
  101. </view>
  102. <image :src="item.share_img"></image>
  103. </view>
  104. <view class="info">
  105. <view class="title line1">{{item.name}}</view>
  106. <!-- <view class="people">
  107. <image :src="item.anchor_img" alt="">
  108. <text>{{item.anchor_name}}</text>
  109. </view> -->
  110. <!-- <view class="goods-wrapper">
  111. <block v-if="item.goods.length<=3">
  112. <view class="goods-item" v-for="(goods,index) in item.goods" :key="index">
  113. <image :src="goods.cover_img" alt="">
  114. <text class="line1">¥{{goods.price}}</text>
  115. </view>
  116. </block>
  117. <block v-if=" item.goods.length>3">
  118. <view class="goods-item" v-for="(goods,index) in item.goods" :key="index"
  119. v-if="index<2">
  120. <image :src="goods.cover_img" alt="">
  121. <text class="line1">¥{{goods.price}}</text>
  122. </view>
  123. <view class="goods-item">
  124. <image :src="item.goods[item.goods.length-1].cover_img" alt="">
  125. <view class="num">+{{item.goods.length}}</view>
  126. </view>
  127. </block>
  128. <block v-if="item.goods.length == 0">
  129. <view class="empty-goods">暂无商品</view>
  130. </block>
  131. </view> -->
  132. </view>
  133. </navigator>
  134. </view>
  135. </view>
  136. </view>
  137. <!-- #endif -->
  138. </view>
  139. </view>
  140. </template>
  141. <script>
  142. let app = getApp().globalData
  143. import {
  144. getLiveList
  145. } from '@/api/api.js';
  146. export default {
  147. name: 'alive',
  148. props: {
  149. dataConfig: {
  150. type: Object,
  151. default: () => {}
  152. }
  153. },
  154. watch: {
  155. dataConfig: {
  156. immediate: true,
  157. handler(nVal, oVal) {
  158. if (nVal) {
  159. this.numConfig = nVal.numConfig.val;
  160. this.titleInfo = nVal.titleInfo.list;
  161. this.isShow = nVal.isShow.val;
  162. this.getLiveList();
  163. }
  164. }
  165. }
  166. },
  167. data() {
  168. return {
  169. isIframe: false,
  170. liveList: [],
  171. numConfig: 0,
  172. limit: this.$config.LIMIT,
  173. name: this.$options.name,
  174. titleInfo: [],
  175. isShow: true,
  176. custom_params:''
  177. }
  178. },
  179. created() {
  180. this.isIframe = app.isIframe
  181. },
  182. mounted() {
  183. this.custom_params= encodeURIComponent(JSON.stringify({spid:this.$store.state.app.uid}))
  184. },
  185. methods: {
  186. getLiveList: function() {
  187. getLiveList(1, this.numConfig <= this.limit ? this.numConfig : this.limit)
  188. .then(res => {
  189. this.liveList = res.data;
  190. })
  191. .catch(res => {});
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .live {
  198. background-color: $uni-bg-color;
  199. margin: $uni-index-margin-row $uni-index-margin-col 0 $uni-index-margin-col;
  200. border-radius: $uni-border-radius-index;
  201. padding-bottom: 15rpx;
  202. }
  203. .live-wrapper {
  204. position: relative;
  205. width: 100%;
  206. overflow: hidden;
  207. border-radius: 16rpx;
  208. background-color: $uni-bg-color;
  209. image {
  210. width: 100%;
  211. height: 400rpx;
  212. }
  213. .live-top {
  214. z-index: 20;
  215. position: absolute;
  216. left: 0;
  217. top: 0;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. color: #fff;
  222. width: 180rpx;
  223. height: 54rpx;
  224. border-radius: 0rpx 0px 18rpx 0px;
  225. image {
  226. width: 30rpx;
  227. height: 30rpx;
  228. margin-right: 10rpx;
  229. /* #ifdef H5 */
  230. display: block;
  231. /* #endif */
  232. }
  233. }
  234. .live-title {
  235. position: absolute;
  236. left: 0;
  237. bottom: 6rpx;
  238. width: 100%;
  239. height: 70rpx;
  240. line-height: 70rpx;
  241. text-align: center;
  242. font-size: 30rpx;
  243. color: #fff;
  244. background: rgba(0, 0, 0, 0.35);
  245. }
  246. &.mores {
  247. width: 100%;
  248. .item {
  249. position: relative;
  250. width: 320rpx;
  251. display: inline-block;
  252. border-radius: 16rpx;
  253. overflow: hidden;
  254. margin-right: 20rpx;
  255. image {
  256. width: 320rpx;
  257. height: 180rpx;
  258. border-radius: 16rpx;
  259. }
  260. .live-title {
  261. height: 40rpx;
  262. line-height: 40rpx;
  263. text-align: center;
  264. font-size: 22rpx;
  265. }
  266. .live-top {
  267. width: 120rpx;
  268. height: 36rpx;
  269. font-size: 22rpx;
  270. image {
  271. width: 20rpx;
  272. height: 20rpx;
  273. }
  274. }
  275. }
  276. }
  277. }
  278. .live-wrapper-a {
  279. display: flex;
  280. width: 690rpx;
  281. padding: 0rpx 30rpx 0;
  282. overflow-x: scroll;
  283. .live-item-a {
  284. width: 280rpx;
  285. background: #fff;
  286. margin-right: 20rpx;
  287. border-radius: 16rpx;
  288. &:last-child {
  289. margin-right: 20rpx;
  290. }
  291. .img-box {
  292. position: relative;
  293. width: 280rpx;
  294. height: 180rpx;
  295. image {
  296. width: 100%;
  297. height: 100%;
  298. border-radius: 12rpx;
  299. object-fit: cover;
  300. }
  301. }
  302. .info {
  303. flex: 1;
  304. display: flex;
  305. flex-direction: column;
  306. justify-content: space-between;
  307. padding: 15rpx 0rpx;
  308. .title {
  309. font-size: 28rpx;
  310. color: #333;
  311. }
  312. .people {
  313. display: flex;
  314. align-items: center;
  315. color: #999;
  316. font-size: 24rpx;
  317. margin-top: 10rpx;
  318. image {
  319. width: 32rpx;
  320. height: 32rpx;
  321. border-radius: 50%;
  322. margin-right: 10rpx;
  323. }
  324. }
  325. .goods-wrapper {
  326. display: flex;
  327. .goods-item {
  328. position: relative;
  329. width: 96rpx;
  330. height: 96rpx;
  331. margin-right: 20rpx;
  332. overflow: hidden;
  333. border-radius: 16rpx;
  334. &:last-child {
  335. margin-right: 0;
  336. }
  337. image {
  338. width: 100%;
  339. height: 100%;
  340. border-radius: 16rpx;
  341. }
  342. .bg {
  343. position: absolute;
  344. left: 0;
  345. top: 0;
  346. width: 100%;
  347. height: 100%;
  348. border-radius: 16rpx;
  349. background: rgba(0, 0, 0, 0.3);
  350. }
  351. text {
  352. position: absolute;
  353. left: 0;
  354. bottom: 0;
  355. width: 100%;
  356. height: 60rpx;
  357. line-height: 70rpx;
  358. color: #fff;
  359. background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.75) 100%);
  360. }
  361. .num {
  362. display: flex;
  363. align-items: center;
  364. justify-content: center;
  365. position: absolute;
  366. left: 0;
  367. top: 0;
  368. width: 100%;
  369. height: 100%;
  370. background: rgba(0, 0, 0, 0.3);
  371. color: #fff;
  372. font-size: 28rpx;
  373. }
  374. }
  375. }
  376. .empty-goods {
  377. width: 96rpx;
  378. height: 96rpx;
  379. border-radius: 6rpx;
  380. background-color: #B2B2B2;
  381. color: #fff;
  382. font-size: 20rpx;
  383. text-align: center;
  384. line-height: 96rpx;
  385. }
  386. }
  387. }
  388. &.live-wrapper-c {
  389. .live-item-a {
  390. display: flex;
  391. flex-direction: column;
  392. .img-box {
  393. width: 100%;
  394. border-radius: 8px 8px 0 0;
  395. }
  396. .info {
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. flex-direction: initial;
  401. .left {
  402. width: 69%;
  403. }
  404. .goods-wrapper {
  405. flex: 1;
  406. }
  407. }
  408. }
  409. }
  410. }
  411. .text {
  412. display: flex;
  413. align-items: flex-end;
  414. .name {
  415. font-size: 32rpx;
  416. font-weight: bold;
  417. }
  418. .txt-btn {
  419. font-size: 24rpx;
  420. display: flex;
  421. align-items: flex-end;
  422. margin-left: 12rpx;
  423. color: #999;
  424. margin-bottom: 4rpx;
  425. }
  426. }
  427. .live-wrapper-b {
  428. padding: 0rpx 20rpx 0;
  429. display: flex;
  430. justify-content: space-between;
  431. flex-wrap: wrap;
  432. .live-item-b {
  433. width: 345rpx;
  434. background-color: #fff;
  435. border-radius: 16rpx;
  436. overflow: hidden;
  437. margin-bottom: 20rpx;
  438. overflow: hidden;
  439. .img-box {
  440. position: relative;
  441. image {
  442. width: 100%;
  443. height: 274rpx;
  444. }
  445. }
  446. .info {
  447. display: flex;
  448. flex-direction: column;
  449. padding: 20rpx;
  450. .title {
  451. font-size: 30rpx;
  452. color: #333;
  453. }
  454. .people {
  455. display: flex;
  456. margin-top: 10rpx;
  457. color: #999;
  458. image {
  459. width: 36rpx;
  460. height: 36rpx;
  461. border-radius: 50%;
  462. margin-right: 10rpx;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. .label {
  469. display: flex;
  470. align-items: center;
  471. justify-content: center;
  472. position: absolute;
  473. left: 10rpx;
  474. top: 10rpx;
  475. border-radius: 22rpx 0px 22rpx 22rpx;
  476. font-size: 24rpx;
  477. color: #fff;
  478. z-index: 1;
  479. image {
  480. margin-right: 10rpx;
  481. }
  482. text {
  483. font-size: 22rpx;
  484. }
  485. }
  486. .bgred {
  487. width: 132rpx;
  488. height: 38rpx;
  489. background: linear-gradient(270deg, #F5742F 0%, #FF1717 100%)
  490. }
  491. .bggary {
  492. width: 108rpx;
  493. height: 38rpx;
  494. background: linear-gradient(270deg, #999999 0%, #666666 100%);
  495. line-height: 38rpx;
  496. }
  497. .bggary .iconfont {
  498. margin-right: 8rpx;
  499. font-size: 24rpx;
  500. color: #FFFFFF;
  501. }
  502. .bgblue {
  503. display: flex;
  504. align-items: center;
  505. position: absolute;
  506. left: 4rpx;
  507. top: 10rpx;
  508. border-radius: 22rpx 0px 22rpx 22rpx;
  509. font-size: 24rpx;
  510. color: #fff;
  511. z-index: 1;
  512. width: 220rpx;
  513. height: 38rpx;
  514. background: rgba(0, 0, 0, 0.36);
  515. overflow: hidden;
  516. .txt {
  517. position: relative;
  518. left: -5rpx;
  519. display: flex;
  520. align-items: center;
  521. justify-content: center;
  522. width: 80rpx;
  523. height: 100%;
  524. text-align: center;
  525. background: linear-gradient(270deg, #2FA1F5 0%, #0076FF 100%);
  526. }
  527. }
  528. .title-box {
  529. display: flex;
  530. justify-content: space-between;
  531. align-items: center;
  532. padding: 20rpx 20rpx;
  533. font-size: 32rpx;
  534. .title {
  535. font-size: $uni-index-title-font-size;
  536. font-weight: bold;
  537. }
  538. // .text {
  539. // font-size: 24rpx;
  540. // color: #999;
  541. // width: 530rpx;
  542. // }
  543. // .name {
  544. // color: #282828;
  545. // font-size: 30rpx;
  546. // font-weight: bold;
  547. // margin-bottom: 5rpx;
  548. // }
  549. .more {
  550. display: flex;
  551. align-items: center;
  552. justify-content: center;
  553. font-size: 24rpx;
  554. color: #999999;
  555. .iconfont {
  556. margin-left: 9rpx;
  557. font-size: 26rpx;
  558. vertical-align: 3rpx;
  559. }
  560. }
  561. }
  562. .empty-img {
  563. width: 690rpx;
  564. height: 300rpx;
  565. border-radius: 14rpx;
  566. margin: 26rpx auto 0 auto;
  567. background-color: #ccc;
  568. text-align: center;
  569. line-height: 300rpx;
  570. .iconfont {
  571. font-size: 50rpx;
  572. }
  573. }
  574. </style>