guhongwei 2 年之前
父節點
當前提交
fcda681642
共有 4 個文件被更改,包括 118 次插入72 次删除
  1. 1 1
      app.json
  2. 87 66
      pages/test/index.js
  3. 7 3
      pages/test/index.wxml
  4. 23 2
      pages/test/index.wxss

+ 1 - 1
app.json

@@ -1,6 +1,5 @@
 {
     "pages": [
-        "pages/notice/index",
         "pages/index/index",
         "pages/login/index",
         "pages/register/index",
@@ -32,6 +31,7 @@
         "pages/teamapply/index",
         "pages/uploadimg/index",
         "pages/updatepd/index",
+        "pages/notice/index",
         "pages/notice/detail",
         "pages/test/index",
         "pages/logs/logs"

+ 87 - 66
pages/test/index.js

@@ -3,82 +3,103 @@ import WxValidate from '../../utils/wxValidate'
 const app = getApp()
 Page({
 
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    frameStyle: { useTop: true, name: '登录', leftArrow: false, useBar: false },
-    // 主体高度
-    infoHeight: '',
-  },
-  back: function () {
-    wx.navigateBack({ url: '/pages/home/index' })
-  },
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function (options) {
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '登录', leftArrow: false, useBar: false },
+        // 主体高度
+        infoHeight: '',
+        list: [],
+        total: 0,
+        skip: 0,
+        limit: 5,
+    },
+    back: function () {
+        wx.navigateBack({ url: '/pages/home/index' })
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        // 计算高度
+        this.searchHeight();
+        // 监听用户是否登录
+        this.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: function () {
+        const that = this;
+        wx.getStorage({
+            key: 'token',
+            success: async res => {
+                let page = { skip: that.data.skip, limit: that.data.limit }
+                const arr = await app.$get(`/courtAdmin/api/team`, page);
+                if (arr.errcode == '0') { that.setData({ list: arr.data }); that.setData({ total: arr.total }); }
+                else wx.showToast({ title: `${arr.errmsg}`, duration: 2000, icon: 'error' })
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
     // 计算高度
-    this.searchHeight()
-  },
-  // 计算高度
-  searchHeight: function () {
-    let frameStyle = this.data.frameStyle;
-    let client = app.globalData.client;
-    let infoHeight = client.windowHeight;
-    // 是否去掉状态栏
-    if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
-    // 是否减去底部菜单
-    if (frameStyle.useBar) infoHeight = infoHeight - 50;
-    if (infoHeight) this.setData({ infoHeight: infoHeight })
-  },
+    searchHeight: function () {
+        let frameStyle = this.data.frameStyle;
+        let client = app.globalData.client;
+        let infoHeight = client.windowHeight;
+        // 是否去掉状态栏
+        if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
+        // 是否减去底部菜单
+        if (frameStyle.useBar) infoHeight = infoHeight - 50;
+        if (infoHeight) this.setData({ infoHeight: infoHeight })
+    },
 
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+    },
 
-  },
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
 
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
+    },
 
-  },
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
 
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
+    },
 
-  },
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
 
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
+    },
 
-  },
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+        console.log('2');
+    },
 
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+        console.log('1');
+    },
 
-  },
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
 
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
-  }
+    }
 })

+ 7 - 3
pages/test/index.wxml

@@ -1,5 +1,9 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
-  <view slot="info" class="main" style="height:{{infoHeight}}px;">
-    模板
-  </view>
+    <view slot="info" class="main" style="height:{{infoHeight}}px;">
+        <view class="one">
+            <view class="list" wx:for="{{list}}" wx:key="item">
+                <view>{{item.name}}</view>
+            </view>
+        </view>
+    </view>
 </mobile-main>

+ 23 - 2
pages/test/index.wxss

@@ -1,4 +1,25 @@
 .main {
-  position: relative;
-  width: 100%;
+    position: relative;
+    width: 100%;
+    overflow-x: hidden;
+}
+
+.main .one {
+    float: left;
+    width: 95%;
+    padding: 10px;
+}
+
+.main .one .list {
+    float: left;
+    width: 95%;
+    padding: 10px;
+    background-color: #fff;
+    margin: 0 0 10px 0;
+    border-radius: 10px;
+    height: 150px;
+}
+
+.main .one .list:last-child {
+    margin: 0;
 }