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) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
this.qrContent += e.targetId this.qrContent += e.targetId
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({ RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({status}) => {
status
}) => {
this.status = !Boolean(status) this.status = !Boolean(status)
}) })
RongIMLib.getConversation(this.conversationType, this.targetId, ({ RongIMLib.getConversation(this.conversationType, this.targetId, ({code,conversation}) => {
code,
conversation
}) => {
if (code == 0) { if (code == 0) {
this.isTop = conversation.isTop this.isTop = conversation.isTop
} }

View File

@@ -1,74 +1,63 @@
<template> <template>
<view> <view class="invite">
<!-- <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98"> <view class="search">
<view class="search"> <u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt"
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt" disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" @change="onSearch" />
disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" /> </view>
</view> <block v-if="friends.length > 0">
<block v-if="friends.length > 0"> <u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-model="checkboxValue" placement="column" @change="checkboxChange"> <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-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" bgColor="#ededed" height="20" size="12" color="#666" <u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#ededed" height="20" size="12"
style="padding:10rpx 30rpx" /> color="#666" style="padding:10rpx 30rpx" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex" <view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="selectFriend(friendItem.targetId)"> @click="addContact(friendItem.targetId)">
<u-checkbox :customStyle="{marginBottom: '8px'}" :name="friendItem.targetId" /> <u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98"
<u-avatar class="avatar-img" size="40" shape="square" :src="contact(friendItem.targetId).portraitUrl" /> 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="info">
<view class="name">{{ contact(friendItem.targetId).name }}</view> <view class="name">{{ contact(friendItem.targetId).name }}</view>
<!-- <view class="address">Hash:{{ friendItem.address }}</view> -->
</view> </view>
</view> </view>
</u-index-item> </u-index-item>
</u-checkbox-group> </u-checkbox-group>
</block> </u-index-list>
<view class="no-lists" v-else> <view class="bottom">
<u-image class="cover" radius="4" width="400rpx" height="400rpx" <span class="onInvite" @click="onInvite">完成<span>{{`(${checkboxValue.length})` || ''}}</span></span>
:src="searchTxt=== '' ? require('@/static/imgs/no-friend.png') :require('@/static/imgs/no-search.png')" </view>
:lazy-load="true" /> </block>
<span>{{searchTxt=== ''?'暂无好友列表~':'暂无搜索内容~'}}</span> <view class="no-lists" v-else>
</view> --> <u-image class="cover" radius="4" width="400rpx" height="400rpx"
<button type="default" @click="onInvite">确定</button> :src="searchTxt=== '' ? require('@/static/imgs/no-friend.png') :require('@/static/imgs/no-search.png')"
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98"> :lazy-load="true" />
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column"> <span>{{searchTxt=== ''?'暂无好友列表~':'暂无搜索内容~'}}</span>
<u-index-item v-for="(item, fkey) in friends" :key="fkey"> </view>
<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>
</view> </view>
</template> </template>
<script> <script>
import { import {
getFriendsLetter, getFriendsLetter,
inviteGroupUser inviteGroupUser,
getGroupUsers
} from '@/apis/interfaces/im'; } from '@/apis/interfaces/im';
import utils from '@/utils/index.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default { export default {
data() { data() {
return { return {
// indexs: [], searchTxt: '',
// friends: [], targetId: '',
// pendingCount: 0,
// searchTxt: '',
// checkboxValue: [],
targetId: '',
indexs: [], indexs: [],
orignalIndexs: [],
friends: [], friends: [],
checkboxValue: [] orignalFriends: [],
checkboxValue: [],
selectValue: []
}; };
}, },
computed: { 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) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
this.getFriendList() this.getFriendList()
}, },
methods: { 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() { getFriendList() {
getFriendsLetter().then(res => { getFriendsLetter().then(res => {
this.indexs = res.indexList this.indexs = res.indexList
this.friends = res.itemArr 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) { addContact(targetId) {
if (!this.checkboxValue.find(item => item == targetId)) { const index = this.checkboxValue.findIndex(item => item == targetId)
if (index === -1) {
this.checkboxValue.push(targetId) this.checkboxValue.push(targetId)
} else { } else {
const index = this.checkboxValue.findIndex(item => item == targetId) this.checkboxValue.splice(index, 1)
this.checkboxValue = this.checkboxValue.splice(index, 1)
} }
}, },
onInvite() { onInvite() {
inviteGroupUser(this.targetId, this.checkboxValue).then(res => { inviteGroupUser(this.targetId, this.checkboxValue).then(res => {
uni.navigateBack() console.log(res, 'res')
uni.navigateBack({
delta: 1,
animationType: 'pop-out',
animationDuration: 200
});
}).catch(err => { }).catch(err => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
@@ -198,18 +199,61 @@
background-color: #fff; background-color: #fff;
} }
.search { .invite {
background-color: #fff; position: relative;
padding: 30rpx; padding: 100rpx 0;
box-sizing: border-box;
z-index: 0;
.search-input { .bottom {
padding: 10rpx $padding; position: fixed;
bottom: 0;
width: 100%; 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 { .no-lists {
padding-top: $padding * 3; padding-top: $padding * 3;
display: flex; display: flex;

View File

@@ -4,10 +4,10 @@
<view class="reviewed-item"> <view class="reviewed-item">
<u-avatar class="avatar" src="require('@/static/user/cover.png')" shape="square" size="36" /> <u-avatar class="avatar" src="require('@/static/user/cover.png')" shape="square" size="36" />
<view style="flex:1;"> <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>
</view> </view>
<view class="sure" @click="sure(2)"> 去确认 </view> <view class="sure" @click="sure(2)"> 通过 </view>
</view> </view>
</view> </view>
</template> </template>
@@ -60,6 +60,7 @@
span { span {
color: $text-color; color: $text-color;
font-size: $title-size-m +1;
} }
} }

View File

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

View File

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