This commit is contained in:
2022-01-25 09:52:20 +08:00
4 changed files with 142 additions and 138 deletions

View File

@@ -1,124 +1,114 @@
<template> <template>
<view> <view>
<block v-if="friends.length > 0"> <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98"> <view>
<view> <view class="friend-flex" @click="toPending">
<view class="friend-flex" @click="toPending"> <u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar>
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar> <view class="name">新的朋友</view>
<view class="name">新的朋友</view> </view>
</view> <view class="friend-flex" @click="showToast">
<view class="friend-flex" @click="showToast"> <u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar>
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar> <view class="name">我的群聊</view>
<view class="name">我的群聊</view> </view>
</view> </view>
</view> <block v-if="friends.length > 0">
<template v-for="(item, friend) in friends"> <template v-for="(item, friend) in friends">
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666"></u-index-anchor> <u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666"></u-index-anchor>
<!-- #endif --> <!-- #endif -->
<u-index-item> <u-index-item>
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666"></u-index-anchor> <u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666"></u-index-anchor>
<!-- #endif --> <!-- #endif -->
<view v-for="(friendItem, index) in item" :key="friendItem.userId" class="friend-flex"> <view
<block v-if="friendItem.portraitUrl != ''"> v-for="(friendItem, index) in item"
<u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''" :default-url="require('@/static/user/cover.png')"></u-avatar> :key="friendItem.userId"
</block> class="friend-flex"
<block v-else> @click="$Router.push({ name: 'imFriendsInfo', params: { id: friendItem.userId } })"
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/user/cover.png')"></u-avatar> >
</block> <block v-if="friendItem.portraitUrl != ''">
<view class="name">{{friendItem.name}}</view> <u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''" :default-url="require('@/static/user/cover.png')"></u-avatar>
</view> </block>
</u-index-item> <block v-else><u-avatar class="cover" size="40" shape="square" :src="require('@/static/user/cover.png')"></u-avatar></block>
</template> <view class="name">{{ friendItem.name }}</view>
</u-index-list> </view>
</block> </u-index-item>
<block v-else> </template>
<u-empty class="pages-null" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无好友"> </block>
</u-empty> <block v-else><u-empty class="pages-null" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无好友"></u-empty></block>
</block> </u-index-list>
</view> </view>
</template> </template>
<script> <script>
import { import { getFriends } from '@/apis/interfaces/im';
getFriends export default {
} from '@/apis/interfaces/im' data() {
export default { return {
data() { indexs: [],
return { friends: []
indexs : [], };
friends: [] },
} onShow() {
}, getFriends().then(res => {
onShow() { this.indexs = res.indexList;
getFriends().then(res => { this.friends = res.itemArr;
this.indexs = res.indexList
this.friends = res.itemArr console.log(res.itemArr);
});
console.log(res.itemArr) },
}) computed: {},
}, methods: {
computed: { // 扫码提示
showToast() {
}, uni.showToast({
methods: { title: '群聊功能暂未开放,敬请期待',
// 扫码提示 icon: 'none'
showToast() { });
uni.showToast({ },
title: "群聊功能暂未开放,敬请期待", // 新朋友
icon: "none" toPending() {
}) uni.navigateTo({
}, url: '/pages/im/friends/pending'
// 新朋友 });
toPending() { }
uni.navigateTo({ },
url: '/pages/im/friends/pending' onNavigationBarButtonTap(e) {
}) this.toPending();
},
// 用户资料
toInfo(targetId) {
uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + targetId
})
}
},
onNavigationBarButtonTap(e) {
this.toPending()
}
}
</script>
<style lang="scss" scoped>
// 页面空
.pages-null {
height: 70vh;
} }
// 好友列表 };
.friend-flex{ </script>
position: relative;
padding: 20rpx $padding; <style lang="scss" scoped>
display: flex; // 页面空
flex-direction: row; .pages-null {
align-items: center; height: 70vh;
// .cover }
.name{ // 好友列表
flex: 1; .friend-flex {
padding-left: $padding; position: relative;
font-size: $title-size; padding: 20rpx $padding;
@extend .nowrap; display: flex;
} flex-direction: row;
&::after{ align-items: center;
position: absolute; // .cover
height: 1rpx; .name {
background: $border-color; flex: 1;
left: calc(40px + #{$padding * 2}); padding-left: $padding;
right: 0; font-size: $title-size;
bottom: 0; @extend .nowrap;
content: " "; }
} &::after {
&:last-child::after{ position: absolute;
display: none; height: 1rpx;
} background: $border-color;
} left: calc(40px + #{$padding * 2});
right: 0;
bottom: 0;
content: ' ';
}
&:last-child::after {
display: none;
}
}
</style> </style>

View File

@@ -38,17 +38,14 @@
userInfo: {} userInfo: {}
} }
}, },
onLoad(e) { mounted() {
this.targetId = e.targetId getUserInfo(this.$Route.query.id).then(res => {
console.log('获取资料',e.targetId); this.userInfo = res
getUserInfo(e.targetId).then(res => { uni.setNavigationBarTitle({
this.userInfo = res title: res.name
console.log('获取资料', res); })
uni.setNavigationBarTitle({ })
title: res.name },
})
})
},
methods: { methods: {
toPrivate() { toPrivate() {
uni.redirectTo({ uni.redirectTo({

View File

@@ -1,11 +1,29 @@
<template> <template>
<div> <div>
我的资料也就展示个二维码吧 我的资料也就展示个二维码吧
获取一波资料吧
</div> </div>
</template> </template>
<script> <script>
import { getUserInfo } from '@/apis/interfaces/im'
export default{
data(){
return{
}
},
mounted() {
console.log(this.$Route)
// getUserInfo(this.$Route.query.id).then(res => {
// })
},
methods: {
}
}
</script> </script>
<style> <style lang="scss" scoped>
</style> </style>

View File

@@ -12,10 +12,8 @@
<view class="chat-status" :class="{'hide': item.sentStatus == 50}" <view class="chat-status" :class="{'hide': item.sentStatus == 50}"
v-if="item.messageDirection == 1">{{ item.sentStatus == 50 ? '已读': '未读'}}</view> v-if="item.messageDirection == 1">{{ item.sentStatus == 50 ? '已读': '未读'}}</view>
<view class="chat-avatar"> <view class="chat-avatar">
<u-avatar v-if="item.messageDirection == 2" bg-color="#ffffff" :src="userInfo.portraitUrl" <u-avatar v-if="item.messageDirection == 2" bg-color="#ffffff" :src="userInfo.portraitUrl" @click="showFriend(targetId)"></u-avatar>
@click="showFriend(targetId)"></u-avatar> <u-avatar v-else @click="showMine" bg-color="#ffffff" :src="$store.getters.sender.portraitUrl" />
<u-avatar v-else @click="showMine" bg-color="#ffffff"
:src="$store.getters.sender.portraitUrl" />
</view> </view>
</view> </view>
<view class="chat-item-time" :id="'chatId_'+index"> <view class="chat-item-time" :id="'chatId_'+index">
@@ -248,7 +246,8 @@
.chat-avatar { .chat-avatar {
position: absolute; position: absolute;
top: 0; top: 0;
background: white;
} }
&.left { &.left {