|
- const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
- let config = require("../../../config/config.js");
- let Http = require("../../../utils/HttpBasics");
- const util = require("../../../utils/util");
- let app = getApp();
- const imgurl = require("../../../utils/imgurl");
- const format = require("../../../utils/util.js");
- Page({
- data: {
- navigationBarHeight,
- noOrdersUrl: imgurl.noOrders.url,
- loadingUrl: imgurl.loading.url,
- wmhome: imgurl.wmhome.url,
- wmdiscount: imgurl.wmdiscount.url,
- wmgive: imgurl.wmgive.url,
- tabs: [{
- key: "all",
- name: "全部"
- },
- {
- key: 0,
- name: "待付款"
- },
- {
- key: 1,
- name: "已完成"
- }
- ],
- liveStatusList:[
- {
- name:'直播中',
- value:101
- },
- {
- name:'未开始',
- value:102
- },
- {
- name:'已结束',
- value:103
- },
- {
- name:'禁播',
- value:104
- },
- {
- name:' 暂停中',
- value:105
- },
- {
- name:' 异常',
- value:106
- },
- {
- name:'已过期',
- value:107
- },
- ],
- list: [],
- current: "",
- loading: true, //"上拉加载"的变量,默认false,隐藏
- current_scroll: "1",
- allow_load: true,
- page: 1,
- content: "",
- roomInfos:[],
- customParams:''
- },
- onLoad(e) {
- // this.getList(e.id, 1);
- this.getRoomList(1);
- let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 }))
- this.setData({
- customParams
- })
- },
- goDetail(e){
- console.log(e.currentTarget.dataset.data)
- let customParams = encodeURIComponent(JSON.stringify({ path: '/pages2live/livelist/index', pid: e.currentTarget.dataset.data.roomid })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
- wx.navigateTo({
- url: `plugin-private://wx2b03c6e691cd7370/pages2/live-player-plugin?room_id=${e.currentTarget.dataset.data.roomid}&type=10&custom_params=${customParams}`,
- })
- },
- //获取房间列表
- getRoomList(pageNum){
- let that=this;
- if (this.data.allow_load) {
- this.setData({
- loading: true,
- content: '小主,我在玩命加载中...'
- })
- Http.get({
- url: config.api.getRoomList,
- data: {
- start:pageNum*5-5,
- limit:5,
- token: app.globalData.token,
- appId:config.weapp.AppId
- }
- }).then(res => {
- console.log(res)
- this.setData({
- loading: false,
- })
- res.data.roomInfos.map((item,index)=>{
- console.log(parseInt(item.startTime))
-
- item.startTimeStr = format.formatTime(
- parseInt(item.startTime+"000"),
- "MM-dd hh:mm"
- );
- item.endTimeStr = format.formatTime(
- parseInt(item.endTime+"000"),
- "MM-dd hh:mm"
- );
- this.data.liveStatusList.map((item02,index02)=>{
- if(item.liveStatus==item02.value){
- item.statusName=item02.name
- }
- })
- })
- var tmpArr = this.data.roomInfos;
- tmpArr.push.apply(tmpArr, res.data.roomInfos);
- if(tmpArr.length==res.data.total){
- this.setData({
- allow_load:false
- })
- }
- this.setData({
- roomInfos:tmpArr
- })
- }).catch(err=>{
- that.setData({
- loading: false,
- })
- })
- }else{
- this.setData({
- loading: true,
- content: "——— 再拉裤子就掉了啦 ———"
- })
- setTimeout(function () {
- that.setData({
- loading: false,
- })
- }, 1400)
- }
- },
- onReachBottom: function () {
- var that = this;
- that.data.page++;
- that.setData({
- page: that.data.page
- });
- this.getRoomList(that.data.page);
- }
- });
|