小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
5.2 KiB

  1. <template>
  2. <view class="live-el mx20 mb10">
  3. <view class="head">
  4. <text class="head-title">热门直播</text>
  5. <view class="head-more" @tap="$yrouter.push('/pages/shop/Live/LiveList/index')">
  6. <text>更多</text>
  7. <text class="cuIcon-right"></text>
  8. </view>
  9. </view>
  10. <view class="content-one">
  11. <view class="content-one__item" v-for="live in detail" :key="live.roomId" @tap="goRoom(live)">
  12. <image class="item-cover" :src="live.shareImge" mode="widthFix"></image>
  13. <view class="item-status">
  14. <image class="status-img" :src="liveStatus[live.liveStatus].img" mode=""></image>
  15. <text class="status-text">{{ liveStatus[live.liveStatus].title }}</text>
  16. </view>
  17. <view class="item-title">{{ live.name }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import ShopLiveCard from '@/components/ShopLiveCard.vue'
  24. let HAS_LIVE = false
  25. // #ifdef MP-WEIXIN
  26. HAS_LIVE = true
  27. let livePlayer = null;
  28. if (HAS_LIVE) {
  29. livePlayer = requirePlugin('live-player-plugin');
  30. }
  31. // #endif
  32. import {
  33. yxWechatLive,
  34. getLiveReplay
  35. } from '@/api/live';
  36. let timer = null;
  37. export default {
  38. components: {
  39. ShopLiveCard
  40. },
  41. data() {
  42. return {
  43. liveList: [],
  44. liveStatus: {
  45. '101': {
  46. img: 'https://wx.yixiang.co/static/images/live.png',
  47. title: '直播中'
  48. },
  49. '102': {
  50. img: 'https://wx.yixiang.co/static/images/prevue.png',
  51. title: '未开始'
  52. },
  53. '103': {
  54. img: 'https://wx.yixiang.co/static/images/playback.png',
  55. title: '已结束'
  56. },
  57. '104': {
  58. img: 'https://wx.yixiang.co/static/images/104.png',
  59. title: '禁播'
  60. },
  61. '105': {
  62. img: 'https://wx.yixiang.co/static/images/105.png',
  63. title: '暂停中'
  64. },
  65. '106': {
  66. img: 'https://wx.yixiang.co/static/images/106.png',
  67. title: '异常'
  68. },
  69. '107': {
  70. img: 'https://wx.yixiang.co/static/images/past.png',
  71. title: '已过期'
  72. }
  73. }
  74. };
  75. },
  76. props: {
  77. detail: Array
  78. },
  79. created() {
  80. },
  81. mounted() {
  82. let that = this;
  83. timer = setInterval(() => {
  84. that.getLiveStatus();
  85. }, 60000);
  86. },
  87. beforeDestroy() {
  88. timer = null;
  89. },
  90. computed: {},
  91. methods: {
  92. // 直播列表
  93. getLiveList() {
  94. // let that = this;
  95. // yxWechatLive({
  96. // page: 1,
  97. // size: 10,
  98. // }).then(res => {
  99. // console.log(res)
  100. // })
  101. },
  102. // 轮询liveStatus
  103. getLiveStatus() {
  104. // if (HAS_LIVE) {
  105. // let that = this;
  106. // let date = '';
  107. // if (that.detail.liveStatus == 102) {
  108. // date = that.$tools.dateFormat('mm-dd HH:MM', new Date(that.detail.starttime * 1000)).replace('-',
  109. // '/');
  110. // that.liveStatus['102'].title = '预告 ' + date;
  111. // }
  112. // livePlayer
  113. // .getLiveStatus({
  114. // room_id: that.detail.roomId
  115. // })
  116. // .then(res => {
  117. // // 101: 直播中, 102: 未开始, 103: 已结束, 104: 禁播, 105: 暂停中, 106: 异常,107:已过期
  118. // that.detail.liveStatus = res.liveStatus;
  119. // })
  120. // .catch(err => {
  121. // console.log('get live status', err);
  122. // });
  123. // }
  124. },
  125. goRoom(live) {
  126. wx.navigateTo({
  127. url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${live.roomId}`
  128. });
  129. }
  130. }
  131. };
  132. </script>
  133. <style lang="scss">
  134. .live-el {
  135. background: #fff;
  136. border-radius: 20rpx;
  137. padding: 30rpx 20rpx 25rpx;
  138. .head {
  139. display: flex;
  140. justify-content: space-between;
  141. align-items: center;
  142. &-title {
  143. font-size: 32rpx;
  144. font-weight: bold;
  145. font-family: PingFang SC;
  146. color: rgba(51, 51, 51, 1);
  147. }
  148. &-more {
  149. font-size: 26rpx;
  150. font-family: PingFang SC;
  151. font-weight: 500;
  152. color: rgba(51, 51, 51, 1);
  153. }
  154. }
  155. // 单个大图直播
  156. .content-one {
  157. .content-one__item {
  158. position: relative;
  159. height: 280rpx;
  160. border-radius: 20rpx;
  161. margin-top: 25rpx;
  162. overflow: hidden;
  163. .item-cover {
  164. background-color: #eee;
  165. width: 100%;
  166. height: 100%;
  167. }
  168. .item-status {
  169. position: absolute;
  170. top: 20rpx;
  171. left: 10rpx;
  172. height: 40rpx;
  173. background: rgba(0, 0, 0, 0.4);
  174. border-radius: 20rpx;
  175. display: flex;
  176. justify-content: center;
  177. align-items: center;
  178. .status-img {
  179. width: 38rpx;
  180. height: 38rpx;
  181. }
  182. .status-text {
  183. font-size: 22rpx;
  184. font-family: PingFang SC;
  185. font-weight: 500;
  186. color: rgba(255, 255, 255, 1);
  187. padding: 0 10rpx;
  188. }
  189. }
  190. .item-title {
  191. width: 680rpx;
  192. position: absolute;
  193. bottom: 0;
  194. line-height: 60rpx;
  195. padding: 0 20rpx;
  196. font-size: 26rpx;
  197. font-family: PingFang SC;
  198. font-weight: 500;
  199. color: rgba(255, 255, 255, 1);
  200. background: linear-gradient(transparent, rgba(#000, 0.5));
  201. }
  202. .like-img {
  203. position: absolute;
  204. bottom: 20rpx;
  205. right: 10rpx;
  206. width: 60rpx;
  207. height: 130rpx;
  208. }
  209. }
  210. }
  211. // 双图直播
  212. .content-two {
  213. width: 100%;
  214. // -moz-column-count: 2;
  215. // -webkit-column-count: 2;
  216. // column-count: 2;
  217. // padding-top: 20rpx;
  218. display: flex;
  219. flex-wrap: wrap;
  220. &__item {
  221. margin-right: 30rpx;
  222. margin-top: 20rpx;
  223. &:nth-child(2n) {
  224. margin-right: 0;
  225. }
  226. }
  227. }
  228. }
  229. </style>