吉安感知网项目-前端
张含笑
2026-02-24 83f3a4c10eecb80204f61c1210d3685e20c0a9f7
feat:获取登录账号信息
2 files modified
49 ■■■■■ changed files
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue 36 ●●●● patch | view | raw | blame | history
uniapps/work-app/src/pages/login/index.vue 13 ●●●● patch | view | raw | blame | history
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
@@ -44,11 +44,11 @@
/** ✅ 你的 WS 地址前缀(后面拼 userId) */
// const WS_BASE = 'ws://218.202.104.82:38201/ws/chat?userId='
const WS_BASE = 'ws://218.202.104.82:38201/ws/chat'
const uid = ref('2021475329842999298')
const newUserInfo = ref(null)
const uid = ref('')
const peerUid = ref('2021474568497131521')
// 联系人名称
const contactName = ref('张三')
const contactName = ref('')
const connected = ref(false)
const state = ref('idle') // idle | calling | ringing | in-call
@@ -138,16 +138,16 @@
// 从URL参数或本地存储获取用户ID
const getUserIdFromStorage = () => {
    // 从url获取用户id
    const contact = JSON.parse(decodeURIComponent(receiveParameters.value))
    console.log('从url获取用户id',contact?.userId)
    // 从本地获取用户id
    const userId = localStorage.getItem('userId') || sessionStorage.getItem('userId')
    console.log('从本地存储获取userId:', userId)
    if (userId) {
    const userId = '2021474815063486465'
    try {
        const params = JSON.parse(decodeURIComponent(route.query.params));
        newUserInfo.value = params.new_userInfo
        const userIdFromParams = params.new_userInfo?.userId
        console.log('从url获取用户id', userIdFromParams)
        return userIdFromParams || userId
    } catch (error) {
        return userId
    }
    return '2021475329842999298' // 默认值
}
// 心跳
@@ -591,8 +591,8 @@
const receiveParameters = ref(route.query.contact || null);
onMounted(() => {
    console.log('收拾收拾',route.query.voiceparams);
    console.log('接收参数', receiveParameters)
    console.log('对方打给我的',route.query.voiceparams);
    console.log('接收拨打电话:对方参数', receiveParameters)
    if (route.query && route.query.params) {
        try {
            const params = JSON.parse(decodeURIComponent(route.query.params));
@@ -609,11 +609,11 @@
    if (receiveParameters.value) {
        try {
            const contact = JSON.parse(decodeURIComponent(receiveParameters.value))
            if (contact.friendId) {
                peerUid.value = contact.friendId
                contactName.value = contact.friendNickName || '未知联系人'
                log('🔗 从contact参数获取peerUid:', contact.friendId)
                log('👤 联系人名称:', contactName.value)
            if (contact.userId) {
                peerUid.value = contact.userId
                contactName.value = contact.nickName || '未知联系人'
                // log('🔗 从contact参数获取peerUid:', peerUid.value)
                // log('👤 联系人名称:', contactName.value)
            }
        } catch (e) {
            log('❌ 解析contact参数失败:', String(e))
uniapps/work-app/src/pages/login/index.vue
@@ -38,7 +38,7 @@
import { getAssetsImage } from "@/utils/index.js";
import {ticketLoginInterfaceApi} from '@/api/work/index.js'
import md5 from "js-md5";
import { loginByUsername } from "@/api/user/index.js";
import { loginByUsername,getUserInfo } from "@/api/user/index.js";
import { useUserStore, useLocationStore } from "@/store/index.js";
import locationUtil from "@/utils/location.js";
import websocketService from "@/utils/websocket.js";
@@ -85,6 +85,15 @@
  username: "zhx",
  password: "123456",
});
const getUserInfoData = () => {
  getUserInfo().then((res) => {
   const currentUserInfo = userStore.$state.userInfo;
      userStore.setUserInfo({
        ...currentUserInfo,
        new_userInfo: res.data.data
      });
  });
};
async function submit() {
  if (!loginForm.value.username.trim()) {
@@ -151,7 +160,7 @@
    } catch (error) {
      console.error('处理位置服务失败:', error);
    }
await getUserInfoData()
 // 调用工单登录接口
    await gdLogin()