邀请好友,搜索算法

This commit is contained in:
2022-02-21 14:24:14 +08:00
parent ad40d0d4d1
commit 1be73f5bbb
2 changed files with 11 additions and 98 deletions

View File

@@ -1,7 +1,7 @@
<template>
<view class="invite">
<view class="search">
<u--input class="search-input" placeholder="搜索" border="none" prefixIcon="search" v-model="searchTxt"
<view class="search u-border-bottom">
<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">
@@ -73,19 +73,18 @@
},
methods: {
onSearch() {
if (this.searchTxt) {
console.log(this.searchTxt)
if (this.searchTxt) {
this.friends = this.orignalFriends.map((list, index) => {
const resList = list.filter(item => item.name.indexOf(this.searchTxt) > 0)
if (resList.length > 0) {
this.indexs = this.orignalIndexs.map((t, i) => {})
} else {
return;
}
const resList = list.filter(item => {
return item.name.indexOf(this.searchTxt) >= 0
})
return resList
})
this.friends = this.friends.filter(n => n)
this.indexs = this.orignalIndexs.map((t, i) => {
if (this.friends[i].length > 0) {
return t
}
})
} else {
this.friends = this.orignalFriends
this.indexs = this.orignalIndexs
@@ -124,7 +123,6 @@
},
onInvite() {
inviteGroupUser(this.targetId, this.checkboxValue).then(res => {
console.log(res, 'res')
uni.navigateBack({
delta: 1,
animationType: 'pop-out',