odc.xiaohui
2023-05-12 4b48bacef8646cee8b66f5e10b0ed7124534e93e
miniprogram/pages/user/group/message/index.ts
@@ -4,6 +4,7 @@
Page({
    data: {
        inter:1,
        messageList: [],
        isShow: false,
        height: null,
@@ -126,15 +127,108 @@
            })
        }
    },
   getBan(){
    var date = new Date()
    var month = date.getMonth() + 1
    var day = date.getDate()
    var hours = date.getHours()
    var minutes = date.getMinutes()
    var secends = date.getSeconds()
    var time
    if (month < 10) {
        month = "0" + month
    }
    if (day < 10) {
        day = "0" + day
    }
    if (minutes < 10) {
        minutes = "0" + minutes
    }
    if (hours < 10) {
        hours = "0" + hours
    }
    if (secends < 10) {
        secends = "0" + secends
    }
    time = date.getFullYear() + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + secends
    var lastTime = wx.getStorageSync('time')
    wx.request(
        {
            url: userMessage.globalData.url + "/wx/user/group/list",
            method: "GET",
            data: {
                id: wx.getStorageSync('id'),
                newDate: time,
                lastDate: lastTime
            },
            header: { 'token': wx.getStorageSync('token') },
            success: (res) => {
                console.log(res.data.data)
                this.setData({
                    ban:res.data.data[0].ban
                })
            }
        })
   },
   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 () {
      console.log('清除定时器');
    this.endInter()
  },
  onHide(){
    console.log('清除定时器');
    this.endInter()
  },
    onLoad(e) {
        var date = new Date()
        var month = date.getMonth() + 1
        var day = date.getDate()
        var hours=date.getHours()
        var minutes=date.getMinutes()
        var secends=date.getSeconds()
        var time
        this.setData({
            uid:wx.getStorageSync('id')
        })
        console.log(this.data.uid);
        this.setData({
            uid:wx.getStorageSync('id')
        })
        let date = new Date()
        let month = date.getMonth() + 1
        let day = date.getDate()
        let hours=date.getHours()
        let minutes=date.getMinutes()
        let secends=date.getSeconds()
        let time
        if (month < 10) {
            month = "0" + month
        }
@@ -152,12 +246,14 @@
        }
        time = date.getFullYear() + "-" + month + "-" + day + " " + hours+":"+minutes+":"+secends
        wx.setStorageSync('time',time)
        this.data.groupId=e.id
        this.data.ban=e.ban
        this.setData({
            ban:e.ban
        })
        console.log("reoId",e.reportId)
        // this.data.ban=e.ban
        // this.setData({
        //     ban:e.ban
        // })
        this.getBan()
        console.log("reoId",e.reportId,e)
        this.data.reportId=e.reportId
        wx.request(
            {
@@ -187,5 +283,13 @@
                      }).exec()
                }
            })
    }
            let that = this
            that.data.inter = setInterval(function(){
                that.getmessage()
             },30000)
    },
    onShow(){
        console.log('123');
    },
})