YY 2 lat temu
rodzic
commit
4f5491e11e
1 zmienionych plików z 101 dodań i 100 usunięć
  1. 101 100
      pages/school/index.js

+ 101 - 100
pages/school/index.js

@@ -1,111 +1,112 @@
 const app = getApp()
 const moment = require("../../utils/moment.min")
 Page({
-    data: {
-        frameStyle: { useTop: true, name: '羽校', leftArrow: false, useBar: true },
-        user: {},
-        list: [],
-        total: 0,
-        page: 0,
-        skip: 0,
-        limit: 5,
-    },
-    // 跳转菜单
-    tabPath(e) {
-        let { route } = e.detail.detail;
-        if (route) wx.redirectTo({ url: `/${route}` })
-    },
-    // 进入系统
-    toJoin: function () {
-        const that = this;
-        that.setData({ skip: 0, page: 0, list: [] })
-        wx.navigateTo({ url: `/pages/smy/index` })
-    },
-    // 查看详情
-    toView: function (e) {
-        const that = this;
-        const { item } = e.currentTarget.dataset;
-        that.setData({ skip: 0, page: 0, list: [] })
-        wx.navigateTo({ url: `/pages/school/info?id=${item._id}` })
-    },
-    // 分页
-    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) { },
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady: function () { },
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow: function () {
-        const that = this;
-        // 监听用户是否登录
-        that.watchLogin();
-    },
+  data: {
+    frameStyle: { useTop: true, name: '羽校', leftArrow: false, useBar: true },
+    user: {},
+    list: [],
+    total: 0,
+    page: 0,
+    skip: 0,
+    limit: 5,
+  },
+  // 跳转菜单
+  tabPath(e) {
+    let { route } = e.detail.detail;
+    if (route) wx.redirectTo({ url: `/${route}` })
+  },
+  // 进入系统
+  toJoin: function () {
+    const that = this;
+    that.setData({ skip: 0, page: 0, list: [] })
+    wx.navigateTo({ url: `/pages/smy/index` })
+  },
+  // 查看详情
+  toView: function (e) {
+    const that = this;
+    const { item } = e.currentTarget.dataset;
+    that.setData({ skip: 0, page: 0, list: [] })
+    wx.navigateTo({ url: `/pages/school/info?id=${item._id}` })
+  },
+  // 分页
+  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) { },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () { },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    const that = this;
     // 监听用户是否登录
-    watchLogin: async function () {
-        const that = this;
-        wx.getStorage({
-            key: 'user',
-            success: async res => {
-                that.setData({ user: res.data })
-                let info = { skip: that.data.skip, limit: that.data.limit };
-                const arr = await app.$get(`/school`, { ...info });
-                if (arr.errcode == '0') {
-                    that.setData({ list: [...that.data.list, ...arr.data] });
-                    that.setData({ total: arr.total })
-                } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
-            },
-            fail: async res => {
-                wx.redirectTo({ url: '/pages/index/index' })
-            }
-        })
-    },
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide: function () {
+    that.watchLogin();
+  },
+  // 监听用户是否登录
+  watchLogin: async function () {
+    const that = this;
+    wx.getStorage({
+      key: 'user',
+      success: async res => {
+        that.setData({ user: res.data })
+        let info = { skip: that.data.skip, limit: that.data.limit };
+        const arr = await app.$get(`/school`, { ...info });
+        if (arr.errcode == '0') {
+          that.setData({ list: [...that.data.list, ...arr.data] });
+          that.setData({ total: arr.total })
+        } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
+      },
+      fail: async res => {
+        wx.redirectTo({ url: '/pages/index/index' })
+      }
+    })
+  },
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    const that = this;
+    that.setData({ skip: 0, page: 0, list: [] })
+  },
 
-    },
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
 
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload: function () {
+  },
 
-    },
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
 
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh: function () {
+  },
 
-    },
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
 
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage: function () {
-
-    }
+  }
 })