odc.xiaohui
2023-04-06 f05a26bb7e036c3d09c84e295f1b77fdb8d9ba08
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的height定位) */
                    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');