This commit is contained in:
唐明明
2022-02-18 17:06:34 +08:00
5 changed files with 146 additions and 109 deletions

View File

@@ -84,15 +84,10 @@
onLoad(e) {
this.targetId = e.targetId
this.qrContent += e.targetId
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({
status
}) => {
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({status}) => {
this.status = !Boolean(status)
})
RongIMLib.getConversation(this.conversationType, this.targetId, ({
code,
conversation
}) => {
RongIMLib.getConversation(this.conversationType, this.targetId, ({code,conversation}) => {
if (code == 0) {
this.isTop = conversation.isTop
}

View File

@@ -1,74 +1,63 @@
<template>
<view>
<!-- <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<view class="search">
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt"
disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" />
</view>
<block v-if="friends.length > 0">
<u-checkbox-group v-model="checkboxValue" placement="column" @change="checkboxChange">
<view class="invite">
<view class="search">
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt"
disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" @change="onSearch" />
</view>
<block v-if="friends.length > 0">
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column">
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" bgColor="#ededed" height="20" size="12" color="#666"
style="padding:10rpx 30rpx" />
<u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#ededed" height="20" size="12"
color="#666" style="padding:10rpx 30rpx" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="selectFriend(friendItem.targetId)">
<u-checkbox :customStyle="{marginBottom: '8px'}" :name="friendItem.targetId" />
<u-avatar class="avatar-img" size="40" shape="square" :src="contact(friendItem.targetId).portraitUrl" />
@click="addContact(friendItem.targetId)">
<u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98"
style="margin-right: 20rpx;" :disabled="canSelect(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 class="address">Hash:{{ friendItem.address }}</view> -->
</view>
</view>
</u-index-item>
</u-checkbox-group>
</block>
<view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="searchTxt=== '' ? require('@/static/imgs/no-friend.png') :require('@/static/imgs/no-search.png')"
:lazy-load="true" />
<span>{{searchTxt=== ''?'暂无好友列表~':'暂无搜索内容~'}}</span>
</view> -->
<button type="default" @click="onInvite">确定</button>
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column">
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" bgColor="#ededed" height="20" size="12" color="#666"
style="padding:10rpx 30rpx" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="addContact(friendItem.targetId)">
<u-checkbox :name="friendItem.targetId" shape="circle" />
<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 class="address">Hash:{{ friendItem.address }}</view> -->
</view>
</view>
</u-index-item>
</u-checkbox-group>
</u-index-list>
</u-index-list>
<view class="bottom">
<span class="onInvite" @click="onInvite">完成<span>{{`(${checkboxValue.length})` || ''}}</span></span>
</view>
</block>
<view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="searchTxt=== '' ? require('@/static/imgs/no-friend.png') :require('@/static/imgs/no-search.png')"
:lazy-load="true" />
<span>{{searchTxt=== ''?'暂无好友列表~':'暂无搜索内容~'}}</span>
</view>
</view>
</template>
<script>
import {
getFriendsLetter,
inviteGroupUser
inviteGroupUser,
getGroupUsers
} from '@/apis/interfaces/im';
import utils from '@/utils/index.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default {
data() {
return {
// indexs: [],
// friends: [],
// pendingCount: 0,
// searchTxt: '',
// checkboxValue: [],
targetId: '',
searchTxt: '',
targetId: '',
indexs: [],
orignalIndexs: [],
friends: [],
checkboxValue: []
orignalFriends: [],
checkboxValue: [],
selectValue: []
};
},
computed: {
@@ -78,57 +67,69 @@
}
}
},
// onLoad() {
// this.getFriendList()
// this.checkNewFriendPending()
// uni.$on('onContactNotification', this.checkNewFriendPending)
// },
// methods: {
// // group事件
// checkboxChange(n) {
// console.log('change', n);
// },
// getFriendList() {
// getFriendsLetter().then(res => {
// console.log(res)
onLoad(e) {
this.targetId = e.targetId
this.getFriendList()
},
methods: {
onSearch(val) {
if (val) {
var ix = []
this.friends = this.orignalFriends.map((list, index) => {
const resList = list.filter(item => item.name.indexOf(val) > 0)
if (resList.length > 0) {
this.indexs.filter((t, i) => i == index)
}
// if (resList.length > 0) {
// ix = this.orignalIndexs.map((t, i) => {
// if (i == index) {
// return t
// }
// }).filter(Boolean)
// }
return resList
})
console.log( this.indexs);
} else {
this.friends = this.orignalFriends
this.indexs = this.orignalIndexs
}
},
canSelect(targetId) {
return utils.inArray(targetId, this.selectValue)
},
getFriendList() {
getFriendsLetter().then(res => {
this.indexs = res.indexList
this.friends = res.itemArr
this.orignalFriends = res.itemArr
this.orignalIndexs = res.indexList
})
getGroupUsers(this.targetId).then(res => {
res.map(res => {
this.checkboxValue.push(String(res.targetId))
this.selectValue.push(String(res.targetId))
})
})
},
// selectFriend(targetId) {
// console.log(targetId,typeof targetId)
// let arr = this.checkboxValue
// let index = arr.findIndex(item => item === targetId)
// if(index>0){
// console.log('选择了再次点击清除数据le')
// }else{
// console.log('没有选择过,添加数据')
// }
// console.log(this.checkboxValue,index)
// console.log('奥克兰打开',targetId)
// },
// 点击名字新增或删除选中数据
addContact(targetId) {
if (!this.checkboxValue.find(item => item == targetId)) {
const index = this.checkboxValue.findIndex(item => item == targetId)
if (index === -1) {
this.checkboxValue.push(targetId)
} else {
const index = this.checkboxValue.findIndex(item => item == targetId)
this.checkboxValue = this.checkboxValue.splice(index, 1)
this.checkboxValue.splice(index, 1)
}
},
onInvite() {
inviteGroupUser(this.targetId, this.checkboxValue).then(res => {
uni.navigateBack()
console.log(res, 'res')
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 200
});
}).catch(err => {
uni.showToast({
icon: 'none',
@@ -198,18 +199,61 @@
background-color: #fff;
}
.search {
background-color: #fff;
padding: 30rpx;
.invite {
position: relative;
padding: 100rpx 0;
box-sizing: border-box;
z-index: 0;
.search-input {
padding: 10rpx $padding;
.bottom {
position: fixed;
bottom: 0;
width: 100%;
height: 120rpx;
background-color: $window-color;
z-index: 100;
color: #fff;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
box-sizing: border-box;
padding-right: 30rpx;
padding-bottom: 10rpx;
.onInvite {
background-color: $main-color;
font-size: $title-size;
display: inline-block;
padding: 10rpx 30rpx;
border-radius: 10rpx;
span {
font-size: $title-size - 2;
}
}
}
.searchTxt {}
.search {
background-color: #fff;
padding: 30rpx;
position: fixed;
width: 100%;
box-sizing: border-box;
top: 0;
z-index: 100;
.search-input {
padding: 10rpx $padding;
width: 100%;
}
.searchTxt {}
}
}
.no-lists {
padding-top: $padding * 3;
display: flex;

View File

@@ -4,10 +4,10 @@
<view class="reviewed-item">
<u-avatar class="avatar" src="require('@/static/user/cover.png')" shape="square" size="36" />
<view style="flex:1;">
<view class="nickname"><span>{{`艾米的猫儿 `}}</span>想邀请<span>{{` 艾米的猫儿洛基艾米`}}</span>加入群聊</view>
<view class="nickname"><span>{{`艾米的猫儿 `}}</span>想邀请<span>{{` 用户8066`}}</span>加入群聊</view>
<view> 申请原因{{`呵呵哒。。`}}</view>
</view>
<view class="sure" @click="sure(2)"> 去确认 </view>
<view class="sure" @click="sure(2)"> 通过 </view>
</view>
</view>
</template>
@@ -60,6 +60,7 @@
span {
color: $text-color;
font-size: $title-size-m +1;
}
}

View File

@@ -163,10 +163,9 @@
this.latestMessage.sentTime || 0,
1,
false,
(messages) => {
console.log(messages);
(messages) => {
this.messages.unshift(...messages)
// this.scrollBottom()
this.scrollBottom()
})
},
// 获取消息列表
@@ -179,7 +178,7 @@
true,
(messages) => {
this.messages = messages
// this.scrollBottom()
this.scrollBottom()
})
},
// 展示好友信息, type 1 是自己, 2 是对方
@@ -212,4 +211,3 @@
}
}
</script>

View File

@@ -16,18 +16,18 @@ export const timeCustomCN = (val) => {
let currentMonth = currentDate.getMonth() + 1;
let date = val.substring(0, 19);
date = date.replace(/-/g, '/');
let valDate = new Date(date);
let valDate = new Date(date);
let valD = valDate.getDate();
let valYear = valDate.getFullYear();
let valMonth = valDate.getMonth() + 1;
// 判断是否属于今天,计算时分
let difftime = (currentDate - valDate) / 1000;
if (currentYear === valYear && currentMonth === valMonth && currentD === valD) {
let minute = parseInt(difftime % 3600 / 60);
if (minute <= 60) {
return minute === 0 ? '刚刚' : minute + '分钟前';
let difftime = (currentDate - valDate) / 1000;
if (currentYear === valYear && currentMonth === valMonth && currentD === valD) {
if (difftime < 3600) {
let minute = parseInt(difftime % 3600 / 60);
return minute === 0 ? '刚刚' : minute + '分钟前';
} else {
return (minute * 60).toFixed(0) + '小时前';
return (difftime / 3600).toFixed(0) + '小时前';
}
} else {
// 计算天
@@ -37,7 +37,6 @@ export const timeCustomCN = (val) => {
let days = Math.abs(currentDate.getTime() - valDate.getTime()) / (1000 * 60 * 60 * 24);
return Math.ceil(days) + '天前';
}
}
}