|
|
@@ -1,16 +1,24 @@
|
|
|
<template>
|
|
|
<!-- 我的好友 -->
|
|
|
<a-spin :spinning="loading">
|
|
|
- <div>
|
|
|
- <a-auto-complete placeholder="输入好友代码进行搜索"
|
|
|
- @search="handleSearch">
|
|
|
- <template #dataSource>
|
|
|
- <a-select-option v-for="(item, index) in friendsList"
|
|
|
- :key="index + '11'">
|
|
|
- {{ item.friendname }}
|
|
|
- </a-select-option>
|
|
|
- </template>
|
|
|
- </a-auto-complete>
|
|
|
+ <div class="my-friend">
|
|
|
+ <a-input-search placeholder="输入好友代码进行搜索"
|
|
|
+ enter-button
|
|
|
+ @search="handleSearch" />
|
|
|
+ <div v-for="(item, index) in searchFriend"
|
|
|
+ :key="index + '11'">
|
|
|
+ <a-row type="flex">
|
|
|
+ <a-col :span="12">
|
|
|
+ <span>{{item.frienduserid}} {{ item.friendname }}</span>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="6"
|
|
|
+ @click="operate(item)">
|
|
|
+ <span v-if="item.isfriend">删除</span>
|
|
|
+ <span v-else>添加</span>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ <a-divider />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</a-spin>
|
|
|
</template>
|
|
|
@@ -19,51 +27,95 @@
|
|
|
import { defineComponent, ref } from 'vue';
|
|
|
import { initData } from '@/common/methods';
|
|
|
import { QueryWrFriendApplyRsp } from '@/services/go/wrtrade/interface';
|
|
|
-import { queryQueryWrFriendApply } from '@/services/go/wrtrade';
|
|
|
+import { queryQueryWrFriend } from '@/services/go/wrtrade';
|
|
|
import { friendOperate } from '@/services/proto/accountinfo';
|
|
|
import { getUsrId } from '@/services/bus/user';
|
|
|
import { queryResultLoadingAndInfo, requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
|
|
|
+import { message } from 'ant-design-vue';
|
|
|
+import { Modal } from 'ant-design-vue';
|
|
|
+import { getLongTypeLoginID } from '@/services/bus/login';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'friend',
|
|
|
setup() {
|
|
|
+ const myFriends = ref<QueryWrFriendApplyRsp[]>([]);
|
|
|
+ const searchFriend = ref<QueryWrFriendApplyRsp[]>([]);
|
|
|
const loading = ref<boolean>(false);
|
|
|
- const friendsList = ref<QueryWrFriendApplyRsp[]>([]);
|
|
|
// 设置 新增和删除好友 公共请求参数
|
|
|
// operatetype: number; // 操作类型-1:申请 2:审核通过 3:审核拒绝 4: 删除
|
|
|
- function getParam(operatetype: 1 | 2 | 3 | 4, frienduserid: number) {
|
|
|
+ function getParam(operatetype: 1 | 2 | 3 | 4, frienduserid: string) {
|
|
|
return {
|
|
|
operatetype,
|
|
|
userid: getUsrId(),
|
|
|
frienduserid,
|
|
|
applysrc: 2,
|
|
|
+ applicantid: getLongTypeLoginID(),
|
|
|
};
|
|
|
}
|
|
|
// 删除好友
|
|
|
- function deleteFriend(frienduserid: number) {
|
|
|
- const param = getParam(4, frienduserid);
|
|
|
- requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']);
|
|
|
+ function deleteFriend(frienduserid: string) {
|
|
|
+ Modal.confirm({
|
|
|
+ title: '删除好友',
|
|
|
+ content: '确定删除好友?',
|
|
|
+ onOk() {
|
|
|
+ const param = getParam(4, frienduserid);
|
|
|
+ requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']).then(() => {
|
|
|
+ queryMyFriend();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
// 添加好友
|
|
|
- function addFriend(frienduserid: number) {
|
|
|
+ function addFriend(frienduserid: string) {
|
|
|
const param = getParam(1, frienduserid);
|
|
|
- requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']);
|
|
|
- }
|
|
|
- // 查询我的好友列表
|
|
|
- function queryMyFriend() {
|
|
|
- queryResultLoadingAndInfo(queryQueryWrFriendApply, loading).then((res) => {
|
|
|
- friendsList.value = res;
|
|
|
+ requestResultLoadingAndInfo(friendOperate, param, loading, ['添加好友成功', '添加好友失败:']).then(() => {
|
|
|
+ queryMyFriend();
|
|
|
});
|
|
|
}
|
|
|
+ function operate({ frienduserid, isfriend }: QueryWrFriendApplyRsp) {
|
|
|
+ if (isfriend) {
|
|
|
+ deleteFriend(frienduserid);
|
|
|
+ } else {
|
|
|
+ addFriend(frienduserid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查询好友列表
|
|
|
+ function queryMyFriend(value?: string) {
|
|
|
+ loading.value = true;
|
|
|
+ queryQueryWrFriend(value)
|
|
|
+ .then((res) => {
|
|
|
+ if (!value) {
|
|
|
+ myFriends.value = res; // 我的朋友
|
|
|
+ }
|
|
|
+ searchFriend.value = res;
|
|
|
+ })
|
|
|
+ .catch((err: string) => message.error(err))
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ function handleSearch(value: string) {
|
|
|
+ const findResult = myFriends.value.find((e) => String(e.frienduserid).includes(value));
|
|
|
+ if (findResult) {
|
|
|
+ searchFriend.value = [findResult];
|
|
|
+ } else {
|
|
|
+ queryMyFriend(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
initData(() => {
|
|
|
queryMyFriend();
|
|
|
});
|
|
|
- return { deleteFriend, addFriend, friendsList };
|
|
|
+ return { operate, myFriends, loading, handleSearch, searchFriend };
|
|
|
},
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|
|
|
+.my-friend {
|
|
|
+ height: 340px;
|
|
|
+ width: 260px;
|
|
|
+}
|
|
|
</style
|
|
|
>;
|