liveBroadcast.vue 13 KB

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