123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- id:"",
- list:{},
- imgPath: util.config.imgPath,
- isLoadMore: true,
- pageIndex: 1,
- pageSize: 10
- },
- onLoad: function (options) {
- if(options.roomid) {
- // wx.navigateTo({
- // url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${options.roomid}`
- // })
- }
- this.getList(false);
- },
- getList(load){
- let self = this;
- util.ajax({
- func: "v2/live/room/applet/live/list",
- data: {"pageIndex": self.data.pageIndex }
- }, function (res) {
- if (res.code == 0) {
- let isLoadMore = true;
- let newData = res.data ? res.data : [];
- let oldData = !load ? newData : [...self.data.list, ...newData];
- if (newData.length < self.data.pageSize || oldData.length > self.data.pageSize) {
- isLoadMore = false;
- }
- self.setData({ list: oldData, isLoadMore: isLoadMore });
- }else
- util.showTips(res.reason);
- });
- },
- onPullDownRefresh: function () {
- var self = this;
- wx.showNavigationBarLoading();
- setTimeout(function () {
- self.getList(false);
- wx.hideNavigationBarLoading();
- wx.stopPullDownRefresh();
- }, 1500);
- },
- onReachBottom: function () {
- var self = this;
- if (self.data.isLoadMore == false) {
- return false;
- }
- setTimeout(function () {
- self.setData({ pageIndex: self.data.pageIndex + 1 });
- self.getList(true);
- }, 1000);
- },
- onShareAppMessage(e) {
- if (e.from == "button") {
- return {
- title: `好友邀请您一起参与《${e.target.dataset.title}》`,
- path: '/pages/public/live/list?roomid='+e.target.dataset.roomid,
- imageUrl:e.target.dataset.img
- }
- } else {
- return {
- title: '好友邀请您一起参与直播',
- path: '/pages/public/live/list'
- }
- }
- }
- })
|