123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- const app = getApp()
- Page({
- data: {
- frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 5,
- },
- back: function () {
- wx.navigateBack({ delta: 1 })
- },
-
- toView: function (e) {
- const that = this;
- that.setData({ skip: 0, page: 0, list: [] })
- let { item } = e.currentTarget.dataset;
- wx.navigateTo({ url: `/pages/user/info?openid=${item.openid}` })
- },
-
- 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) { },
-
- watchLogin: async function () {
- const that = this;
-
- wx.getStorage({
- key: 'user',
- success: async res => {
- let info = { skip: that.data.skip, limit: that.data.limit };
- let arr;
- arr = await app.$get(`/newCourt/api/user`, { ...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' })
- }
- })
- },
-
- onReady: function () {
- },
-
- onShow: function () {
- const that = this;
-
- that.watchLogin();
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- console.log('1');
- },
-
- onReachBottom: function () {
- console.log('2');
- },
-
- onShareAppMessage: function () {
- }
- })
|