zhanghongrui 2 년 전
부모
커밋
adcbcae1a0
7개의 변경된 파일151개의 추가작업 그리고 35개의 파일을 삭제
  1. 38 2
      base/httputil.js
  2. 14 2
      pages/index/index.js
  3. 2 2
      pages/index/index.wxml
  4. 70 23
      pages/notice/notice.js
  5. 1 2
      pages/notice/notice.json
  6. 4 4
      pages/notice/notice.wxml
  7. 22 0
      pages/notice/notice_details.wxml

+ 38 - 2
base/httputil.js

@@ -164,9 +164,10 @@ function post(url, data, successfun) {
 function get(url, data, successfun) {
   wx.request({
     url: BASE_Server + url, //仅为示例,并非真实的接口地址
-    method: "Get",
+    method: "GET",
     header: {
-      'content-type': 'application/x-www-form-urlencoded'
+      'content-type': 'application/x-www-form-urlencoded',
+      'Authorization': 'Bearer ' + app.globalToken
     },
     params: data,
     success(res) {
@@ -180,6 +181,40 @@ function get(url, data, successfun) {
   })
 }
 
+
+function send_get(url, data, successfun) {
+  console.log("令牌:", app.globalToken)
+  // if(app.globalToken==null){
+  //   wx.reLaunch({
+  //     url: '../denglu/denglu',
+  //   })
+  // }
+  //如果令牌为空或过期,需要重新请求
+
+  wx.request({
+    url: BASE_Server + url, //仅为示例,并非真实的接口地址 
+    method: "GET",
+    header: {
+      'content-type': 'application/json',
+      'Authorization': 'Bearer ' + app.globalToken
+    },
+    data: data,
+    success(res) {
+      // var d = decodeURIComponent(decodeURIComponent(res.data.data))
+      // var json = JSON.parse(d)
+      console.log("TAG","返回数据:"+res.data)
+      authToken(res.data)
+      successfun(res.data)
+    },
+    fail(res){
+      wx.showToast({
+        title: "网络请求失败",
+      })
+    }
+
+  })
+}
+
 function send_postdecode(url, data, successfun) {
   wx.request({
     url: BASE_Server + url, //仅为示例,并非真实的接口地址
@@ -237,6 +272,7 @@ module.exports = {
   post: post,
   // wxpost: wxpost,
   get: get,
+  send_get:send_get,
   send_postdecode: send_postdecode,
 
 

+ 14 - 2
pages/index/index.js

@@ -43,7 +43,8 @@ Page({
     //功能数据-孙一石
     //记录首页点击-登录后继续跳转
     dofun: null,
-    xunjianImgCount: 0
+    xunjianImgCount: 0,
+    NoticeTitle:"登录查看公告"
 
   },
 
@@ -189,9 +190,20 @@ Page({
     http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
   },
   initIndexPageSuccess(res) {
+    console.log("@@",res)
     this.setData({
-      xunjianImgCount: res.xunjianImgCount
+      xunjianImgCount: res.xunjianImgCount,
+     
     })
+    if(res.noticeList.length>0){
+      this.setData({
+        NoticeTitle:res.noticeList[0].noticeTitle
+      })
+    }else{
+      this.setData({
+        NoticeTitle:"暂无公告"
+      })
+    }
   },
 
   loginSuccess(res) {

+ 2 - 2
pages/index/index.wxml

@@ -53,8 +53,8 @@
   <!-- 通知公告 -->
   <view class="tzgg">
     <image class="img" src="{{host}}/images/xcx_lb.png" />
-    <b>[待办]</b>
-    <text>隐患排查已整改,请核查!</text>
+    <!-- <b>[待办]</b> -->
+    <text>{{NoticeTitle}}</text>
     <view class="more" data-fun="bindViewGengDuo" bindtap="init_userInfo">更多></view>
   </view>
   <!-- 中间图片banner -->

+ 70 - 23
pages/notice/notice.js

@@ -13,29 +13,49 @@ Page({
      */
     loadingData: false,
     enterpriseList: [],
+    isRefresh: true,
+    total: 0,
     pageNum: 1 // 页码
   },
   onLoad: function () {
     // wx.showLoading({
     //   title: '加载中'
     // })
-    this.loadData(this.data.pageNum)
+    this.loadData()
   },
   //加载数据
-  loadData: function (num) {
-    http.send_post("/system/AppEnterpriseController/getInitEnterpriseList", null, this.getQiyeEnterpriseListSuccess)
+  loadData: function () {
+    let obj = new Object()
+    obj.pageNum = this.data.pageNum
+    obj.pageSize = 10
+    obj.reasonable= false
+    http.send_get("/system/AppNoticeController/getNotice", obj, this.getQiyeEnterpriseListSuccess)
 
 
   },
 
   getQiyeEnterpriseListSuccess(res) {
 
-    console.log("####" + this.pageNum)
-    this.setData({
-      enterpriseList: res.rows,
+console.log("@@@@",res)
+     // 显示加载图标
+     wx.showLoading({
+      title: '玩命加载中',
     })
     var that = this
-    if (this.data.pageNum == 1) {
+
+    if(res.data.rows.length==0){
+      wx.showToast({
+        title: '暂无更多数据',
+        icon:"none"
+      })
+    }
+    if (this.data.isRefresh) {
+      this.setData({
+        enterpriseList: res.data.rows,
+        total: res.data.total
+      })
+
+
       // 隐藏导航栏加载框
       setTimeout(function () {
         that.setData({
@@ -44,10 +64,14 @@ Page({
         wx.hideNavigationBarLoading();
         // 停止下拉动作
         wx.stopPullDownRefresh();
+        wx.hideLoading()
 
       }, 1000)
 
     } else {
+      this.setData({
+        enterpriseList: this.data.enterpriseList.concat(res.data.rows)
+      })
       // 隐藏加载框
 
       setTimeout(function () {
@@ -59,9 +83,8 @@ Page({
         wx.hideLoading();
       }, 1000)
 
-
-
     }
+
   },
   onPullDownRefresh: function () {
     // 显示顶部刷新图标
@@ -72,37 +95,61 @@ Page({
       return;
     }
     that.setData({
-      pageNum: 1
+      pageNum: 1,
+      isRefresh: true
     })
-    this.loadData(this.data.pageNum)
+    this.loadData()
   },
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-    var loadingData = this.data.loadingData
-    // 显示加载图标
-    wx.showLoading({
-      title: '玩命加载中',
-    })
-    var hidden = this.data.hidden
+    let that = this
+    var loadingData = that.data.loadingData
+   
+    var hidden = that.data.hidden
     // 页数+1
-    this.setData({
-      pageNum: this.data.pageNum + 1
+    that.setData({
+      pageNum: that.data.pageNum + 1,
+      isRefresh: false
     })
     if (hidden) {
-      this.setData({
+      that.setData({
         hidden: false
       });
-      console.info(this.data.hidden);
+      console.info(that.data.hidden);
     }
 
     if (loadingData) {
       return;
     }
-    this.setData({
+    that.setData({
       loadingData: true
     });
-    this.loadData(this.data.pageNum);
+
+    
+    //console.log("@@@@"+Math.ceil(this.data.total/10))
+   // if(Math.ceil(that.data.total/10)>=that.data.pageNum){
+      that.loadData();
+  
+    // }else{
+     
+    //   setTimeout(function () {
+    //     that.setData({
+    //       hidden: true,
+    //     });
+
+    //   }, 2000)
+    // }
+
+   
   },
+
+
+  bindViewDetails() {
+
+    wx.navigateTo({
+      url: '../notice/notice_details?busEnterpriseId=' +"d"
+    })
+  }
 })

+ 1 - 2
pages/notice/notice.json

@@ -11,8 +11,7 @@
   "onPullDownRefresh": true,
   "onReachBottom": true,
 
-  "navigationBarTitleText": "公告",
-  "onReachBottomDistance":10
+  "navigationBarTitleText": "公告"
 
 }
 

+ 4 - 4
pages/notice/notice.wxml

@@ -4,10 +4,10 @@
 
 <!-- 列表 -->
 <view class="list_vi">
-    <view class="list_li" bindtap="bindViewDetails" wx:for="{{enterpriseList}}" wx:key="index" data-enterpriseid="{{item.busEnterpriseId}}">
-      <i class="list_icon iconfont icon-queding" wx:if="{{item.riskCount == 0}}"></i>
-      <i class="list_icon iconfont icon-yingjipingtai" wx:if="{{item.riskCount > 0}}"></i>
-      <text>{{item.businessName}}</text>
+    <view class="list_li" bindtap="bindViewDetails" wx:for="{{enterpriseList}}" wx:key="index" data-noticeId="{{item.noticeId}}">
+      <!-- <i class="list_icon iconfont icon-queding" wx:if="{{item.riskCount == 0}}"></i>
+      <i class="list_icon iconfont icon-yingjipingtai" wx:if="{{item.riskCount > 0}}"></i> -->
+      <text>{{item.noticeTitle}}</text>
       <i class="iconfont icon-xiangyou list_right"></i>
     </view>
     <view class='data-loading' hidden='{{hidden}}'>

+ 22 - 0
pages/notice/notice_details.wxml

@@ -0,0 +1,22 @@
+
+
+
+
+<!-- 列表 -->
+<view class="list_vi">
+    <view class="list_li" bindtap="bindViewDetails" wx:for="{{enterpriseList}}" wx:key="index" data-noticeId="{{item.noticeId}}">
+      <!-- <i class="list_icon iconfont icon-queding" wx:if="{{item.riskCount == 0}}"></i>
+      <i class="list_icon iconfont icon-yingjipingtai" wx:if="{{item.riskCount > 0}}"></i> -->
+      <text>{{item.noticeTitle}}</text>
+      <i class="iconfont icon-xiangyou list_right"></i>
+    </view>
+    <view class='data-loading' hidden='{{hidden}}'>
+    数据加载中...
+  </view>
+    </view>
+
+
+
+
+
+