zhaoxiaohai 3 年之前
父节点
当前提交
81ff892a63
共有 2 个文件被更改,包括 50 次插入38 次删除
  1. 48 36
      pages/tabbar/home/index.js
  2. 2 2
      pages/tabbar/home/index.wxml

+ 48 - 36
pages/tabbar/home/index.js

@@ -1,4 +1,5 @@
 const _Http = getApp().globalData.http;
+let DataCarousel = null;
 Page({
 
     /**
@@ -10,6 +11,8 @@ Page({
         gridList: [],
         showAnnunciate: false, //显示最新通告
         unreadNum: 0, //通告未读
+        notice: "",
+        msgCount: 1,
     },
 
     /**
@@ -98,12 +101,46 @@ Page({
             })
         })
     },
+    /* 获取最新信息 */
+    queryMessage(i) {
+        if (i == 5) return;
+        _Http.basic({
+            "classname": "system.message.Message",
+            "method": "queryMessage",
+            content: {
+                nocache: true,
+                pageNumber: 1,
+                pageSize: 3,
+                pageTotal: 1,
+                type: "系统"
+            },
+        }).then(res => {
+            if (res.msg != '成功') return this.queryMessage(i + 1);
+            this.setData({
+                msgList: res.data,
+                notice: res.data[0]
+            })
+            this.startDataCarousel();
+        })
+    },
+    startDataCarousel() {
+        clearInterval(DataCarousel);
+        DataCarousel = setInterval(() => {
+            let count = this.data.msgCount < this.data.msgList.length ? this.data.msgCount : 0;
+            console.log(count)
+            this.setData({
+                msgCount: count + 1,
+                notice: this.data.msgList[count]
+            })
+        }, 5000)
+    },
     /* 更新站点信息 */
     refreshData(item) {
         this.setData({
             user: item
         })
         this.queryNoticeList(0); //获取通告列表
+        this.queryMessage(0)
     },
     /* 宫格区域应用程序 */
     applications(e) {
@@ -114,6 +151,15 @@ Page({
             url: `${item.path}?auth=${JSON.stringify(item.apps)}`,
         });
     },
+    /* 去消息详情 */
+    toMsg(e) {
+        const {
+            item
+        } = e.currentTarget.dataset;
+        wx.navigateTo({
+            url: '/pages/tabbar/message/details?id=' + item.objectid,
+        })
+    },
     /* 去通告 */
     toAnnunciate() {
         this.applications({
@@ -124,52 +170,18 @@ Page({
             }
         })
     },
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {
-
-    },
-
     /**
      * 生命周期函数--监听页面显示
      */
     onShow() {
         this.getTabBar().init();
+        this.startDataCarousel();
     },
-
     /**
      * 生命周期函数--监听页面隐藏
      */
     onHide() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
-
+        clearInterval(DataCarousel);
     },
 
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage() {
-
-    }
 })

+ 2 - 2
pages/tabbar/home/index.wxml

@@ -18,8 +18,8 @@
 </view>
 <view style="height: 130rpx;" />
 <!-- 滚动通知 -->
-<view class="scroll-area">
-    <van-notice-bar custom-class='notice-bar' background="none" color='#666' text="滚动区域滚动区域滚动区域滚动区域滚动区域滚动区域滚动区域滚动区域滚动区域滚动区域">
+<view class="scroll-area" data-item="{{notice}}" catchtap="toMsg">
+    <van-notice-bar custom-class='notice-bar' background="none" color='#666' text="{{notice.message}}">
         <text slot="left-icon" class="iconfont icon-a-shouyexiaoxigundongquxiaoxi" />
     </van-notice-bar>
 </view>