odc.xiaohui
2023-04-06 f05a26bb7e036c3d09c84e295f1b77fdb8d9ba08
miniprogram/pages/manager/group/message/index.ts
@@ -4,6 +4,9 @@
Page({
    data: {
        inter:1,
        overLayList:{},
        showOverlay:false,
        messageList: [],
        isShow: false,
        height: null,
@@ -19,6 +22,22 @@
    //         url: '../cause/detail/index?id=' + e.currentTarget.id,
    //     })
    // },
    onClickHide(e){
        console.log(e)
        this.setData({
            showOverlay:false
        })
    },
    onClickShow(e){
        console.log(e);
        this.setData({
            overLayList:e
        })
        this.setData({
            showOverlay:true
        })
    },
groupMenber(){
    wx.navigateTo({
        url:'../message/member/index?id='+this.data.groupId
@@ -44,7 +63,7 @@
        url:'../message/records/index?id='+this.data.groupId
    })
},
    more() {
more() {
        console.log("进来了", this.data.scrollTop)
        if (this.data.isShow == false) {
            this.setData({
@@ -61,6 +80,7 @@
    },
    sendMsg(){
        wx.request(
            {
                url: message.globalData.url + "/wx/group/manager/sendMsg",
@@ -91,10 +111,21 @@
                                    value:""
                                })
                                console.log(this.data.messageList)
                                wx.setStorageSync('time',time)
                                try {
                                    wx.setStorageSync('time', 'time')
                                  } catch (e) { }
                                // wx.setStorageSync('time','time')
                                this.setData({
                                    isInput : 1
                                })
                                wx.createSelectorQuery().select('#chat')
                                .boundingClientRect(function(rect){
                                    console.log('rectheight',rect);
                                    /* 将页面移动到最底部(用xxx的height定位) */
                                    wx.pageScrollTo({
                                      scrollTop: rect.height
@@ -120,8 +151,64 @@
            })
        }
    },
    getmessage(){
        wx.request(
            {
                url: message.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 = message.globalData.imageUrl + "/img/" + res.data.data[index].pic;
                        }
                    }
                    this.setData({
                        messageList: res.data.data,
                    })
                    console.log(this.data.messageList)
                    try {
                        wx.setStorageSync('time', 'time')
                      } catch (e) { }
                    // wx.setStorageSync('time','time')
                    this.setData({
                        isInput : 2
                    })
                    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')
        })
        var date = new Date()
        var month = date.getMonth() + 1
        var day = date.getDate()
@@ -175,5 +262,9 @@
                      }).exec()
                }
            })
            let that = this
            that.data.inter = setInterval(function(){
                that.getmessage()
             },10000)
    }
})