liveBroadcast.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <!-- 小程序直播 -->
  3. <!-- #ifdef MP -->
  4. <!-- liveStatus直播间状态。101:直播中,102:未开始,103已结束,104禁播,105:暂停,106:异常,107:已过期 -->
  5. <view v-if="liveList.length > 0">
  6. <view class="wrapper-count indexList" :style="[boxStyle]">
  7. <view class='title acea-row row-between-wrapper'>
  8. <view class='text line1 tui-skeleton-rect acea-row'>
  9. <image :src="logoUrl"></image>
  10. <text class='label' :style="[titleColor]">{{titleText}}</text>
  11. </view>
  12. <navigator v-if="!merId" :url="moreLink" class="more-btn" hover-class="none">
  13. <view class='more tui-skeleton-rect' :style="[moreColor]">
  14. 更多
  15. <text class="iconfont icon-jiantou"></text>
  16. </view>
  17. </navigator>
  18. </view>
  19. <view class='tips mb20'>First new product</view>
  20. <!-- 直播 -->
  21. <block v-if="listStyle == 0">
  22. <view class="live-wrapper mores">
  23. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex">
  24. <view class="item" v-for="(item, index) in liveList" :key="index"
  25. :style="[{'margin-right':dataConfig.contentConfig.val + 'px'},imgStyle]">
  26. <navigator hover-class="none"
  27. :url="'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.roomId">
  28. <view class="live-top"
  29. :style="'background:' + (item.liveStatus == 101 ? playBg : item.liveStatus != 101 && item.liveStatus != 102 ? endBg : notBg) + ';'"
  30. :class="item.liveStatus == 102 ? 'playRadius' : 'notPlayRadius'">
  31. <view v-if="item.liveReplay">
  32. <text class="iconfont icon-zhibo-huifang"></text>
  33. <text>回放</text>
  34. </view>
  35. <view v-else-if="item.liveStatus == 101">
  36. <text class="iconfont icon-zhibo-zhibozhong"></text>
  37. <text>直播中</text>
  38. </view>
  39. <view v-else-if="item.liveStatus == 103 ">
  40. <text class="iconfont icon-zhibo-yugao"></text>
  41. <text>已结束</text>
  42. </view>
  43. <view v-else-if="item.liveStatus == 102">
  44. <text class="iconfont icon-zhibo-yugao"></text>
  45. <text>预告</text>
  46. </view>
  47. </view>
  48. <view v-if="item.liveStatus == 101 || item.liveStatus == 102" class="broadcast-time">
  49. {{ igetPartTime(item.startTime) }}
  50. </view>
  51. <image :src="item.feedsImgWx" mode="aspectFill"></image>
  52. </navigator>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. </block>
  57. <block v-if="listStyle == 1">
  58. <view class="live-wrapper-a" :style="[gridGap]">
  59. <navigator class="live-item-a" v-for="(item,index) in liveList" :key="index"
  60. :style="[contentStyle]"
  61. :url="'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.roomId">
  62. <view class="img-box">
  63. <view class="label bggary" v-if="item.liveReplay">
  64. <text class="iconfont icon-zhibo-huifang"></text>
  65. <text>回放</text>
  66. </view>
  67. <view class="label bgred" v-else-if="item.liveStatus==101">
  68. <text class="iconfont icon-zhibo-zhibozhong"></text>
  69. <text>直播中</text>
  70. </view>
  71. <view class="label bggary" v-else-if="item.liveStatus == 103 ">
  72. <text class="iconfont icon-zhibo-yugao"></text>
  73. <text>已结束</text>
  74. </view>
  75. <view class="label bgblue" v-else-if="item.liveStatus == 102">
  76. <view class="txt">预告</view>
  77. <view class="msg">{{ igetPartTime(item.startTime) }}</view>
  78. </view>
  79. <image :src="item.feedsImgWx" mode="aspectFill" :style="[imgStyle]"></image>
  80. </view>
  81. <view class="info">
  82. <view class="title line2">{{item.roomName}}</view>
  83. <view class="people">
  84. <text>{{item.anchorName}}</text>
  85. </view>
  86. <view class="goods-wrapper">
  87. <block v-if="item.broadcast && item.broadcast.length <=3 && item.broadcast.length > 0">
  88. <view class="goods-item" v-for="(goods,index) in item.broadcast" :key="index">
  89. <image :src="goods.coverImg" alt="">
  90. <text class="line1">¥{{goods.price}}</text>
  91. </view>
  92. </block>
  93. <block v-if="item.broadcast && item.broadcast.length>3">
  94. <view class="goods-item" v-for="(goods,index) in item.broadcast" :key="index"
  95. v-if="index<2">
  96. <image :src="goods.coverImg" alt="">
  97. <text class="line1">¥{{goods.price}}</text>
  98. </view>
  99. <view class="goods-item">
  100. <image :src="item.broadcast[item.broadcast.length-1].goods.coverImg" alt="">
  101. <view class="num">+{{item.broadcast.length}}</view>
  102. </view>
  103. </block>
  104. <block v-if="!item.broadcast || item.broadcast.length == 0">
  105. <view class="empty-goods">暂无商品</view>
  106. </block>
  107. </view>
  108. </view>
  109. </navigator>
  110. </view>
  111. </block>
  112. <block v-if="listStyle == 2">
  113. <view class="live-wrapper-b" :style="[gridGap]">
  114. <navigator class="live-item-b" v-for="(item,index) in liveList" :key="index"
  115. :url="'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.roomId"
  116. hover-class="none" :style="[contentStyle]">
  117. <view class="img-box">
  118. <view class="label bggary" v-if="item.liveReplay">
  119. <text class="iconfont icon-zhibo-huifang"></text>
  120. <text>回放</text>
  121. </view>
  122. <view class="label bgred" v-else-if="item.liveStatus==101">
  123. <text class="iconfont icon-zhibo-zhibozhong"></text>
  124. <text>直播中</text>
  125. </view>
  126. <view class="label bggary" v-else-if="item.liveStatus == 103 ">
  127. <text class="iconfont icon-zhibo-yugao"></text>
  128. <text>已结束</text>
  129. </view>
  130. <view class="label bgblue" v-else-if="item.liveStatus == 102">
  131. <view class="txt">预告</view>
  132. <view class="msg">{{ igetPartTime(item.startTime) }}</view>
  133. </view>
  134. <image :src="item.feedsImgWx"></image>
  135. </view>
  136. <view class="info">
  137. <view class="title line2">{{item.roomName}}</view>
  138. <view class="people">
  139. <text>{{item.anchorName}}</text>
  140. </view>
  141. </view>
  142. </navigator>
  143. </view>
  144. </block>
  145. </view>
  146. </view>
  147. <!-- #endif -->
  148. </template>
  149. <script>
  150. // +----------------------------------------------------------------------
  151. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  152. // +----------------------------------------------------------------------
  153. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  154. // +----------------------------------------------------------------------
  155. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  156. // +----------------------------------------------------------------------
  157. // | Author: CRMEB Team <admin@crmeb.com>
  158. // +----------------------------------------------------------------------
  159. import {
  160. liveroomApi
  161. } from '@/api/public.js';
  162. import easyLoadimage from '@/components/base/easy-loadimage.vue';
  163. export default {
  164. name: 'liveBroadcast',
  165. components: {
  166. easyLoadimage
  167. },
  168. props: {
  169. dataConfig: {
  170. type: Object,
  171. default: () => {}
  172. },
  173. //商户id
  174. merId: {
  175. type: String || Number,
  176. default: ''
  177. }
  178. },
  179. data() {
  180. return {
  181. urlDomain: this.$Cache.get("imgHost"),
  182. liveList: [],
  183. bg: '#fff',
  184. endBg: 'linear-gradient(#666666, #999999)',
  185. notBg: 'rgb(26, 163, 246)',
  186. playBg: 'linear-gradient(#FF0000, #FF5400)',
  187. };
  188. },
  189. computed: {
  190. //内容圆角
  191. contentStyle() {
  192. return {
  193. 'border-radius': this.dataConfig.contentStyle.val ? this.dataConfig.contentStyle.val + 'px' : '0'
  194. };
  195. },
  196. //样式种类
  197. listStyle() {
  198. return this.dataConfig.tabConfig.tabVal
  199. },
  200. //最外层盒子的样式
  201. boxStyle() {
  202. return {
  203. borderRadius: this.dataConfig.bgStyle.val * 2 + 'rpx',
  204. background: `linear-gradient(${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
  205. margin: this.dataConfig.mbConfig.val * 2 + 'rpx' + ' ' + this.dataConfig.lrConfig.val * 2 + 'rpx' +
  206. ' ' + 0,
  207. padding: this.dataConfig.upConfig.val * 2 + 'rpx' + ' ' + '10px' + ' ' + this.dataConfig.downConfig
  208. .val * 2 + 'rpx'
  209. }
  210. },
  211. //内容间距
  212. gridGap() {
  213. return {
  214. 'grid-gap': this.dataConfig.contentConfig.val * 2 + 'rpx'
  215. }
  216. },
  217. //文章图片的圆角和高度
  218. imgStyle() {
  219. return {
  220. 'border-radius': this.dataConfig.contentStyle.val * 2 + 'rpx',
  221. }
  222. },
  223. //标题图片
  224. logoUrl() {
  225. return this.dataConfig.logoConfig.url
  226. },
  227. //标题
  228. titleText() {
  229. return this.dataConfig.titleConfig.val
  230. },
  231. //标题颜色
  232. titleColor() {
  233. return {
  234. color: this.dataConfig.titleColor.color[0].item
  235. }
  236. },
  237. //更多颜色
  238. moreColor() {
  239. return {
  240. color: this.dataConfig.moreColor.color[0].item
  241. }
  242. },
  243. //更多链接地址
  244. moreLink() {
  245. return this.dataConfig.linkConfig.val
  246. }
  247. },
  248. mounted() {
  249. this.getLiveList();
  250. },
  251. methods: {
  252. getPartTime(val) {
  253. var timearr = val.replace(" ", ":").replace(/:/g, "-").split("-");
  254. var timestr = Number(timearr[1]) + "月" + timearr[2] + "日" + Number(timearr[3]) + ":" + timearr[4];
  255. return timestr;
  256. },
  257. // 直播
  258. getLiveList() {
  259. let that = this;
  260. liveroomApi({
  261. page: 1,
  262. limit: 6
  263. }).then(res => {
  264. res.data.list.map(item => {
  265. this.$set(item, 'broadcast', JSON.parse(item.goodsJson));
  266. })
  267. that.liveList = res.data.list;
  268. }).catch(e => {});
  269. },
  270. }
  271. };
  272. </script>
  273. <style lang="scss" scoped>
  274. @import '@/static/css/diyMain.scss';
  275. .wrapper-count {
  276. padding: 24rpx 20rpx 0;
  277. }
  278. .live-wrapper {
  279. position: relative;
  280. width: 100%;
  281. overflow: hidden;
  282. border-radius: 16rpx;
  283. image {
  284. width: 100%;
  285. height: 400rpx;
  286. }
  287. .live-top {
  288. z-index: 20;
  289. position: absolute;
  290. left: 0;
  291. top: 0;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. color: #fff;
  296. width: 180rpx;
  297. height: 54rpx;
  298. border-radius: 16rpx 0px 16rpx 0px;
  299. &.playRadius {
  300. border-radius: 16rpx 0 0 0;
  301. }
  302. &.notPlayRadius {
  303. border-radius: 16rpx 0px 16rpx 0px;
  304. }
  305. image {
  306. width: 30rpx;
  307. height: 30rpx;
  308. margin-right: 10rpx;
  309. /* #ifdef H5 */
  310. display: block;
  311. /* #endif */
  312. }
  313. }
  314. .live-title {
  315. position: absolute;
  316. left: 0;
  317. bottom: 6rpx;
  318. width: 100%;
  319. height: 70rpx;
  320. line-height: 70rpx;
  321. text-align: center;
  322. font-size: 30rpx;
  323. color: #fff;
  324. background: rgba(0, 0, 0, 0.35);
  325. }
  326. &.mores {
  327. width: 100%;
  328. .item {
  329. position: relative;
  330. width: 280rpx;
  331. display: inline-block;
  332. border-radius: 16rpx;
  333. overflow: hidden;
  334. image {
  335. width: 280rpx;
  336. height: 224rpx;
  337. border-radius: 16rpx;
  338. }
  339. .live-title {
  340. height: 40rpx;
  341. line-height: 40rpx;
  342. text-align: center;
  343. font-size: 22rpx;
  344. }
  345. .live-top {
  346. width: 100rpx;
  347. height: 36rpx;
  348. font-size: 22rpx;
  349. image {
  350. width: 20rpx;
  351. height: 20rpx;
  352. }
  353. }
  354. }
  355. }
  356. }
  357. .live-wrapper-a {
  358. display: grid;
  359. grid-template-rows: auto;
  360. grid-template-columns: repeat(1, 1fr);
  361. .live-item-a {
  362. display: flex;
  363. background: #fff;
  364. overflow: hidden;
  365. .img-box {
  366. position: relative;
  367. width: 340rpx;
  368. height: 270rpx;
  369. image {
  370. width: 100%;
  371. height: 100%;
  372. }
  373. }
  374. .info {
  375. flex: 1;
  376. display: flex;
  377. flex-direction: column;
  378. justify-content: space-between;
  379. padding: 15rpx 20rpx;
  380. .title {
  381. font-size: 30rpx;
  382. color: #333;
  383. }
  384. .people {
  385. display: flex;
  386. align-items: center;
  387. color: #999;
  388. font-size: 24rpx;
  389. margin-top: 10rpx;
  390. }
  391. .goods-wrapper {
  392. display: flex;
  393. .goods-item {
  394. position: relative;
  395. width: 96rpx;
  396. height: 96rpx;
  397. margin-right: 20rpx;
  398. overflow: hidden;
  399. border-radius: 16rpx;
  400. &:last-child {
  401. margin-right: 0;
  402. }
  403. image {
  404. width: 100%;
  405. height: 100%;
  406. border-radius: 16rpx;
  407. }
  408. .bg {
  409. position: absolute;
  410. left: 0;
  411. top: 0;
  412. width: 100%;
  413. height: 100%;
  414. border-radius: 16rpx;
  415. background: rgba(0, 0, 0, 0.3);
  416. }
  417. text {
  418. font-size: 24rpx;
  419. position: absolute;
  420. left: 0;
  421. bottom: 0;
  422. width: 100%;
  423. height: 60rpx;
  424. line-height: 70rpx;
  425. color: #fff;
  426. background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.75) 100%);
  427. }
  428. .num {
  429. display: flex;
  430. align-items: center;
  431. justify-content: center;
  432. position: absolute;
  433. left: 0;
  434. top: 0;
  435. width: 100%;
  436. height: 100%;
  437. background: rgba(0, 0, 0, 0.3);
  438. color: #fff;
  439. font-size: 28rpx;
  440. }
  441. }
  442. }
  443. .empty-goods {
  444. width: 96rpx;
  445. height: 96rpx;
  446. border-radius: 6rpx;
  447. background-color: #B2B2B2;
  448. color: #fff;
  449. font-size: 20rpx;
  450. text-align: center;
  451. line-height: 96rpx;
  452. }
  453. }
  454. }
  455. &.live-wrapper-c {
  456. .live-item-a {
  457. display: flex;
  458. flex-direction: column;
  459. .img-box {
  460. width: 100%;
  461. border-radius: 8px 8px 0 0;
  462. }
  463. .info {
  464. display: flex;
  465. justify-content: space-between;
  466. align-items: center;
  467. flex-direction: initial;
  468. .left {
  469. width: 69%;
  470. }
  471. .goods-wrapper {
  472. flex: 1;
  473. }
  474. }
  475. }
  476. }
  477. }
  478. .live-wrapper-b {
  479. display: grid;
  480. grid-template-columns: repeat(2, 1fr);
  481. grid-template-rows: auto;
  482. .live-item-b {
  483. background-color: #fff;
  484. overflow: hidden;
  485. margin-bottom: 20rpx;
  486. overflow: hidden;
  487. .img-box {
  488. position: relative;
  489. image {
  490. width: 100%;
  491. height: 274rpx;
  492. }
  493. }
  494. .info {
  495. display: flex;
  496. flex-direction: column;
  497. padding: 20rpx;
  498. .title {
  499. font-size: 30rpx;
  500. color: #333;
  501. }
  502. .people {
  503. display: flex;
  504. margin-top: 10rpx;
  505. color: #999;
  506. font-size: 24rpx;
  507. }
  508. }
  509. }
  510. }
  511. .label {
  512. display: flex;
  513. align-items: center;
  514. justify-content: center;
  515. position: absolute;
  516. left: 0;
  517. top: 0;
  518. border-radius: 16rpx 0px 16rpx 0;
  519. font-size: 24rpx;
  520. color: #fff;
  521. image {
  522. margin-right: 10rpx;
  523. }
  524. text {
  525. font-size: 22rpx;
  526. }
  527. }
  528. .bgred {
  529. width: 132rpx;
  530. height: 38rpx;
  531. background: linear-gradient(270deg, #F5742F 0%, #FF1717 100%)
  532. }
  533. .bggary {
  534. width: 108rpx;
  535. height: 38rpx;
  536. background: linear-gradient(270deg, #999999 0%, #666666 100%)
  537. }
  538. .bgblue {
  539. width: 220rpx;
  540. height: 38rpx;
  541. background: rgba(0, 0, 0, 0.36);
  542. overflow: hidden;
  543. .txt {
  544. position: relative;
  545. left: -6rpx;
  546. display: flex;
  547. align-items: center;
  548. justify-content: center;
  549. width: 38px;
  550. height: 100%;
  551. text-align: center;
  552. background: linear-gradient(270deg, #2FA1F5 0%, #0076FF 100%);
  553. }
  554. }
  555. </style>