guhongwei il y a 2 ans
Parent
commit
cb51218712
7 fichiers modifiés avec 39 ajouts et 51 suppressions
  1. 6 11
      pages/address/list.js
  2. 2 1
      pages/home/index.js
  3. 3 7
      pages/news/index.js
  4. 6 11
      pages/project/list.js
  5. 2 5
      pages/topic/index.js
  6. 19 15
      pages/user/list.js
  7. 1 1
      pages/user/list.wxml

+ 6 - 11
pages/address/list.js

@@ -4,9 +4,10 @@ Page({
         frameStyle: { useTop: true, name: '比赛场地', leftArrow: true, useBar: false },
         frameStyle: { useTop: true, name: '比赛场地', leftArrow: true, useBar: false },
         list: [],
         list: [],
         total: 0,
         total: 0,
-        limit: 5,
         page: 0,
         page: 0,
-        skip: 0
+        skip: 0,
+        limit: 5,
+
     },
     },
     // 返回
     // 返回
     back: function () {
     back: function () {
@@ -14,18 +15,14 @@ Page({
     },
     },
     toCommon: function (e) {
     toCommon: function (e) {
         const that = this;
         const that = this;
-        that.setData({ list: [] })
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
+        that.setData({ skip: 0, page: 0, list: [] })
         const { route } = e.currentTarget.dataset;
         const { route } = e.currentTarget.dataset;
         if (route) wx.navigateTo({ url: `/pages/${route}` });
         if (route) wx.navigateTo({ url: `/pages/${route}` });
     },
     },
     // 修改
     // 修改
     toEdit: function (e) {
     toEdit: function (e) {
         const that = this;
         const that = this;
-        that.setData({ list: [] })
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
+        that.setData({ skip: 0, page: 0, list: [] })
         let { item } = e.currentTarget.dataset;
         let { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/address/add?id=${item._id}` })
         wx.navigateTo({ url: `/pages/address/add?id=${item._id}` })
     },
     },
@@ -41,9 +38,7 @@ Page({
                     const arr = await app.$delete(`/newCourt/api/ground/${item._id}`);
                     const arr = await app.$delete(`/newCourt/api/ground/${item._id}`);
                     if (arr.errcode == '0') {
                     if (arr.errcode == '0') {
                         wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
                         wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
-                        that.setData({ list: [] })
-                        that.setData({ skip: 0 })
-                        that.setData({ page: 0 })
+                        that.setData({ skip: 0, page: 0, list: [] })
                         that.watchLogin()
                         that.watchLogin()
                     } else {
                     } else {
                         wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
                         wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })

+ 2 - 1
pages/home/index.js

@@ -5,10 +5,10 @@ Page({
         lingdang: '/image/lingdang.png',
         lingdang: '/image/lingdang.png',
         user: {},
         user: {},
         list: [],
         list: [],
+        total: 0,
         page: 0,
         page: 0,
         skip: 0,
         skip: 0,
         limit: 5,
         limit: 5,
-        total: 0,
     },
     },
     // 跳转菜单
     // 跳转菜单
     tabPath(e) {
     tabPath(e) {
@@ -20,6 +20,7 @@ Page({
         if (route) wx.navigateTo({ url: `/pages/${route}` });
         if (route) wx.navigateTo({ url: `/pages/${route}` });
     },
     },
     toView: function (e) {
     toView: function (e) {
+        that.setData({ skip: 0, page: 0, list: [] })
         const { item } = e.currentTarget.dataset;
         const { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/match/info?id=${item._id}` })
         wx.navigateTo({ url: `/pages/match/info?id=${item._id}` })
     },
     },

+ 3 - 7
pages/news/index.js

@@ -11,10 +11,10 @@ Page({
             ],
             ],
         },
         },
         list: [],
         list: [],
+        total: 0,
         page: 0,
         page: 0,
         skip: 0,
         skip: 0,
         limit: 5,
         limit: 5,
-        total: 0,
         typeList: news_type,
         typeList: news_type,
     },
     },
     // 跳转菜单
     // 跳转菜单
@@ -26,17 +26,13 @@ Page({
     tabsChange: function (e) {
     tabsChange: function (e) {
         const that = this;
         const that = this;
         that.setData({ 'tabs.active': e.detail.name });
         that.setData({ 'tabs.active': e.detail.name });
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
-        that.setData({ list: [] })
+        that.setData({ skip: 0, page: 0, list: [] })
         that.watchLogin()
         that.watchLogin()
     },
     },
     // 详情
     // 详情
     toView: function (e) {
     toView: function (e) {
         const that = this;
         const that = this;
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
-        that.setData({ list: [] })
+        that.setData({ skip: 0, page: 0, list: [] })
         const { item } = e.currentTarget.dataset;
         const { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/news/info?id=${item._id}` })
         wx.navigateTo({ url: `/pages/news/info?id=${item._id}` })
     },
     },

+ 6 - 11
pages/project/list.js

@@ -4,9 +4,10 @@ Page({
         frameStyle: { useTop: true, name: '比赛项目', leftArrow: true, useBar: false },
         frameStyle: { useTop: true, name: '比赛项目', leftArrow: true, useBar: false },
         list: [],
         list: [],
         total: 0,
         total: 0,
-        limit: 5,
         page: 0,
         page: 0,
-        skip: 0
+        skip: 0,
+        limit: 5,
+
     },
     },
     // 返回
     // 返回
     back: function () {
     back: function () {
@@ -14,18 +15,14 @@ Page({
     },
     },
     toCommon: function (e) {
     toCommon: function (e) {
         const that = this;
         const that = this;
-        that.setData({ list: [] })
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
+        that.setData({ skip: 0, page: 0, list: [] })
         const { route } = e.currentTarget.dataset;
         const { route } = e.currentTarget.dataset;
         if (route) wx.navigateTo({ url: `/pages/${route}` });
         if (route) wx.navigateTo({ url: `/pages/${route}` });
     },
     },
     // 修改
     // 修改
     toEdit: function (e) {
     toEdit: function (e) {
         const that = this;
         const that = this;
-        that.setData({ list: [] })
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
+        that.setData({ skip: 0, page: 0, list: [] })
         let { item } = e.currentTarget.dataset;
         let { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/project/add?id=${item._id}` })
         wx.navigateTo({ url: `/pages/project/add?id=${item._id}` })
     },
     },
@@ -41,9 +38,7 @@ Page({
                     const arr = await app.$delete(`/newCourt/api/matchProject/${item._id}`);
                     const arr = await app.$delete(`/newCourt/api/matchProject/${item._id}`);
                     if (arr.errcode == '0') {
                     if (arr.errcode == '0') {
                         wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
                         wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
-                        that.setData({ list: [] })
-                        that.setData({ skip: 0 })
-                        that.setData({ page: 0 })
+                        that.setData({ skip: 0, page: 0, list: [] })
                         that.watchLogin()
                         that.watchLogin()
                     } else {
                     } else {
                         wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
                         wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })

+ 2 - 5
pages/topic/index.js

@@ -3,11 +3,10 @@ Page({
     data: {
     data: {
         frameStyle: { useTop: true, name: '话题', leftArrow: false, useBar: true },
         frameStyle: { useTop: true, name: '话题', leftArrow: false, useBar: true },
         list: [],
         list: [],
-        //分页
+        total: 0,
         skip: 0,
         skip: 0,
         page: 0,
         page: 0,
         limit: 5,
         limit: 5,
-        total: 0
     },
     },
     // 跳转菜单
     // 跳转菜单
     tabPath(e) {
     tabPath(e) {
@@ -16,9 +15,7 @@ Page({
     },
     },
     toView: function (e) {
     toView: function (e) {
         const that = this;
         const that = this;
-        that.setData({ skip: 0 })
-        that.setData({ page: 0 })
-        that.setData({ list: [] })
+        that.setData({ skip: 0, page: 0, list: [] })
         let { item } = e.currentTarget.dataset;
         let { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/topic/info?id=${item._id}` })
         wx.navigateTo({ url: `/pages/topic/info?id=${item._id}` })
     },
     },

+ 19 - 15
pages/user/list.js

@@ -2,32 +2,36 @@ const app = getApp()
 Page({
 Page({
     data: {
     data: {
         frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
         frameStyle: { useTop: true, name: '用户管理', leftArrow: true, useBar: false },
-        oldList: [],
         list: [],
         list: [],
-        limit: 5,
-        skip: 0,
+        total: 0,
         page: 0,
         page: 0,
+        skip: 0,
+        limit: 5,
     },
     },
     back: function () {
     back: function () {
-        wx.navigateBack({
-            delta: 1,
-        })
+        wx.navigateBack({ delta: 1 })
     },
     },
     // 详细信息
     // 详细信息
     toView: function (e) {
     toView: function (e) {
         const that = this;
         const that = this;
-        that.setData({ list: [] })
+        that.setData({ skip: 0, page: 0, list: [] })
         let { item } = e.currentTarget.dataset;
         let { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/user/info?openid=${item.openid}` })
         wx.navigateTo({ url: `/pages/user/info?openid=${item.openid}` })
     },
     },
     // 分页
     // 分页
-    upcroll: function () {
+    toPage: function () {
         const that = this;
         const that = this;
-        let page = that.data.page + 1;
-        that.setData({ page })
-        const skip = page * that.data.limit;
-        that.setData({ skip });
-        that.watchLogin()
+        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 }) }
     },
     },
     /**
     /**
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
@@ -44,8 +48,8 @@ Page({
                 let arr;
                 let arr;
                 arr = await app.$get(`/newCourt/api/user`, { ...info });
                 arr = await app.$get(`/newCourt/api/user`, { ...info });
                 if (arr.errcode == '0') {
                 if (arr.errcode == '0') {
-                    if (arr.data && arr.data.length > 0) that.setData({ list: [...that.data.list, ...arr.data] })
-                    else wx.showToast({ title: `没有更多数据`, icon: 'success', duration: 2000 })
+                    that.setData({ list: [...that.data.list, ...arr.data] })
+                    that.setData({ total: arr.total })
                 }
                 }
                 else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
                 else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
             },
             },

+ 1 - 1
pages/user/list.wxml

@@ -6,7 +6,7 @@
             </view>
             </view>
         </view>
         </view>
         <view class="two">
         <view class="two">
-            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="upcroll">
+            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
                 <view class="list-scroll-view">
                 <view class="list-scroll-view">
                     <view class="list" wx:for="{{list}}" wx:key="item">
                     <view class="list" wx:for="{{list}}" wx:key="item">
                         <view class="name">{{item.name}}</view>
                         <view class="name">{{item.name}}</view>