liveBroadcast.vue 15 KB

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