// pages/chat-group/chat-group.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { imgPath: app.globalData.imgPath, // groupList: [{ // groupid: '178900372094977', // groupname: '测试' // }, { // groupid: '170301940891650', // groupname: '测试2' // }], search_btn: true, search_friend: false, show_mask: false, groupList: [], // 群聊列表 myName: "" }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ myName: options.myName }); this.listGroups(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, listGroups() { var that = this; wx.WebIM.conn.getGroup({ limit: 50, success: function (res) { console.info(res) that.setData({ groupList: res.data }); // 好像也没有别的官方通道共享数据啊 getApp().globalData.groupList = res.data || []; }, error: function (e) { console.info(e) } }); }, into_room: function (e) { var nameList = { myName: this.data.myName, your: e.currentTarget.dataset.username, groupId: e.currentTarget.dataset.roomid }; wx.navigateTo({ url: "../chat-group-detail/chat-group-detail?username=" + JSON.stringify(nameList) }); }, })