From 335f4c556458c787424a2c7477215e0dd7ce60e7 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Mon, 3 Aug 2020 14:41:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pageA/login/login.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pageA/login/login.vue b/pageA/login/login.vue index a535530..fb825f0 100644 --- a/pageA/login/login.vue +++ b/pageA/login/login.vue @@ -179,7 +179,14 @@ }) return false } else { + console.log(123) me.loginIn(res.data.token); //存储一个字符传值 + // 缓存用户的信息 + uni.setStorageSync({ + key: 'user_info', + data: res.data + }); + if (res.data.member.has_labels) { uni.switchTab({ url: '/pages/index/index' @@ -189,14 +196,7 @@ url: '/pageA/topick/topick' }) } - // 缓存用户的信息 - uni.setStorageSync({ - key: 'user_info', - data: res.data, - success: function() { - console.log('success'); - } - }); + } // 存储接口请求所需token From b070a559dce3010ded8051d764f7d58c75c23fe2 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Mon, 3 Aug 2020 15:56:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=9B=B4=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/zhibo/index.nvue | 47 +++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/pages/zhibo/index.nvue b/pages/zhibo/index.nvue index 059dc86..b38e106 100644 --- a/pages/zhibo/index.nvue +++ b/pages/zhibo/index.nvue @@ -336,10 +336,13 @@ export default { }; }, onLoad(a) { + this.url = a.url; this.id = a.id console.log(this.url); let that = this; + + uni.getSystemInfo({ success(a) { console.log(a.windowHeight); @@ -401,7 +404,8 @@ export default { } }) //当前用户 - uni.request({ + try { + uni.request({ url:"https://dmmall.sdbairui.com/api/Member/MemberInfo", method:"POST", header:{ @@ -409,28 +413,54 @@ export default { }, success(res){ console.log(res,111) - var currentUser = { - id : "12", - nickname :"123", - avatar: "1223" + var currentUser = { + id : res.data.data.MemberArray.member_mobile + "", + nickname : res.data.data.MemberArray.member_nickname, + avatar: res.data.data.MemberArray.member_avatar }; var room = { - id : "123", - name : "123" + id : a.id + "", + name : a.id + "" }; console.log(room,currentUser) //构造chatRoomService - that.chatRoomService = new ChatRoomService(room, currentUser); + that.chatRoomService = new ChatRoomService(room, currentUser); + that.chatRoomService.initialWhenNewMessage(that.whenNewMessage); that.chatRoomService.connectGoEasyIM(); //获取当前聊天室数据 that.room = that.chatRoomService.room; + setTimeout(function() { + that.chatRoomService.quitRoom(); + that.chatRoomService = {} + + }, 1000); + setTimeout(function(){ + that.chatRoomService = new ChatRoomService(room, currentUser); + + that.chatRoomService.initialWhenNewMessage(that.whenNewMessage); + that.chatRoomService.connectGoEasyIM(); + + //获取当前聊天室数据 + that.room = that.chatRoomService.room; + }, 2000); } }) + } catch (error) { + console.log("错误") + } + }, + onBackPress () {//返回取消订阅 + //断开连接 + this.chatRoomService.quitRoom(); + }, + beforeDestroy () { + this.chatRoomService.quitRoom(); + }, methods:{ sendMessage (messageType, content) {//发送消息 console.log(123) @@ -452,6 +482,7 @@ export default { // }, 300) console.log(message) this.danmulist.push(message) + if(this.danmulist.length > 7){ this.danmulist = this.danmulist.slice(this.danmulist.length - 7) }