liveBroadcast.vue 14 KB

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