| | |
| | | |
| | | Page({ |
| | | data: { |
| | | inter:1, |
| | | messageList: [], |
| | | isShow: false, |
| | | height: null, |
| | |
| | | } |
| | | }) |
| | | }, |
| | | 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') |
| | |
| | | }).exec() |
| | | } |
| | | }) |
| | | let that = this |
| | | that.data.inter = setInterval(function(){ |
| | | that.getmessage() |
| | | },30000) |
| | | }, |
| | | onShow(){ |
| | | console.log('123'); |