From f05a26bb7e036c3d09c84e295f1b77fdb8d9ba08 Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期四, 06 四月 2023 20:46:42 +0800
Subject: [PATCH] 修改定时

---
 miniprogram/pages/user/group/message/index.ts |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/miniprogram/pages/user/group/message/index.ts b/miniprogram/pages/user/group/message/index.ts
index 725860f..c47f467 100644
--- a/miniprogram/pages/user/group/message/index.ts
+++ b/miniprogram/pages/user/group/message/index.ts
@@ -4,6 +4,7 @@
 
 Page({
     data: {
+        inter:1,
         messageList: [],
         isShow: false,
         height: null,
@@ -169,7 +170,51 @@
             }
         })
    },
+   getmessage(){
+    wx.request(
+        {
+            url: userMessage.globalData.url + "/wx/message",
+            method: "GET",
+            header: { 'token': wx.getStorageSync('token') },
+            data: {
+                groupId: this.data.groupId
+            },
+            success: (res) => {
+                for (let index = 0; index < res.data.data.length; index++) {
+                    if (res.data.data[index].pic != null) {
+                        res.data.data[index].pic = userMessage.globalData.imageUrl + "/img/" + res.data.data[index].pic;
+                    }
+                }
+                this.setData({
+                    messageList: res.data.data,
+                    
+                })
+                console.log(this.data.messageList)
+                wx.createSelectorQuery().select('#chat')
+                .boundingClientRect(function(rect){
+                    console.log('rectheight',rect);
+                    /* 灏嗛〉闈㈢Щ鍔ㄥ埌鏈�搴曢儴锛堢敤xxx鐨刪eight瀹氫綅锛� */
+                    wx.pageScrollTo({
+                      scrollTop: rect.height
+                    })
+                  }).exec()
+            }
+        })
+   },
+   endInter(){
+    let thit = this
+    clearInterval(thit.data.inter)
+  },
+  onUnload () {
+    this.endInter()
+  },
+  onHide(){
+    this.endInter()
+  },
     onLoad(e) {
+        this.setData({
+            uid:wx.getStorageSync('id')
+        })
         console.log(this.data.uid);
         this.setData({
             uid:wx.getStorageSync('id')
@@ -235,6 +280,10 @@
                       }).exec()
                 }
             })
+            let that = this
+            that.data.inter = setInterval(function(){
+                that.getmessage()
+             },30000)
     },
     onShow(){
         console.log('123');

--
Gitblit v1.8.0