Sfoglia il codice sorgente

添加聊天接口

wkw 1 settimana fa
parent
commit
9eb72b7f45

+ 1 - 0
package.json

@@ -46,6 +46,7 @@
     "lodash": "^4.17.21",
     "pinia": "^3.0.1",
     "pinia-plugin-persistedstate": "^4.4.1",
+    "pinyin": "^4.0.0",
     "qrcode.vue": "^3.6.0",
     "semver": "^7.7.2",
     "sharp": "^0.34.2",

+ 13 - 3
src/api/path/im.api.js

@@ -27,8 +27,8 @@ export function userFriend(param) {
 }
 
 // 获取用户详情
-export function userUuid(id) {
-  return service.get(`user/${id}`);
+export function userUuid(uuid) {
+  return service.get(`user/${uuid}`);
 }
 
 // 获取消息
@@ -41,8 +41,18 @@ export function friendRequest(params) {
   return service.get("user/friend/request", { params });
 }
 
-// 添加好友
+// 同意或者拒绝好友
 export function friendAudit(param) {
   return service.post('user/friend/audit', param);
 }
 
+// 获取群组信息
+export function groupList(uuid) {
+  return service.get(`group/${uuid}`);
+}
+
+// 加入群组
+export function groupJoin(param) {
+  return service.post(`/group/join/:userUuid/:groupUuid`, param);
+}
+

+ 1 - 1
src/router/system.js

@@ -12,7 +12,7 @@ export const systemRoutes = [
         name: "im",
         meta: {
           title: "router.Social",
-          keepAlive: true,
+          keepAlive: false,
           navbar: false,
           tabbar: true,
         }, // 社交

+ 2 - 1
src/stores/modules/walletStore.js

@@ -6,6 +6,7 @@ import { sysLogin } from "@/common/login.js";
 import { showNotify } from 'vant';
 import router from '@/router/index'
 import { hotTokens } from '@/api/path/login.api'
+import { cryptoDecode } from "@/utils/crypto.js"
 
 
 export const useWalletStore = defineStore("useWalletStore", {
@@ -137,7 +138,7 @@ export const useWalletStore = defineStore("useWalletStore", {
         showNotify({ type: 'warning', message: '钱包不存在' });
         return;
       }
-      if (wallet.accountPassword !== password) {
+      if (cryptoDecode(wallet.accountPassword) !== password) {
         showNotify({ type: 'warning', message: '请输入正确的密码' });
         return;
       }

+ 3 - 3
src/updater/update.json

@@ -1,7 +1,7 @@
 {
-  "version": "1.0.36",
-  "releaseDate": "2025-08-01 10:07:07",
-  "checksum": "7ad222dbd486ecbcb7fd31bac5ff8f65fb6a0166a02c3fea0155282e941dfee0",
+  "version": "1.0.37",
+  "releaseDate": "2025-08-05 10:32:17",
+  "checksum": "6384cf5e11ad534a84fca6f1f2a545b24f6ad16977f78b6580a31bf38e0ad5d0",
   "minBinaryVersion": "1.0.0",
   "mandatory": true,
   "upDataDescription": "✨修正一些錯誤。。。。!!!"

+ 10 - 0
src/utils/utils.js

@@ -1,3 +1,4 @@
+import pinyin from 'pinyin'
 /**
  * * 生成一个不重复的ID
  * @param { Number } randomLength
@@ -60,3 +61,12 @@ export const getParseLang = (data, lang) => {
   }
 };
 
+export const getFirstLetter = (name) => {
+  const py = pinyin(name[0], {
+    style: pinyin.STYLE_FIRST_LETTER,
+    heteronym: false
+  });
+  const letter = py?.[0]?.[0]?.toUpperCase() || '#';
+  return /^[A-Z]$/.test(letter) ? letter : '#';
+}
+

+ 12 - 0
src/views/im/contactList/groupList/index.vue

@@ -25,10 +25,22 @@
 </template>
 
 <script setup>
+import { useWalletStore } from "@/stores/modules/walletStore";
+import { groupList } from "@/api/path/im.api";
+const walletStore = useWalletStore();
+
+
 const value = ref('');
 const onSearch = () => {
     
 }
+const getgroupList = async () => {
+    const res = await groupList(walletStore.account);
+    console.log(res)
+}
+onMounted(() => {
+    getgroupList();
+});
 </script>
 
 <style lang="less" scoped>

+ 39 - 53
src/views/im/contactList/index.vue

@@ -27,71 +27,57 @@
                                         round
                                         :src="item.avatar"
                                     />
-                                    <div>{{ item.name }}</div>
+                                    <div>{{ item.nickname }}</div>
                                 </div>
                             </template>
                         </van-cell>
                     </van-cell-group>
                 </template>
             </van-index-bar>
-            <div class="total">7个朋友</div>
+            <div class="total">{{memberGroups.length}}个朋友</div>
         </div>
     </div>
 </template>
 
 <script setup>
+import { userList } from "@/api/path/im.api";
+import {getFirstLetter} from "@/utils/utils";
+import { useWalletStore } from "@/stores/modules/walletStore";
 const router = useRouter();
-const memberGroups = ref([
-  {
-    index: 'A',
-    members: [
-      { id: '1', name: '安琪拉', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '2', name: '艾琳', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'B',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'C',
-    members: [
-      { id: '1', name: '安琪拉', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '2', name: '艾琳', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'D',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'E',
-    members: [
-      { id: '1', name: '安琪拉', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '2', name: '艾琳', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'F',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'G',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-]);
+const walletStore = useWalletStore();
+
+const memberGroups = ref([]);
+
+const getuserList = async () => {
+  const res = await userList({ uuid: walletStore.account });
+  const groupedMap = {};
+
+  res.data.forEach(user => {
+    const name = user.nickname || '';
+    const firstLetter = getFirstLetter(name); // 获取首字母
+
+    if (!groupedMap[firstLetter]) {
+      groupedMap[firstLetter] = [];
+    }
+
+    groupedMap[firstLetter].push({...user});
+  });
+
+  // 转为数组并按 index 排序
+  const groupedList = Object.keys(groupedMap)
+    .sort()
+    .map(letter => ({
+      index: letter,
+      members: groupedMap[letter]
+    }));
+
+  memberGroups.value = groupedList;
+  console.log(memberGroups.value)
+};
+
+onMounted(() => {
+  getuserList();
+});
 </script>
 
 <style lang="less" scoped>

+ 23 - 11
src/views/im/contactList/invitation/index.vue

@@ -10,18 +10,25 @@
                     <van-image class="item-img" round src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"/>
                     <div class="item-ri-cont">
                         <div>
-                            <div v-if="type == 1 && list.length > 0">
-                                <span class="name">{{item.nickname}}</span>申请添加您为好友
+                            <div v-if="type == 1">
+                                <span class="name">{{ item.nickname }}</span>申请添加您为好友
                             </div>
-                            <div v-if="type == 2 && list.length > 0">
-                                请求添加<span class="name">{{item.nickname}}</span>为好友
+                            <div v-else-if="type == 2">
+                                请求添加<span class="name">{{ item.nickname }}</span>为好友
                             </div>
-                            <!-- <div class="fs12">1213</div> -->
                         </div>
-                        <div v-if="type == 1" class="item-btn" @click="changeBtn(item)">同意</div>
-                        <div class="fs12" v-if="type == 2"
-                            :class="item.status == 1?'fs90':item.status == 3?'fscolor':''">
-                            {{item.status == 1?'待同意':item.status == 2?'发消息':'已拒绝'}}
+
+                        <!-- 左边操作按钮或文字 -->
+                        <div v-if="type == 1 && item.status == 1" class="item-btn" @click="changeBtn(item)">同意</div>
+                        <div v-else-if="type == 2 && item.status == 1" class="fs12 fs90">待同意</div>
+
+                        <!-- 右边状态展示(仅 status ≠ 1 时) -->
+                        <div
+                            v-if="item.status !== 1"
+                            class="fs12"
+                            :class="item.status == 2 ? '' : 'fscolor'"
+                        >
+                            {{ item.status == 2 ? '已添加' : '已拒绝' }}
                         </div>
                     </div>
                 </div>
@@ -37,7 +44,7 @@
             <div class="pop-content-password">
                 <div class="pop-title-password">你确定同意该好友的请求吗?</div>
                 <div class="pop-btn-password" style="margin-top: 50px;">
-                    <van-button type="default" class="btn-password cancel" @click="showAgree = false">拒绝</van-button>
+                    <van-button type="default" class="btn-password cancel" @click="changeFun(3)">拒绝</van-button>
                     <van-button type="default" class="btn-password confirm" @click="changeFun(2)">同意</van-button>
                 </div>
             </div>
@@ -47,6 +54,7 @@
 
 <script setup>
 import { friendRequest,friendAudit } from "@/api/path/im.api";
+import { showToast } from 'vant';
 import { useWalletStore } from "@/stores/modules/walletStore";
 const walletStore = useWalletStore();
 
@@ -59,7 +67,6 @@ const activeItem = ref({})
 const getfriendRequest = async () => {
     const res = await friendRequest({uuid:walletStore.account,status:type.value});
     list.value = res.data;
-    console.log(res)
 }
 const changeBtn = (item) => {
     showAgree.value = true;
@@ -70,8 +77,13 @@ const changeTab = (val) => {
     list.value = [];
     getfriendRequest();
 }
+//他弹框是否同意
 const changeFun = async (val) => {
     const res = await friendAudit({uuid:walletStore.account,status:val,friendUsername:activeItem.value.uuid});
+    if(res.code == 200){
+        let text = val == 2?'添加成功':'已拒绝'
+        showToast(text);
+    }
 }
 onMounted(()=>{
     getfriendRequest();

+ 38 - 52
src/views/im/detail/addMember/index.vue

@@ -21,7 +21,7 @@
                             <template #title>
                                 <div class="cell-item">
                                     <van-image class="img-icon" round :src="item.avatar" />
-                                    <div>{{ item.name }}</div>
+                                    <div>{{ item.nickname }}</div>
                                 </div>
                             </template>
                         </van-cell>
@@ -47,61 +47,42 @@
   
 
 <script setup>
+import { userList } from "@/api/path/im.api";
+import {getFirstLetter} from "@/utils/utils";
+import { useWalletStore } from "@/stores/modules/walletStore";
 const router = useRouter();
+const walletStore = useWalletStore();
+
 
 const checked = ref([]);
+const memberGroups = ref([]);
+
+const getuserList = async () => {
+  const res = await userList({ uuid: walletStore.account });
+  const groupedMap = {};
+
+  res.data.forEach(user => {
+    const name = user.nickname || '';
+    const firstLetter = getFirstLetter(name); // 获取首字母
+
+    if (!groupedMap[firstLetter]) {
+      groupedMap[firstLetter] = [];
+    }
 
-const memberGroups = ref([
-  {
-    index: 'A',
-    members: [
-      { id: '1', name: '安琪拉', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '2', name: '艾琳', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'B',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'C',
-    members: [
-      { id: '1', name: '安琪拉', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '2', name: '艾琳', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'D',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'E',
-    members: [
-      { id: '1', name: '安琪拉', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '2', name: '艾琳', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'F',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-  {
-    index: 'G',
-    members: [
-      { id: '3', name: '白起', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-      { id: '4', name: '百里守约', avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg' },
-    ],
-  },
-]);
+    groupedMap[firstLetter].push({...user});
+  });
+
+  // 转为数组并按 index 排序
+  const groupedList = Object.keys(groupedMap)
+    .sort()
+    .map(letter => ({
+      index: letter,
+      members: groupedMap[letter]
+    }));
+
+  memberGroups.value = groupedList;
+  console.log(memberGroups.value)
+};
 
 const checkboxRefs = ref([]);
 onBeforeUpdate(() => {
@@ -123,9 +104,14 @@ const toggle = (groupIndex, index) => {
 const submit = () => {
     if(checked.value.length == 0) return;
     console.log("已选择成员:", checked.value);
+    
     router.push('detail')
 };
 
+
+onMounted(() => {
+  getuserList();
+});
 </script>
 
 <style lang="less" scoped>

+ 2 - 1
src/views/wallet/transferDetail/index.vue

@@ -108,6 +108,7 @@ import { useRouter,useRoute } from 'vue-router'
 import { useWalletStore } from "@/stores/modules/walletStore";
 import Web3 from "web3";
 import pubData from "@/utils/pub.json";
+import { cryptoDecode } from "@/utils/crypto.js"
 import { showLoadingToast,showToast } from 'vant';
 import { showNotify } from 'vant';
 
@@ -217,7 +218,7 @@ const cancel = () => {
 }
 // 密码确认
 const popConfirm = () => {
-    if(passWord.value != walletStore.accountPassword){
+    if(passWord.value != cryptoDecode(walletStore.accountPassword)){
         showNotify({ type: 'warning', message: $t('wallet.PleaseEnterTheCorrectPassword') });
     }else{
         getData();

+ 2 - 1
src/views/wallet/walletDetail/index.vue

@@ -76,6 +76,7 @@ import QrcodeVue from 'qrcode.vue';
 import { useWalletStore } from '@/stores/modules/walletStore';
 import { showNotify } from 'vant';
 import { useRoute } from 'vue-router';
+import { cryptoDecode } from "@/utils/crypto.js"
 import { useCopy } from "@/hooks/use-copy.js";
 useCopy();
 
@@ -122,7 +123,7 @@ const confirm = () => {
         walletStore.deleteWallet(id, text.value);
     } else if (type.value == 2) {
         // 查看私钥或者密码
-        if (text.value != currentWallet.value.accountPassword) {
+        if (text.value != cryptoDecode(currentWallet.value.accountPassword)) {
             showNotify({ type: 'warning', message: $t('wallet.PleaseEnterTheCorrectPassword') });
         } else {
             showkey.value = true;