好友申请通知优化
This commit is contained in:
@@ -36,7 +36,6 @@
|
|||||||
methods: {
|
methods: {
|
||||||
resolve() {
|
resolve() {
|
||||||
resolveFriend(this.message.sourceUserId).then(res => {
|
resolveFriend(this.message.sourceUserId).then(res => {
|
||||||
this.clearMessages()
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '通过好友申请'
|
title: '通过好友申请'
|
||||||
@@ -47,6 +46,8 @@
|
|||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: err.message
|
title: err.message
|
||||||
})
|
})
|
||||||
|
}).finally(() => {
|
||||||
|
this.clearMessages()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
reject() {
|
reject() {
|
||||||
@@ -70,9 +71,9 @@
|
|||||||
clearMessages() {
|
clearMessages() {
|
||||||
RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId)
|
RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId)
|
||||||
this.$emit('success')
|
this.$emit('success')
|
||||||
uni.$emit('onNewContactConversation', message)
|
uni.$emit('onNewContactConversation')
|
||||||
uni.$emit('onNewContactFriends', message)
|
uni.$emit('onNewContactFriends')
|
||||||
uni.$emit('onNewContactPendings', message)
|
uni.$emit('onNewContactPendings')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,21 @@
|
|||||||
</view>
|
</view>
|
||||||
<block v-if="friends.length > 0">
|
<block v-if="friends.length > 0">
|
||||||
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
|
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
|
||||||
<u-index-anchor :text="indexs[fkey]" bgColor="#f9f9f9" height="20" size="12" color="#666" class="anchor" />
|
<u-index-anchor :text="indexs[fkey]" bgColor="#f9f9f9" height="20" size="12" color="#666"
|
||||||
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex" @click="toFriend(friendItem.targetId)">
|
class="anchor" />
|
||||||
<u-avatar class="avatar-img" size="40" shape="square" :src="contact(friendItem.targetId).portraitUrl" />
|
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
|
||||||
<view class="info"> <view class="name">{{ contact(friendItem.targetId).name }}</view> </view>
|
@click="toFriend(friendItem.targetId)">
|
||||||
|
<u-avatar class="avatar-img" size="40" shape="square"
|
||||||
|
:src="contact(friendItem.targetId).portraitUrl" />
|
||||||
|
<view class="info">
|
||||||
|
<view class="name">{{ contact(friendItem.targetId).name }}</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</u-index-item>
|
</u-index-item>
|
||||||
</block>
|
</block>
|
||||||
<view class="no-lists" v-else>
|
<view class="no-lists" v-else>
|
||||||
<u-image class="cover" radius="4" width="400rpx" height="400rpx" :src=" require('@/static/imgs/no-friend.png')" :lazy-load="true" />
|
<u-image class="cover" radius="4" width="400rpx" height="400rpx"
|
||||||
|
:src=" require('@/static/imgs/no-friend.png')" :lazy-load="true" />
|
||||||
<span>暂无好友列表~</span>
|
<span>暂无好友列表~</span>
|
||||||
</view>
|
</view>
|
||||||
</u-index-list>
|
</u-index-list>
|
||||||
@@ -28,7 +34,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getFriendsLetter} from '@/apis/interfaces/im';
|
import {
|
||||||
|
getFriendsLetter
|
||||||
|
} from '@/apis/interfaces/im';
|
||||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||||
import im from '@/utils/im/index.js'
|
import im from '@/utils/im/index.js'
|
||||||
|
|
||||||
@@ -47,18 +55,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLoad() {
|
||||||
|
uni.$on('onNewContactFriends', this.checkNewFriendPending)
|
||||||
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.getFriendList()
|
this.getFriendList()
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
uni.$on('onContactNotification', this.checkNewFriendPending)
|
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
uni.$off("onContactNotification")
|
uni.$off("onNewContactFriends")
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFriendList() {
|
getFriendList() {
|
||||||
getFriendsLetter().then(res => {
|
getFriendsLetter().then(res => {
|
||||||
console.log(res)
|
|
||||||
this.indexs = res.indexList
|
this.indexs = res.indexList
|
||||||
this.friends = res.itemArr
|
this.friends = res.itemArr
|
||||||
})
|
})
|
||||||
@@ -70,10 +79,7 @@
|
|||||||
},
|
},
|
||||||
toGroup() {
|
toGroup() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/im/group/index',
|
url: '/pages/im/group/index'
|
||||||
fail(err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toFriend(targetId) {
|
toFriend(targetId) {
|
||||||
@@ -85,13 +91,13 @@
|
|||||||
toPending() {
|
toPending() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/im/friends/pending'
|
url: '/pages/im/friends/pending'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onNavigationBarButtonTap(e) {
|
onNavigationBarButtonTap(e) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/im/friends/search'
|
url: '/pages/im/friends/search'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -160,6 +166,7 @@
|
|||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-lists {
|
.no-lists {
|
||||||
padding-top: $padding * 3;
|
padding-top: $padding * 3;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -57,7 +57,11 @@
|
|||||||
// 好友申请数量
|
// 好友申请数量
|
||||||
this.checkNewFriendPending()
|
this.checkNewFriendPending()
|
||||||
// 监听新的好友申请
|
// 监听新的好友申请
|
||||||
uni.$on('onNewContactConversation', this.checkNewFriendPending)
|
uni.$on('onNewContactConversation', () => {
|
||||||
|
console.log('更新好友申请数量');
|
||||||
|
// 更新好友申请数量
|
||||||
|
this.checkNewFriendPending()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if (this.$store.state.token !== '') {
|
if (this.$store.state.token !== '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user