This commit is contained in:
2022-02-23 17:09:26 +08:00
9 changed files with 86 additions and 71 deletions

View File

@@ -36,7 +36,6 @@
methods: {
resolve() {
resolveFriend(this.message.sourceUserId).then(res => {
this.clearMessages()
uni.showToast({
icon: 'none',
title: '通过好友申请'
@@ -47,6 +46,8 @@
icon: 'none',
title: err.message
})
}).finally(() => {
this.clearMessages()
})
},
reject() {
@@ -67,12 +68,12 @@
})
},
// 不管是通过还是拒绝,都要把相关的信息清理
clearMessages() {
clearMessages() {
RongIMLib.deleteMessages(RongIMLib.ConversationType.SYSTEM, this.message.sourceUserId)
this.$emit('success')
uni.$emit('onNewContactConversation', message)
uni.$emit('onNewContactFriends', message)
uni.$emit('onNewContactPendings', message)
uni.$emit('onNewContactConversation')
uni.$emit('onNewContactFriends')
uni.$emit('onNewContactPendings')
}
}
}

View File

@@ -45,27 +45,27 @@
}
}
},
methods: {
showImage(path) {
uni.previewImage({
urls: [
path
]
})
methods: {
showImage(path) {
uni.previewImage({
urls: [
path
]
})
},
previewImage() {
previewImage() {
if (this.content.local && this.content.local.indexOf('///data/user/') < 0) {
this.showImage(this.content.local)
} else {
this.showImage(this.content.remote)
RongIMLib.downloadMediaMessage(this.message.messageId, {
success: (path) => {
this.content.local = path
this.showImage(path)
},
error: (errorCode, messageId) => {
uni.showToast({
icon: 'none',
title: errorCode
error: (errorCode, messageId) => {
uni.showToast({
icon: 'none',
title: errorCode
})
}
})

View File

@@ -10,25 +10,33 @@
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')" />
<view class="info">我的群聊</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-anchor :text="indexs[fkey]" bgColor="#f9f9f9" height="20" size="12" color="#666" class="anchor" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex" @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>
<u-index-anchor :text="indexs[fkey]" bgColor="#f9f9f9" height="20" size="12" color="#666"
class="anchor" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@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>
</u-index-item>
</block>
<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" />
<span>暂无好友列表~</span>
<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" />
<span>暂无好友列表~</span>
</view>
</u-index-list>
</view>
</template>
<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 im from '@/utils/im/index.js'
@@ -47,20 +55,21 @@
}
}
},
onLoad() {
uni.$on('onNewContactFriends', this.checkNewFriendPending)
},
onShow() {
this.getFriendList()
this.checkNewFriendPending()
uni.$on('onContactNotification', this.checkNewFriendPending)
},
onUnload() {
uni.$off("onContactNotification")
},
onUnload() {
uni.$off("onNewContactFriends")
},
methods: {
getFriendList() {
getFriendsLetter().then(res => {
console.log(res)
getFriendsLetter().then(res => {
this.indexs = res.indexList
this.friends = res.itemArr
this.friends = res.itemArr
})
},
checkNewFriendPending() {
@@ -70,10 +79,7 @@
},
toGroup() {
uni.navigateTo({
url: '/pages/im/group/index',
fail(err) {
console.log(err);
}
url: '/pages/im/group/index'
})
},
toFriend(targetId) {
@@ -85,13 +91,13 @@
toPending() {
uni.navigateTo({
url: '/pages/im/friends/pending'
});
})
}
},
onNavigationBarButtonTap(e) {
uni.navigateTo({
url: '/pages/im/friends/search'
});
})
}
};
</script>
@@ -159,19 +165,20 @@
font-size: 14px;
line-height: 24px;
background-color: #fff;
}
.no-lists {
padding-top: $padding * 3;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: $text-gray-m;
span {
padding-top: $padding;
}
}
.no-lists {
padding-top: $padding * 3;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: $title-size-m;
color: $text-gray-m;
span {
padding-top: $padding;
}
}
</style>

View File

@@ -2,7 +2,7 @@
<view class="pending">
<u-sticky>
<view class="header-search" @click="$Router.push({ name: 'SearchFriend' })">
<u-search placeholder="输入手机号码搜索" height="74" searchIcon="search" inputAlign="center" bgColor="white"
<u-search placeholder="输入手机号码搜索" searchIcon="search" inputAlign="center" bgColor="white"
:disabled="true" :show-action="false" />
</view>
</u-sticky>

View File

@@ -11,14 +11,16 @@
<!-- 搜索 -->
<u-sticky>
<view class="header-search">
<u-search placeholder="输入用户账号、手机号" height="74" searchIcon="search" @custom="search" v-model="searchValue" @search="search" bgColor="#f9f9f9" :focus="focused" />
<u-search placeholder="输入用户账号、手机号" searchIcon="search" @custom="search" v-model="searchValue"
@search="search" bgColor="#f9f9f9" :focus="focused" />
</view>
</u-sticky>
<block v-if="searchResult.length > 0">
<applyFriend :lists="searchResult" :isApply="true" @action="action" />
</block>
<view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx" :src="require('@/static/imgs/no-search.png')" :lazy-load="true" />
<u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="require('@/static/imgs/no-search.png')" :lazy-load="true" />
<span>暂无匹配内容~</span>
</view>
</view>
@@ -43,11 +45,11 @@
},
methods: {
search() {
// friendship: '' 没有好友关系
// accepted 好友
// pending 申请中
// denied 拒绝
// blocked 黑名单
// friendship: '' 没有好友关系
// accepted 好友
// pending 申请中
// denied 拒绝
// blocked 黑名单
searchFriend(this.searchValue)
.then(res => {
this.searchResult = res;
@@ -60,9 +62,9 @@
});
});
},
action(e) {
uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + e.item.targetId
action(e) {
uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + e.item.targetId
})
}
}

View File

@@ -52,10 +52,12 @@
}
}
}
},
onShow() {
this.initGroupInfo()
},
onLoad(e) {
this.targetId = e.targetId
this.initGroupInfo()
// 获取历史消息列表
this.getMessageList()
// 监听新消息

View File

@@ -5,10 +5,10 @@
<view v-for="(item, index) in groups" :key="index" class="friend-flex" @click="toGroup(item.targetId)">
<u-avatar size="36" shape="square" :src="item.portraitUrl !== ''?contact(item.targetId).portraitUrl :require('@/static/user/cover-s.png')" />
<view class="info">
<view class="name">{{item.name}} <span class="total">{{item.people_count}} 成员</span></view>
<view class="name">{{ item.name }} <span class="total">{{ item.members }} 成员</span></view>
</view>
</view>
<view class="group-count"> {{groups.length}}个群聊 </view>
<view class="group-count"> {{ groups.length }}个群聊 </view>
</block>
<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" />

View File

@@ -22,7 +22,7 @@
<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" />
<span> 暂无群聊申请数据~</span>
<span>暂无群聊申请数据</span>
</view>
</view>
</template>
@@ -82,7 +82,6 @@
uni.$emit('groupInvitedUser')
}
})
}).catch(err => {
// uni.showToast({
// title: err.message,

View File

@@ -59,7 +59,11 @@
onLoad() {
// 监听新的好友申请
uni.$on('onNewContactConversation', this.checkNewFriendPending)
uni.$on('onNewContactConversation', () => {
console.log('更新好友申请数量');
// 更新好友申请数量
this.checkNewFriendPending()
})
},
onShow() {
// 好友申请数量