浏览代码

比賽管理

zs 2 年之前
父节点
当前提交
4484419d4c
共有 1 个文件被更改,包括 36 次插入2 次删除
  1. 36 2
      pages/match/index.js

+ 36 - 2
pages/match/index.js

@@ -56,7 +56,11 @@ Page({
                 logo: [{ url: '/image/beijing.jpeg' }],
                 status: '2'
             }
-        ]
+        ],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
     },
     // 跳转菜单
     tabPath(e) {
@@ -75,10 +79,40 @@ Page({
         let data = that.data.statusList[e.detail.value];
         that.setData({ 'searchInfo.status': data.value });
     },
+    // 分页
+    toPage: function () {
+        const that = this;
+        let list = that.data.list;
+        let limit = that.data.limit;
+        if (that.data.total > list.length) {
+            wx.showLoading({ title: '加载中', mask: true })
+            let page = that.data.page + 1;
+            that.setData({ page: page })
+            let skip = page * limit;
+            that.setData({ skip: skip })
+            that.watchLogin();
+            wx.hideLoading()
+        } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
+    },
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) { },
+    onLoad: function (options) {
+        const that = this;
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => { },
+            fail: async res => {
+                // wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */