|
@@ -51,6 +51,10 @@ Page({
|
|
player_two_score: '5',
|
|
player_two_score: '5',
|
|
}
|
|
}
|
|
],
|
|
],
|
|
|
|
+ total: 0,
|
|
|
|
+ page: 0,
|
|
|
|
+ skip: 0,
|
|
|
|
+ limit: 5,
|
|
},
|
|
},
|
|
// 返回
|
|
// 返回
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
@@ -58,6 +62,30 @@ Page({
|
|
tabsChange: function (e) {
|
|
tabsChange: function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
that.setData({ 'tabs.active': e.detail.active });
|
|
that.setData({ 'tabs.active': e.detail.active });
|
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] });
|
|
|
|
+ that.watchLogin();
|
|
|
|
+ },
|
|
|
|
+ //通用添加 详细信息
|
|
|
|
+ toCommon: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item, route } = e.currentTarget.dataset;
|
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] });
|
|
|
|
+ wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._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 }) }
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
@@ -78,9 +106,21 @@ Page({
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: async function () {
|
|
watchLogin: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ const tabs = that.data.tabs;
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
key: 'user',
|
|
key: 'user',
|
|
- success: async res => { },
|
|
|
|
|
|
+ success: async res => {
|
|
|
|
+ if (tabs.active == 'a') {
|
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, user_id: res.data._id };
|
|
|
|
+ let arr = await app.$get(`/msgs`, { ...info }, 'race');
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ let groupList = [...that.data.groupList, ...arr.data]
|
|
|
|
+ that.setData({ groupList })
|
|
|
|
+ that.setData({ total: arr.total })
|
|
|
|
+
|
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
fail: async res => {
|
|
fail: async res => {
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
}
|
|
}
|