index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="main">
  3. <view class='flash-sale'>
  4. <view class='list'>
  5. <view v-for="(item,index) in broadcastList" :key='index' >
  6. <navigator hover-class="none" :url="((item.live_status == 103 && item.replay_status) || item.live_status === 101 || item.live_status === 102) ? 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.room_id : ''">
  7. <view class='item acea-row row-between-wrapper'>
  8. <view class="live-image">
  9. <img class="image" :src="item.share_img">
  10. <view class="live-top" :class="item.live_status == 102 ? 'playRadius' : 'notPlayRadius'" :style="'background:' + (item.live_status == 101 ? playBg : (item.live_status != 101 && item.live_status != 102) ? endBg : notBg) + ';'">
  11. <block v-if="item.live_status == 101">
  12. <image src="/static/images/live-01.png" mode=""></image>
  13. <text>直播中</text>
  14. </block>
  15. <block v-if="item.live_status == 103 && item.replay_status === 1">
  16. <image src="/static/images/live-02.png" mode=""></image>
  17. <text>回放</text>
  18. </block>
  19. <block v-if="(item.live_status != 101 && item.live_status != 102 && item.live_status != 103) || (item.live_status == 103 && item.replay_status == 0)">
  20. <image src="/static/images/live-02.png" mode=""></image>
  21. <text>已结束</text>
  22. </block>
  23. <block v-if="item.live_status == 102">
  24. <image src="/static/images/live-03.png" mode=""></image>
  25. <text>预告</text>
  26. </block>
  27. </view>
  28. <view v-if="item.live_status == 101 || item.live_status == 102" class="broadcast-time">{{ item.show_time }}</view>
  29. </view>
  30. <view class="live-wrapper">
  31. <view class="live-title">{{ item.name }}</view>
  32. <view class="live-store">{{ item.anchor_name }}</view>
  33. <view class="pro-count" style="white-space: nowrap; display: flex" v-if="item.broadcast.length > 0">
  34. <navigator hover-class="none" class="item" v-for="(itm, idx) in item.broadcast" :key="idx">
  35. <view class="pro-img" v-if="idx < 3">
  36. <image :src="itm.goods.cover_img"></image>
  37. <view class="price" v-if="idx < 2">¥{{itm.goods.price}}</view>
  38. <view v-else class="more">+{{ item.broadcast.length - 2 }}</view>
  39. </view>
  40. </navigator>
  41. </view>
  42. </view>
  43. </view>
  44. </navigator>
  45. </view>
  46. <view class='loadingicon acea-row row-center-wrapper'>
  47. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  48. </view>
  49. </view>
  50. </view>
  51. <home></home>
  52. </div>
  53. </template>
  54. <script>
  55. import {
  56. getBroadcastListApi
  57. } from '../../../api/store.js';
  58. import home from '@/components/home/index.vue'
  59. export default {
  60. components: {
  61. home
  62. },
  63. data() {
  64. return {
  65. topImage: '',
  66. broadcastList: [],
  67. loadTitle: '加载更多',
  68. scrollLeft: 0,
  69. interval: 0,
  70. status: 1,
  71. page: 1,
  72. limit: 5,
  73. loading: false,
  74. loadend: false,
  75. pageloading: false,
  76. endBg: 'linear-gradient(#666666, #999999)',
  77. notBg: 'rgb(26, 163, 246)',
  78. playBg: 'linear-gradient(#FF0000, #FF5400)',
  79. }
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. // #ifdef MP
  85. onShareAppMessage: function() {
  86. wx.showShareMenu({
  87. withShareTicket: true,
  88. menus: ['shareAppMessage', 'shareTimeline']
  89. })
  90. return {
  91. title: '直播',
  92. path: 'pages/activity/liveBroadcast/index',
  93. }
  94. },
  95. onShareTimeline: function() {
  96. return {
  97. title: '直播',
  98. query: {
  99. key: ''
  100. },
  101. imageUrl: ''
  102. }
  103. },
  104. // #endif
  105. onLoad() {
  106. this.getBroadcastList();
  107. },
  108. methods: {
  109. getBroadcastList() {
  110. var that = this;
  111. var data = {
  112. page: that.page,
  113. limit: that.limit,
  114. };
  115. if (that.loadend) return;
  116. if (that.pageloading) return;
  117. this.pageloading = true
  118. getBroadcastListApi(data).then(res => {
  119. var list = res.data.list;
  120. var loadend = list.length < that.limit;
  121. that.page++;
  122. that.broadcastList = that.broadcastList.concat(list),
  123. that.page = that.page;
  124. that.pageloading = false;
  125. that.loadend = loadend;
  126. that.loadTitle = loadend ? '我也是有底线的' : '加载更多';
  127. }).catch(err => {
  128. that.pageloading = false
  129. that.loadTitle = '我也是有底线的'
  130. });
  131. },
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom: function() {
  137. this.getBroadcastList();
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. .main {
  143. padding: 0 20rpx;
  144. margin-top: 20rpx;
  145. .row-between-wrapper {
  146. margin-bottom: 20rpx;
  147. display: flex;
  148. flex-direction: row;
  149. flex-wrap: wrap;
  150. justify-content: space-between;
  151. // background: darkseagreen;
  152. border-radius: 18rpx;
  153. .live-image {
  154. position: relative;
  155. width: 50%;
  156. height: 272rpx;
  157. border-radius: 18rpx 0 0 18rpx;
  158. .image {
  159. width: 100%;
  160. height: 100%;
  161. border-radius: 18rpx 0 0 18rpx;
  162. }
  163. }
  164. .live-wrapper {
  165. width: 50%;
  166. height: 272rpx;
  167. padding: 20rpx;
  168. background: #fff;
  169. border-radius: 0 18rpx 18rpx 0;
  170. position: relative;
  171. .live-title {
  172. font-size: 30rpx;
  173. color: #282828;
  174. font-weight: bold;
  175. }
  176. .live-store {
  177. font-size: 24rpx;
  178. color: #666666;
  179. }
  180. .pro-count {
  181. width: 330rpx;
  182. height: 100rpx;
  183. white-space: nowrap;
  184. position: absolute;
  185. bottom: 20rpx;
  186. }
  187. .item {
  188. width: 100rpx;
  189. height: 100rpx;
  190. margin-right: 15rpx;
  191. border-radius: 8rpx;
  192. position: relative;
  193. .pro-img{
  194. width: 100rpx;
  195. height: 100rpx;
  196. }
  197. image {
  198. width: 100rpx;
  199. height: 100rpx;
  200. max-width: 100%;
  201. border-radius: 8rpx;
  202. }
  203. .price {
  204. text-align: center;
  205. color: #FEFEFE;
  206. position: absolute;
  207. bottom: 4rpx;
  208. left: 0;
  209. width: 100%;
  210. font-size: 22rpx;
  211. background: rgba(0,0,0,.5);
  212. border-radius: 0 0 8rpx 8rpx;
  213. }
  214. .more {
  215. width: 100rpx;
  216. height: 100rpx;
  217. line-height: 100rpx;
  218. text-align: center;
  219. font-size: 28rpx;
  220. color: #FEFEFE;
  221. font-weight: bold;
  222. position: absolute;
  223. top: 0;
  224. left: 0;
  225. background-color: rgba(0, 0, 0, .2);
  226. border-radius: 8rpx;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. .live-top {
  233. z-index: 20;
  234. position: absolute;
  235. left: 0;
  236. top: 0;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. color: #fff;
  241. min-width: 130rpx;
  242. max-width: 140rpx;
  243. height: 50rpx;
  244. font-size: 22rpx;
  245. &.playRadius {
  246. border-radius: 18rpx 0px 0 0px;
  247. }
  248. &.notPlayRadius {
  249. border-radius: 18rpx 0px 18rpx 0px;
  250. }
  251. image {
  252. width: 30rpx;
  253. height: 30rpx;
  254. margin-right: 10rpx;
  255. /* #ifdef H5 */
  256. display: block;
  257. /* #endif */
  258. }
  259. }
  260. .broadcast-time {
  261. z-index: 20;
  262. position: absolute;
  263. left: 120rpx;
  264. top: 0;
  265. display: flex;
  266. align-items: center;
  267. justify-content: center;
  268. color: #fff;
  269. width: 160rpx;
  270. height: 50rpx;
  271. background: rgba(0,0,0,.4);
  272. font-size: 22rpx;
  273. border-radius: 0 0 18rpx 0;
  274. }
  275. </style>