live.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <!--pages/live/live.wxml-->
  4. <view class="list" v-if="pageList.length > 0">
  5. <block v-for="(item, index) in pageList" :key="index">
  6. <view class="li" @tap="intoLive" :data-id="item.roomid" :data-index="index">
  7. <image :src="item.share_img" mode="scaleToFill" class="zbimg"></image>
  8. <view class="title">{{item.name}}</view>
  9. <view class="dflex">
  10. <view class="sta dflex flex" v-if="item.live_status == 101"><image src="/static/pages/images/zbico.png"></image>直播中</view>
  11. <view class="sta dflex flex" v-else-if="item.live_status == 102"><image src="/static/pages/images/zbico.png"></image>{{item.time}}开播</view>
  12. <view class="sta end dflex flex" v-else><image src="/static/pages/images/zbico1.png"></image>已结束</view>
  13. <!-- <view class="ren dflex flex"><image src="/pages/images/ren.png"></image>6247</view> -->
  14. <view class="into" v-if="item.live_status == 103">查看回放</view>
  15. <view class="into" v-else>进入直播</view>
  16. <!-- <view class="into" wx:if="{{item.live_status == 102}}">开播提醒</view> -->
  17. </view>
  18. </view>
  19. </block>
  20. <footer-copyright></footer-copyright>
  21. </view>
  22. <view class="nodata" v-if="ishow">
  23. <image :src="picUrlss+'empty_zb.png'"></image>
  24. <text>暂无直播</text>
  25. </view>
  26. <!-- <view class="placeholder-view" :style="'height:' + (bottomBlankHeignt + 115) + 'rpx'"></view> -->
  27. <foot channel="live" :isUpdate="isUpdate"></foot>
  28. </view>
  29. </template>
  30. <script>
  31. // pages/live/live.js
  32. const app = getApp();
  33. const req = require("../../utils/request.js");
  34. const util = require("../../utils/util.js");
  35. import foot from "../../components/nav-bar/index";
  36. import footerCopyright from "../../components/footer-copyright/footer-copyright";
  37. export default {
  38. data() {
  39. return {
  40. picUrlss: req.public.picUrls,
  41. bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
  42. page: 1,
  43. pageList: [],
  44. isLoad: true,
  45. isUpdate: false // 是否更新消息
  46. ,
  47. hasmore: false,
  48. ishow: false
  49. };
  50. },
  51. components: {
  52. foot,
  53. footerCopyright
  54. },
  55. props: {},
  56. onLoad() {// this.getList()
  57. },
  58. onShow() {
  59. this.getList();
  60. this.setData({
  61. isUpdate: !this.isUpdate
  62. });
  63. },
  64. onReachBottom() {
  65. this.page++;
  66. this.getList();
  67. },
  68. methods: {
  69. getList() {
  70. let that = this;
  71. let isShowLoading = false;
  72. // console.log(that.isLoad);
  73. if (!that.isLoad) return false;
  74. that.isLoad = false;
  75. let form = {
  76. page: that.page,
  77. limit: 10
  78. };
  79. if (form.page == 1 && !isShowLoading) {
  80. req.loadIng('加载中');
  81. isShowLoading = true;
  82. }
  83. req.getRequest('/api/live/list', form, data => {
  84. // if (!data) return req.msg('还没有直播');
  85. if (data && data.length == 10) that.isLoad = true;
  86. if (that.page > 1) data = that.pageList.concat(data);
  87. if (!data || data.length < 10) {
  88. that.setData({
  89. hasmore: true
  90. });
  91. }
  92. if (data) {
  93. data.map(item => {
  94. if (item.start_time) {
  95. item.time = util.transTime(item.start_time);
  96. }
  97. return item;
  98. });
  99. }
  100. // console.log(data);
  101. that.setData({
  102. pageList: data
  103. });
  104. if (!this.pageList) {
  105. that.setData({
  106. ishow: true
  107. });
  108. } else {
  109. that.setData({
  110. ishow: false
  111. });
  112. }
  113. if (isShowLoading) {
  114. uni.hideLoading();
  115. isShowLoading = false;
  116. }
  117. });
  118. },
  119. getLive(id) {
  120. return new Promise((resolve, reject) => {
  121. req.getRequest('/api/live/playBack', {
  122. page: 1,
  123. limit: 10,
  124. room_id: id
  125. }, data => {
  126. this.videoList = data;
  127. resolve();
  128. });
  129. });
  130. },
  131. intoLive(event) {
  132. let roomId = event.currentTarget.dataset.id;
  133. let index=event.currentTarget.dataset.index;
  134. // console.log(roomId)
  135. // let date=this.data.pageList.filter(res=>res.roomid==roomId)
  136. // // console.log(JSON.stringify(JSON.stringify(date[0])))
  137. // // console.log(typeof(JSON.stringify(date[0])))
  138. // res=JSON.stringify(date[0])
  139. let redirect = '/pages/liveMiddle/liveMiddle?id=' + roomId
  140. req.isLogin().then(success => {
  141. if (success) {
  142. uni.navigateTo({
  143. url: redirect // url:`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}`
  144. });
  145. }
  146. });
  147. },
  148. async playBack(event) {
  149. let roomId = event.currentTarget.dataset.id;
  150. await this.getLive(roomId);
  151. let videoList = JSON.stringify(this.videoList);
  152. if (videoList.length < 1) return req.msg('回放生成中');
  153. uni.navigateTo({
  154. url: '/pages/video/video?videoList=' + videoList
  155. });
  156. }
  157. }
  158. };
  159. </script>
  160. <style>
  161. @import "./live.css";
  162. </style>