index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div class="main">
  3. <!-- liveStatus直播间状态。101:直播中,102:未开始,103已结束,104禁播,105:暂停,106:异常,107:已过期 -->
  4. <view class='flash-sale'>
  5. <view class='list'>
  6. <view v-for="(item,index) in broadcastList" :key='index'>
  7. <navigator hover-class="none"
  8. :url="(item.liveStatus == 103 || item.liveStatus === 101 || item.liveStatus === 102) ? 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + item.roomId : ''">
  9. <view class='item acea-row row-between-wrapper'>
  10. <view class="live-image">
  11. <img class="image" :src="item.shareImgLocal">
  12. <view class="live-top" :class="item.liveStatus == 102 ? 'playRadius' : 'notPlayRadius'"
  13. :style="'background:' + (item.liveStatus == 101 ? playBg : (item.liveStatus != 101 && item.liveStatus != 102) ? endBg : notBg) + ';'">
  14. <block v-if="item.liveReplay">
  15. <text class="iconfont icon-zhibo-huifang"></text>
  16. <text>回放</text>
  17. </block>
  18. <block v-else-if="item.liveStatus == 101">
  19. <text class="iconfont icon-zhibo-zhibozhong"></text>
  20. <text>直播中</text>
  21. </block>
  22. <block v-else-if="item.liveStatus == 103">
  23. <text class="iconfont icon-zhibo-yugao"></text>
  24. <text>已结束</text>
  25. </block>
  26. <block v-else-if="item.liveStatus == 102">
  27. <text class="iconfont icon-zhibo-yugao"></text>
  28. <text>预告</text>
  29. </block>
  30. </view>
  31. <view v-if="item.liveStatus == 101 || item.liveStatus == 102" class="broadcast-time">
  32. {{ getPartTime(item.startTime) }}</view>
  33. </view>
  34. <view class="live-wrapper">
  35. <view class="live-title">{{ item.roomName }}</view>
  36. <view class="live-store">{{ item.anchorName }}</view>
  37. <!-- -->
  38. <view class="pro-count" style="white-space: nowrap; display: flex"
  39. v-if="item.goodsJson">
  40. <!-- <view class="item">
  41. <image :src="JSON.parse(item.goodsJson).coverImg"></image>
  42. </view> -->
  43. <navigator hover-class="none" class="item"
  44. v-for="(itm, idx) in JSON.parse(item.goodsJson)" :key="idx">
  45. <view class="pro-img" v-if="idx < 3">
  46. <image :src="itm.coverImg"></image>
  47. <view class="price" v-if="idx < 2">¥{{itm.price}}</view>
  48. <view v-else class="more">+{{ JSON.parse(item.goodsJson).length - 2 }}
  49. </view>
  50. </view>
  51. </navigator>
  52. </view>
  53. </view>
  54. </view>
  55. </navigator>
  56. </view>
  57. <view class='loadingicon acea-row row-center-wrapper'>
  58. <text class='loading iconfont icon-jiazai' :hidden='pageloading==false'></text>{{loadTitle}}
  59. </view>
  60. </view>
  61. </view>
  62. </div>
  63. </template>
  64. <script>
  65. // +----------------------------------------------------------------------
  66. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  67. // +----------------------------------------------------------------------
  68. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  69. // +----------------------------------------------------------------------
  70. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  71. // +----------------------------------------------------------------------
  72. // | Author: CRMEB Team <admin@crmeb.com>
  73. // +----------------------------------------------------------------------
  74. import {
  75. liveroomApi
  76. } from '@/api/public.js';
  77. import onShare from "../../../mixins/onShare";
  78. export default {
  79. mixins: [onShare],
  80. data() {
  81. return {
  82. topImage: '',
  83. broadcastList: [],
  84. loadTitle: '加载更多',
  85. scrollLeft: 0,
  86. interval: 0,
  87. status: 1,
  88. page: 1,
  89. limit: 5,
  90. loading: false,
  91. loadend: false,
  92. pageloading: false,
  93. endBg: 'linear-gradient(#666666, #999999)',
  94. notBg: 'rgb(26, 163, 246)',
  95. playBg: 'linear-gradient(#FF0000, #FF5400)',
  96. }
  97. },
  98. onLoad() {
  99. this.getBroadcastList();
  100. },
  101. methods: {
  102. getPartTime(val) {
  103. var timearr = val.replace(" ", ":").replace(/:/g, "-").split("-");
  104. var timestr = Number(timearr[1]) + "月" + timearr[2] + "日" + Number(timearr[3]) + ":" + timearr[4];
  105. return timestr;
  106. },
  107. getBroadcastList() {
  108. var that = this;
  109. var data = {
  110. page: that.page,
  111. limit: that.limit,
  112. };
  113. if (that.loadend) return;
  114. if (that.pageloading) return;
  115. this.pageloading = true
  116. liveroomApi(data).then(res => {
  117. var list = res.data.list;
  118. var loadend = list.length < that.limit;
  119. that.page++;
  120. that.broadcastList = that.broadcastList.concat(list),
  121. that.page = that.page;
  122. that.pageloading = false;
  123. that.loadend = loadend;
  124. that.loadTitle = loadend ? '我也是有底线的' : '加载更多';
  125. }).catch(err => {
  126. that.pageloading = false
  127. that.loadTitle = '我也是有底线的'
  128. });
  129. },
  130. },
  131. /**
  132. * 页面上拉触底事件的处理函数
  133. */
  134. onReachBottom: function() {
  135. this.getBroadcastList();
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .main {
  141. padding: 0 20rpx;
  142. margin-top: 20rpx;
  143. .row-between-wrapper {
  144. margin-bottom: 20rpx;
  145. display: flex;
  146. flex-direction: row;
  147. flex-wrap: wrap;
  148. justify-content: space-between;
  149. border-radius: 18rpx;
  150. .live-image {
  151. position: relative;
  152. width: 355rpx;
  153. height: 272rpx;
  154. border-radius: 18rpx 0 0 18rpx;
  155. .image {
  156. width: 100%;
  157. height: 100%;
  158. border-radius: 18rpx 0 0 18rpx;
  159. }
  160. .iconfont {
  161. font-size: 24rpx;
  162. margin-right: 6rpx;
  163. }
  164. }
  165. .live-wrapper {
  166. width: 50%;
  167. height: 272rpx;
  168. padding: 20rpx;
  169. background: #fff;
  170. border-radius: 0 18rpx 18rpx 0;
  171. position: relative;
  172. .live-title {
  173. font-size: 30rpx;
  174. color: #282828;
  175. font-weight: bold;
  176. }
  177. .live-store {
  178. font-size: 24rpx;
  179. color: #666666;
  180. }
  181. .pro-count {
  182. width: 330rpx;
  183. height: 100rpx;
  184. white-space: nowrap;
  185. position: absolute;
  186. bottom: 20rpx;
  187. }
  188. .item {
  189. width: 100rpx;
  190. height: 100rpx;
  191. margin-right: 15rpx;
  192. border-radius: 8rpx;
  193. position: relative;
  194. .pro-img {
  195. width: 100rpx;
  196. height: 100rpx;
  197. }
  198. image {
  199. width: 100rpx;
  200. height: 100rpx;
  201. max-width: 100%;
  202. border-radius: 8rpx;
  203. }
  204. .price {
  205. text-align: center;
  206. color: #FEFEFE;
  207. position: absolute;
  208. bottom: 4rpx;
  209. left: 0;
  210. width: 100%;
  211. font-size: 22rpx;
  212. background: rgba(0, 0, 0, .5);
  213. border-radius: 0 0 8rpx 8rpx;
  214. }
  215. .more {
  216. width: 100rpx;
  217. height: 100rpx;
  218. line-height: 100rpx;
  219. text-align: center;
  220. font-size: 28rpx;
  221. color: #FEFEFE;
  222. font-weight: bold;
  223. position: absolute;
  224. top: 0;
  225. left: 0;
  226. background-color: rgba(0, 0, 0, .2);
  227. border-radius: 8rpx;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. .live-top {
  234. z-index: 20;
  235. position: absolute;
  236. left: 0;
  237. top: 0;
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. color: #fff;
  242. min-width: 121rpx;
  243. max-width: 140rpx;
  244. height: 50rpx;
  245. font-size: 22rpx;
  246. &.playRadius {
  247. border-radius: 18rpx 0px 0 0px;
  248. }
  249. &.notPlayRadius {
  250. border-radius: 18rpx 0px 18rpx 0px;
  251. }
  252. image {
  253. width: 30rpx;
  254. height: 30rpx;
  255. margin-right: 10rpx;
  256. /* #ifdef H5 */
  257. display: block;
  258. /* #endif */
  259. }
  260. }
  261. .broadcast-time {
  262. z-index: 20;
  263. position: absolute;
  264. left: 120rpx;
  265. top: 0;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. color: #fff;
  270. width: 160rpx;
  271. height: 50rpx;
  272. background: rgba(0, 0, 0, .4);
  273. font-size: 22rpx;
  274. border-radius: 0 0 18rpx 0;
  275. }
  276. </style>