This commit is contained in:
luyuan 2020-08-18 10:43:15 +08:00
parent a39aa6e059
commit 9f17c5478c
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
5 changed files with 77 additions and 25 deletions

View File

@ -61,6 +61,7 @@
</view> </view>
</template> </template>
<script> <script>
import IMService from '@/static/imservice.js'
import identifying from '@/components/logininput/identifying' import identifying from '@/components/logininput/identifying'
import { import {
mapMutations mapMutations
@ -107,6 +108,8 @@
let pages = getCurrentPages(); let pages = getCurrentPages();
let prePage = pages[pages.length - 2]; let prePage = pages[pages.length - 2];
this.temp_url = prePage.route; this.temp_url = prePage.route;
console.log(this.imService.lianjie)
this.imService.disconnect()
// console.log(this.temp_url); // console.log(this.temp_url);
}, },
// //
@ -181,6 +184,12 @@
me.loginIn(res.data.token); // me.loginIn(res.data.token); //
// //
uni.setStorageSync('user_info',res.data); uni.setStorageSync('user_info',res.data);
let im = this.imService
im.status = false
console.log(123)
im.lianjie = false
im = new IMService();
console.log(im.lianjie)
if (res.data.member.has_labels) { if (res.data.member.has_labels) {
uni.switchTab({ uni.switchTab({
url: '/pages/index/index' url: '/pages/index/index'

View File

@ -23,6 +23,7 @@
import { import {
mapMutations mapMutations
} from 'vuex'; } from 'vuex';
import IMService from '@/static/imservice.js'
export default { export default {
data() { data() {
return { return {
@ -88,7 +89,12 @@
url: url url: url
}); });
}, },
loginOut() { async loginOut() {
let im = this.imService
await im.disconnect()
im.lianjie = false
im = new IMService();
console.log(im.lianjie)
this.logout(); this.logout();
uni.redirectTo({ uni.redirectTo({
url: "../../pageA/login/login", url: "../../pageA/login/login",

View File

@ -267,27 +267,19 @@
indexad, indexad,
darenItem darenItem
}, },
onShow() { async onShow() {
this.page = 1; this.page = 1;
if (this.page != 1) { if (this.page != 1) {
} }
// if (this.hasLogin) { console.log(this.imService.lianjie,this.imService.status)
// this.isNewmembervoucher(); if(!this.imService.status && this.$store.state.hasLogin && !this.imService.lianjie){
// }
},
async onLoad(){
this.articleList = [];
this.getArticlelist();
this.getSwiper();
//
if(this.$store.state.hasLogin){
this.isNewmembervoucher(); this.isNewmembervoucher();
const user = uni.getStorageSync('user_info'); const user = uni.getStorageSync('user_info');
// console.log(user) // console.log(user)
this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar) this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar)
await this.imService.connectIM() await this.imService.connectIM()
}else{ }else if(!this.imService.status && !this.imService.lianjie){
await this.$u.api.getDefaultAvatar().then((res)=>{ await this.$u.api.getDefaultAvatar().then((res)=>{
console.log(res) console.log(res)
uni.setStorageSync("morenimg",res.data.avatar) uni.setStorageSync("morenimg",res.data.avatar)
@ -298,16 +290,57 @@
await this.imService.connectIM() await this.imService.connectIM()
} }
console.log("1212") if(!this.imService.status && !this.imService.lianjie){
let that = this console.log("1212")
setTimeout(function(){ this.imService.lianjie = true
that.imService.disconnect() let that = this
console.log("guanbi") setTimeout(function(){
},1000) that.imService.disconnect()
setTimeout(function(){ console.log("guanbi")
console.log("lianjie") },1000)
that.imService.connectIM() setTimeout(function(){
},2000) console.log("lianjie")
that.imService.connectIM()
},2000)
}
// if (this.hasLogin) {
// this.isNewmembervoucher();
// }
},
async onLoad(){
this.articleList = [];
this.getArticlelist();
this.getSwiper();
//
// if(this.$store.state.hasLogin){
// this.isNewmembervoucher();
// const user = uni.getStorageSync('user_info');
// // console.log(user)
// this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar)
// await this.imService.connectIM()
// }else{
// await this.$u.api.getDefaultAvatar().then((res)=>{
// console.log(res)
// uni.setStorageSync("morenimg",res.data.avatar)
// this.imService.login(new Date().getTime(),"123",res.data.avatar)
// console.log("")
// })
// console.log("")
// await this.imService.connectIM()
// }
// console.log("1212")
// let that = this
// setTimeout(function(){
// that.imService.disconnect()
// console.log("guanbi")
// },1000)
// setTimeout(function(){
// console.log("lianjie")
// that.imService.connectIM()
// },2000)
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.page = 1; this.page = 1;

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,8 @@
* @Last Modified time: 2020-4-21 15:01:41 * @Last Modified time: 2020-4-21 15:01:41
*/ */
import GoEasyIM from './goeasy-im-1.0.9'; // import GoEasyIM from './goeasy-im-1.0.9';
import GoEasyIM from './goeasy-im-1.1.1';
import restApi from './restapi'; import restApi from './restapi';
function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) { function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) {
@ -38,6 +39,7 @@ function IMService() {
appkey:'BC-453aa755c4ea48148abefc55a86df283' appkey:'BC-453aa755c4ea48148abefc55a86df283'
}); });
this.status = false this.status = false
this.lianjie = false
//当前“我” //当前“我”
this.currentUser = null; this.currentUser = null;
//我的好友 //我的好友