瀏覽代碼

添加好友功能

huangbin 4 年之前
父節點
當前提交
f8388d08e6

+ 11 - 0
src/layout/components/header.vue

@@ -28,6 +28,15 @@
             </a-input-search>-->
       <!-- <a-icon type="search" /> -->
     </div>
+    <div>
+      <a-popover trigger="hover"
+                 placement="bottom">
+        <template #content>
+          <Friend />
+        </template>
+        <span>好友</span>
+      </a-popover>
+    </div>
     <div class="news-container">
       <a-badge @click="openNotice"
                :dot="getUnReadNoticeLength() > 0">
@@ -75,6 +84,7 @@ import { handleNotice } from '@/views/setting/notice/setup';
 import { isOemByEnum, OemType } from '@/common/config/projectName';
 import { changeTheme, ThemeEnum } from '@/common/config/theme';
 import { initData } from '@/common/methods';
+import Friend from '@/views/setting/friends/index.vue';
 
 // 设置
 const setFn = () => {
@@ -126,6 +136,7 @@ export default defineComponent({
     components: {
         UserOutlined,
         Setting,
+        Friend,
     },
     props: {
         collapsed: {

+ 6 - 6
src/services/proto/accountinfo/interface.ts

@@ -204,13 +204,13 @@ export interface AuditWskhUserInfoRsp {
 // // 好友操作请求 0 29 197
 export interface FriendOperateReq {
     operatetype: number; // 操作类型-1:申请 2:审核通过 3:审核拒绝 4: 删除
-    friendapplyid: number; // 申请ID
+    friendapplyid?: number; // 申请ID
     userid: number; // 申请人用户ID
     frienduserid: number; // 好友用户ID
     applysrc: number; // 申请来源 - 1:管理端 2:终端
-    applicantid: number; // 申请人登录ID
-    remark: number; // 备注
-    auditorid: number; // 审核人用户ID
-    auditsrc: number; // 审核来源 - 1:管理端 2:终端
-    auditremark: number; // 审核备注
+    applicantid?: number; // 申请人登录ID
+    remark?: string; // 备注
+    auditorid?: number; // 审核人用户ID
+    auditsrc?: number; // 审核来源 - 1:管理端 2:终端
+    auditremark?: number; // 审核备注
 }

+ 43 - 21
src/views/setting/friends/index.vue

@@ -1,43 +1,65 @@
 <template>
   <!-- 我的好友 -->
-  <div>
-    <a-auto-complete placeholder="输入好友代码进行搜索">
-
-    </a-auto-complete>
-  </div>
+  <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>
+  </a-spin>
 </template>
 
 <script lang="ts">
 import { defineComponent, ref } from 'vue';
-import { closeModal } from '@/common/setup/modal/index';
-import NoticeContent from './components/noticeContent.vue';
 import { initData } from '@/common/methods';
-import { queryTableList } from '@/common/setup/table';
 import { QueryWrFriendApplyRsp } from '@/services/go/wrtrade/interface';
 import { queryQueryWrFriendApply } from '@/services/go/wrtrade';
 import { friendOperate } from '@/services/proto/accountinfo';
+import { getUsrId } from '@/services/bus/user';
+import { queryResultLoadingAndInfo, requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 
 export default defineComponent({
-    name: 'notice',
-    components: {
-        NoticeContent,
-    },
+    name: 'friend',
     setup() {
-        // const { visible, cancel } = closeModal('notice');
+        const loading = ref<boolean>(false);
+        const friendsList = ref<QueryWrFriendApplyRsp[]>([]);
         // 设置 新增和删除好友 公共请求参数
-        function getParam() {
-            return {};
+        // operatetype: number; // 操作类型-1:申请 2:审核通过 3:审核拒绝 4: 删除
+        function getParam(operatetype: 1 | 2 | 3 | 4, frienduserid: number) {
+            return {
+                operatetype,
+                userid: getUsrId(),
+                frienduserid,
+                applysrc: 2,
+            };
         }
         // 删除好友
-        function deleteFriend() {}
+        function deleteFriend(frienduserid: number) {
+            const param = getParam(4, frienduserid);
+            requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']);
+        }
+
         // 添加好友
-        function addFriend() {}
-        initData(() => {
-            queryQueryWrFriendApply().then((res) => {
-                console.log('好友', res);
+        function addFriend(frienduserid: number) {
+            const param = getParam(1, frienduserid);
+            requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']);
+        }
+        // 查询我的好友列表
+        function queryMyFriend() {
+            queryResultLoadingAndInfo(queryQueryWrFriendApply, loading).then((res) => {
+                friendsList.value = res;
             });
+        }
+        initData(() => {
+            queryMyFriend();
         });
-        return {};
+        return { deleteFriend, addFriend, friendsList };
     },
 });
 </script>

+ 25 - 26
src/views/setting/notice/components/noticeContent.vue

@@ -1,30 +1,29 @@
 <template>
-    <div class="notice-content">
-        <aside>
-            <a-list item-layout="horizontal" :data-source="noticeList">
-                <template #renderItem="{ item }">
-                    <a-list-item @click="choose(item)">
-                        <a-list-item-meta :description="formatTime(item.createtime)">
-                            <template #title>
-                                <a
-                                    :style="{ color: item.readed ? '@m-grey2' : '@m-white1' }"
-                                    href="javascript:;"
-                                >{{ item.title }}</a>
-                            </template>
-                            <template #avatar>
-                                <a-badge :color="item.readed ? '@m-grey2' : 'orange'" />
-                            </template>
-                        </a-list-item-meta>
-                    </a-list-item>
-                </template>
-            </a-list>
-        </aside>
-        <main>
-            <h4>{{ chooseItemNotice.title }}</h4>
-            <p>{{ formatTime(chooseItemNotice.createtime) }}</p>
-            <div>{{ chooseItemNotice.content }}</div>
-        </main>
-    </div>
+  <div class="notice-content">
+    <aside>
+      <a-list item-layout="horizontal"
+              :data-source="noticeList">
+        <template #renderItem="{ item }">
+          <a-list-item @click="choose(item)">
+            <a-list-item-meta :description="formatTime(item.createtime)">
+              <template #title>
+                <a :style="{ color: item.readed ? '@m-grey2' : '@m-white1' }"
+                   href="javascript:;">{{ item.title }}</a>
+              </template>
+              <template #avatar>
+                <a-badge :color="item.readed ? '@m-grey2' : 'orange'" />
+              </template>
+            </a-list-item-meta>
+          </a-list-item>
+        </template>
+      </a-list>
+    </aside>
+    <main>
+      <h4>{{ chooseItemNotice.title }}</h4>
+      <p>{{ formatTime(chooseItemNotice.createtime) }}</p>
+      <div>{{ chooseItemNotice.content }}</div>
+    </main>
+  </div>
 </template>
 
 <script lang="ts">