From 0deef8bc6ad743f5f8cc62f3de0a35b3c27f979d Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 18 Feb 2022 15:12:51 +0800 Subject: [PATCH] update --- pages/im/group/invite.vue | 51 ++++++++++++++++++++++++++++++++------- utils/filters.js | 15 ++++++------ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/pages/im/group/invite.vue b/pages/im/group/invite.vue index dec52c5..b523d3f 100644 --- a/pages/im/group/invite.vue +++ b/pages/im/group/invite.vue @@ -2,18 +2,18 @@ + disabledColor="#Fff" prefixIconStyle="font-size: 22px;color: #909399" @change="onSearch" /> - + - + @@ -43,6 +43,8 @@ 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 { @@ -51,9 +53,11 @@ searchTxt: '', targetId: '', indexs: [], + orignalIndexs: [], friends: [], + orignalFriends: [], checkboxValue: [], - selectValue:[] + selectValue: [] }; }, computed: { @@ -68,15 +72,44 @@ 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(res.targetId + "") - this.selectValue.push(res.targetId+"") + this.checkboxValue.push(String(res.targetId)) + this.selectValue.push(String(res.targetId)) }) }) }, @@ -91,7 +124,7 @@ }, onInvite() { inviteGroupUser(this.targetId, this.checkboxValue).then(res => { - console.log(res,'res') + console.log(res, 'res') uni.navigateBack({ delta: 1, animationType: 'pop-out', diff --git a/utils/filters.js b/utils/filters.js index d541c07..cfab948 100644 --- a/utils/filters.js +++ b/utils/filters.js @@ -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) + '天前'; } - } }