瀏覽代碼

直播列表

junyuanz 5 年之前
父節點
當前提交
f2e8c143f0
共有 7 個文件被更改,包括 159 次插入14 次删除
  1. 1 0
      app.json
  2. 14 12
      pages/home/home.js
  3. 81 0
      pages/livelist/livelist.js
  4. 10 0
      pages/livelist/livelist.json
  5. 16 0
      pages/livelist/livelist.wxml
  6. 35 0
      pages/livelist/livelist.wxss
  7. 2 2
      utils/request.js

+ 1 - 0
app.json

@@ -7,6 +7,7 @@
     "pages/areacart/areacart",
     "pages/centcart/centcart",
     "pages/projects/projects",
+    "pages/livelist/livelist",
     "pages/helpfarm/helpfarm",
     "pages/helpfarm/helpfarm-detail/helpfarm-detail",
     "pages/helpfarm/helpfarm-success/helpfarm-success",

+ 14 - 12
pages/home/home.js

@@ -532,18 +532,20 @@ Page ({
     
    },
    tolive:function(e){
-   	var that = this
-    var url = 'v1/live_broad/current'
-    var params = {}
-    var success = function (res) {
-      let roomId = [res.data.room_id] // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
-			let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
-			wx.navigateTo({
-			    url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}`
-			})
-    }
-    _request.$get(url, params, success)
-   	
+// 	var that = this
+//  var url = 'v1/live_broad/current'
+//  var params = {}
+//  var success = function (res) {
+//    let roomId = [res.data.room_id] // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
+//			let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
+//			wx.navigateTo({
+//			    url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}`
+//			})
+//  }
+//  _request.$get(url, params, success)
+   	wx.navigateTo({
+	      url: '/pages/livelist/livelist'
+	   })
    	
    },
    // 滚动事件 

+ 81 - 0
pages/livelist/livelist.js

@@ -0,0 +1,81 @@
+var _request = require('../../utils/request.js')
+Page({
+  data: {
+    projects_page: 1,
+    projects_per_page: 6,
+    projects_more: true,
+    projects_change: false,
+    projects: [],
+    vershow: true,
+    navData:[],
+    currentTab: 0,
+    navScrollLeft: 0,
+    balance: 0,
+    todaysend: Date.parse(new Date()) / 1000
+  },
+  onLoad: function () {
+      // this.getLive()
+  },
+  onShow: function () {
+      this.getLive()
+  },
+  onUnload: function () {
+  },
+  onHide: function () {
+  },
+  onPullDownRefresh: function () {
+    this.setData({
+      projects_more: true,
+      projects_page: 1,
+      projects_change: true
+    })
+    this.getLive()
+    wx.stopPullDownRefresh()
+  },
+  onReachBottom: function () {
+    if (this.data.projects_more) {
+      var page = this.data.projects_page + 1
+      this.setData({
+        projects_page: page
+      })
+      this.getLive()
+    }
+  },
+  getLive: function () {
+    var that = this
+    var url = 'v1/live_broad/list'
+	var params = {
+	  page: this.data.projects_page,
+	  per_page: this.data.projects_per_page
+	}
+    var success = function (res) {
+      console.log('res',res);
+	  var result = that.data.projects.concat(res.data.list || [])
+	  that.setData({
+		  projects:result
+	  })
+	  
+	  var listMore = res.data.list_count > that.data.projects.length
+	  that.setData({
+	    projects_more: listMore
+	  })
+	  
+    }
+    _request.$get(url, params, success)
+  },
+  toLiveRoom: function (val) {
+    var id = val.currentTarget.dataset.val
+	let roomId = [id] // 填写具体的房间号,可通过下面【获取直播房间列表】 API 获取
+	let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
+	wx.navigateTo({
+		url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}`
+	})
+  },
+  
+  onShareAppMessage: function (val) {
+    return _request.share({
+      // path: '/pages/start/start?url=pages/projects/projects',
+      sc: 'xcx_products'
+    })
+  }
+})

+ 10 - 0
pages/livelist/livelist.json

@@ -0,0 +1,10 @@
+{
+  "navigationBarTitleText": "直播列表",
+  "usingComponents": {
+    "currency": "../../component/currency/currency",
+    "format-time": "../../component/formatTime/formatTime"
+  },
+  "enablePullDownRefresh": true,
+  "backgroundColor": "#f2f4f6",
+  "backgroundTextStyle": "dark"
+}

+ 16 - 0
pages/livelist/livelist.wxml

@@ -0,0 +1,16 @@
+<view class="bg">
+  <view class="projects">
+    <view class="projectbg">
+      <view class="livelist" wx:key="{{index}}" wx:for="{{projects}}"  data-val="{{item.room_id}}" bindtap="toLiveRoom">
+		  
+	   <image class="project-right" src="{{item.cover}}"></image>
+	   <view class="title">{{item.title}} <span>房间号{{item.room_id}}</span></view>
+	   <view class="startt">开播时间:{{item.begin_time}} - {{item.end_hour}}</view>
+	   <view class="status">{{item.state}}</view>
+        <view class="clean"></view>
+      </view>
+      
+      <view><text wx:if="{{projects_more}}" style="text-align: center;padding: 10px;color: #999;display: block;margin-bottom: 15px;">正在努力加载...</text></view>
+    </view>
+  </view>
+</view>

+ 35 - 0
pages/livelist/livelist.wxss

@@ -0,0 +1,35 @@
+.livelist{
+    width: 46%;
+    float: left;
+    margin: 0 2%;
+    margin-top: 10px;
+    padding: 15rpx;
+    overflow: hidden;
+    box-sizing: border-box;
+    border: 1px solid #ddd;
+	position: relative;
+}
+.livelist image{
+	    max-height: 100%;
+	    width: 100%;
+	    height: 280rpx;
+		margin-bottom: 15rpx;
+}
+.livelist .title{
+	font-size: 35rpx;
+}
+.livelist .title span{
+	    font-size: 20rpx;
+	    float: right;
+	    line-height: 46rpx;
+	    color: #eab86a;
+}
+.livelist .startt{
+	font-size: 24rpx;
+	color: #eab86a;
+}
+.livelist .status{
+	    position: absolute;
+	    top: 5px;
+	    color: #f00;
+}

+ 2 - 2
utils/request.js

@@ -1,7 +1,7 @@
 // // 新正式(未审批)
-//const apiHost = 'https://fohowapi.hiwavo.com/' 
+// const apiHost = 'https://fohowapi.hiwavo.com/' 
 // 测试
-   const apiHost = 'https://tfohowapi.hiwavo.com/'
+const apiHost = 'https://tfohowapi.hiwavo.com/'
 
 function $get (url, params, success, fail) {
   wx.showNavigationBarLoading()