var _request = require('../../utils/request.js') Page({ data: { projects_page: 1, projects_per_page: 8, 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.setData({ projects_more: true, projects_page: 1, projects_change: true, projects:[] }) this.getLive() }, onUnload: function () { }, onHide: function () { }, onPullDownRefresh: function () { this.setData({ projects_more: true, projects_page: 1, projects_change: true, projects:[] }) this.getLive('refresh') 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 (type) { 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); if(type != 'refresh'){ var result = that.data.projects.concat(res.data.list || []) that.setData({ projects:result }) }else{ that.setData({ projects:res.data.list }) } 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' }) } })