|
@@ -10,7 +10,7 @@
|
|
|
<SearchOutlined />
|
|
<SearchOutlined />
|
|
|
</template>
|
|
</template>
|
|
|
</a-input-search>
|
|
</a-input-search>
|
|
|
- <div class="mt10">
|
|
|
|
|
|
|
+ <div class="mt10 friend-content">
|
|
|
<div class="item"
|
|
<div class="item"
|
|
|
v-for="(item, index) in searchFriend"
|
|
v-for="(item, index) in searchFriend"
|
|
|
:key="index + '11'">
|
|
:key="index + '11'">
|
|
@@ -99,18 +99,11 @@ export default defineComponent({
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
queryQueryWrFriend(value)
|
|
queryQueryWrFriend(value)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- if (value) {
|
|
|
|
|
- const set = new Set<number>([]);
|
|
|
|
|
- searchFriend.value.forEach((el) => set.add(el.frienduserid));
|
|
|
|
|
- res.forEach((el) => {
|
|
|
|
|
- // 防止重复搜索
|
|
|
|
|
- if (!set.has(el.frienduserid)) {
|
|
|
|
|
- searchFriend.value.push(el);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ if (!value) {
|
|
|
myFriends.value = res; // 我的朋友
|
|
myFriends.value = res; // 我的朋友
|
|
|
- searchFriend.value = res;
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const findResult = myFriends.value.filter((e) => String(e.frienduserid).includes(value));
|
|
|
|
|
+ searchFriend.value = [...findResult, ...res];
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.catch((err: string) => message.error(err))
|
|
.catch((err: string) => message.error(err))
|
|
@@ -121,12 +114,15 @@ export default defineComponent({
|
|
|
|
|
|
|
|
function handleSearch(value: string) {
|
|
function handleSearch(value: string) {
|
|
|
if (value) {
|
|
if (value) {
|
|
|
|
|
+ // 模糊 搜索自己的好友
|
|
|
|
|
+ // 精准添加 好友
|
|
|
const findResult = myFriends.value.filter((e) => String(e.frienduserid).includes(value));
|
|
const findResult = myFriends.value.filter((e) => String(e.frienduserid).includes(value));
|
|
|
if (findResult.length) {
|
|
if (findResult.length) {
|
|
|
- searchFriend.value = findResult;
|
|
|
|
|
// fix:#1191 搜索好友时,输入的数字包含在已有好友中时,会无法精确匹配到未添加的用户
|
|
// fix:#1191 搜索好友时,输入的数字包含在已有好友中时,会无法精确匹配到未添加的用户
|
|
|
if (!findResult.find((e) => e.frienduserid.toString() === value)) {
|
|
if (!findResult.find((e) => e.frienduserid.toString() === value)) {
|
|
|
queryMyFriend(value);
|
|
queryMyFriend(value);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ searchFriend.value = findResult;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
queryMyFriend(value);
|
|
queryMyFriend(value);
|
|
@@ -212,6 +208,10 @@ export default defineComponent({
|
|
|
box-shadow: none !important;
|
|
box-shadow: none !important;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ .friend-content {
|
|
|
|
|
+ height: 290px;
|
|
|
|
|
+ overflow-y: scroll;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</style
|
|
</style
|
|
|
>;
|
|
>;
|