liveBroadcast.vue 13 KB

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