|
@@ -0,0 +1,107 @@
|
|
|
+import http from '../../base/httputil'
|
|
|
+const app = getApp()
|
|
|
+
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 控制上拉到底部时是否出现 "数据加载中..."
|
|
|
+ */
|
|
|
+ hidden: true,
|
|
|
+ /**
|
|
|
+ * 数据是否正在加载中,避免数据多次加载
|
|
|
+ */
|
|
|
+ loadingData: false,
|
|
|
+ enterpriseList: [],
|
|
|
+ pageNum: 1 // 页码
|
|
|
+ },
|
|
|
+ onLoad: function () {
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中'
|
|
|
+ // })
|
|
|
+ this.loadData(this.data.pageNum)
|
|
|
+ },
|
|
|
+ //加载数据
|
|
|
+ loadData: function(num) {
|
|
|
+ http.send_post("/system/AppEnterpriseController/getInitEnterpriseList", null, this.getQiyeEnterpriseListSuccess)
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ getQiyeEnterpriseListSuccess(res) {
|
|
|
+
|
|
|
+ console.log("####"+this.data.pageNum)
|
|
|
+ this.setData({
|
|
|
+ enterpriseList: res.data.rows,
|
|
|
+ })
|
|
|
+ var that = this
|
|
|
+ if(this.data.pageNum==1){
|
|
|
+ // 隐藏导航栏加载框
|
|
|
+ setTimeout(function() {
|
|
|
+ that.setData({
|
|
|
+ loadingData: false
|
|
|
+ });
|
|
|
+ wx.hideNavigationBarLoading();
|
|
|
+ // 停止下拉动作
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
+
|
|
|
+ },1000)
|
|
|
+
|
|
|
+ }else{
|
|
|
+ // 隐藏加载框
|
|
|
+
|
|
|
+ setTimeout(function() {
|
|
|
+ that.setData({
|
|
|
+ hidden: true,
|
|
|
+ loadingData: false
|
|
|
+ });
|
|
|
+
|
|
|
+ wx.hideLoading(); },1000)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+ // 显示顶部刷新图标
|
|
|
+ wx.showNavigationBarLoading();
|
|
|
+ var that = this;
|
|
|
+ var loadingData = this.data.loadingData
|
|
|
+ if (loadingData) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ pageNum:1
|
|
|
+ })
|
|
|
+ this.loadData(this.data.pageNum)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+* 页面上拉触底事件的处理函数
|
|
|
+*/
|
|
|
+onReachBottom: function () {
|
|
|
+ var loadingData = this.data.loadingData
|
|
|
+ // 显示加载图标
|
|
|
+ wx.showLoading({
|
|
|
+ title: '玩命加载中',
|
|
|
+ })
|
|
|
+ var hidden = this.data.hidden
|
|
|
+ // 页数+1
|
|
|
+ this.setData({
|
|
|
+ pageNum: this.data.pageNum + 1
|
|
|
+ })
|
|
|
+ if (hidden) {
|
|
|
+ this.setData({
|
|
|
+ hidden: false
|
|
|
+ });
|
|
|
+ console.info(this.data.hidden);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (loadingData) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ loadingData: true
|
|
|
+ });
|
|
|
+ this.loadData(this.data.pageNum);
|
|
|
+ },
|
|
|
+})
|