| | |
| | | |
| | | /** 退出登录 */ |
| | | export const logout = () => post("/user/logout") |
| | | // 工单用户登录接口 |
| | | export const ticketLoginInterfaceApi = (tenantId, deptId, roleId, username, password, type, key, code) => { |
| | | return request({ |
| | | url: '/blade-auth/oauth/token', |
| | | method: 'post', |
| | | header: { |
| | | 'Tenant-Id': tenantId, |
| | | 'Dept-Id': website.switchMode ? deptId : '', |
| | | 'Role-Id': website.switchMode ? roleId : '', |
| | | 'Captcha-Key': key, |
| | | 'Captcha-Code': code, |
| | | }, |
| | | params: { |
| | | tenantId, |
| | | username, |
| | | password, |
| | | grant_type: 'password', |
| | | scope: 'all', |
| | | type, |
| | | }, |
| | | }) |
| | | } |
| | | |
| | | // 用户登录接口 |
| | | export const loginByUsername = (tenantId, deptId, roleId, username, password, type, key, code) => { |
| | |
| | | import { request } from "@/utils/requestGd/index.js" |
| | | |
| | | // 获取工单列表 |
| | | export const getGdList = data => { |
| | | return request({ |
| | | url: '/system/user/profile/update', |
| | |
| | | VITE_APP_WEBVIEW_URL: 'https://wrj.shuixiongit.com/drone-app-web-view/#/webViewWrapper', |
| | | // VITE_APP_WEBVIEW_URL: 'https://192.168.1.157:5176/mobile-web-view/#/webViewWrapper', |
| | | VITE_API_BASE_URL: 'http://218.202.104.82:8200', |
| | | VITE_API_BASE_URL_GD: 'https://wrj.shuixiongit.com/api', |
| | | // VITE_API_BASE_URL: 'https://aisky.org.cn/api', |
| | | VITE_APP_WS_API_URL:'wss://wrj.shuixiongit.com/drone-wss/api/v1/ws', |
| | | |
| | |
| | | |
| | | // 消息处理 |
| | | function messageHandler(payload) { |
| | | console.log('🌐 全局WebSocket收到消息111111111111111111111:', payload) |
| | | // console.log('🌐 全局WebSocket收到消息111111111111111111111:', payload) |
| | | // 先尝试直接处理消息(适用于mobile-web-view的voiceCallDetail页面的消息格式) |
| | | const t = (payload.type || '').toString() |
| | | // const bizCode = payload.biz_code || '' |
| | |
| | | <script setup> |
| | | import { getAssetsImage } from "@/utils/index.js"; |
| | | import md5 from "js-md5"; |
| | | import { loginByUsername } from "@/api/user/index.js"; |
| | | import { loginByUsername,ticketLoginInterfaceApi } from "@/api/user/index.js"; |
| | | import { useUserStore, useLocationStore } from "@/store/index.js"; |
| | | import locationUtil from "@/utils/location.js"; |
| | | import websocketService from "@/utils/websocket.js"; |
| | |
| | | url: '/subPackages/userDetail/password/index' |
| | | }); |
| | | } |
| | | |
| | | const loginFormGd = ref({ |
| | | username: "zhx", |
| | | password: "123456", |
| | | }); |
| | | async function submit() { |
| | | // 调用工单登录接口 |
| | | await gdLogin(); |
| | | if (!loginForm.value.username.trim()) { |
| | | uni.showToast({ |
| | | title: "请输入用户名", |
| | |
| | | userInfo.key, |
| | | userInfo.code |
| | | ); |
| | | userStore.setUserInfo(res.data.data); |
| | | userStore.setUserInfo(res.data.data); |
| | | // 请求位置权限并初始化位置服务 |
| | | try { |
| | | // 请求位置权限 |
| | |
| | | } catch (error) { |
| | | console.error('处理位置服务失败:', error); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | uni.reLaunch({ |
| | | url: "/pages/work/index", |
| | | }); |
| | |
| | | icon: "none", |
| | | duration: 2000, |
| | | }); |
| | | // 即使原始登录失败,也尝试调用工单登录接口 |
| | | await gdLogin(); |
| | | } |
| | | } |
| | | |
| | | // 工单登录 |
| | | async function gdLogin() { |
| | | let userInfo = { |
| | | tenantId: "000000", |
| | | deptId: "", |
| | | roleId: "", |
| | | username: loginFormGd.value.username, |
| | | password: loginFormGd.value.password, |
| | | type: "account", |
| | | code: "", |
| | | key: "", |
| | | }; |
| | | try { |
| | | const res = await ticketLoginInterfaceApi( |
| | | userInfo.tenantId, |
| | | userInfo.deptId, |
| | | userInfo.roleId, |
| | | userInfo.username, |
| | | md5(userInfo.password), |
| | | userInfo.type, |
| | | userInfo.key, |
| | | userInfo.code |
| | | ); |
| | | console.log('工单登录',res) |
| | | // 存储工单token到用户信息中 |
| | | if (res.data?.access_token) { |
| | | const currentUserInfo = userStore.$state.userInfo; |
| | | userStore.setUserInfo({ |
| | | ...currentUserInfo, |
| | | gd_access_token: res.data.access_token |
| | | }); |
| | | } |
| | | } catch (error) { |
| | | const errorMsg = |
| | | error.data?.error_description !== "Bad credentials" |
| | | ? error.data?.error_description |
| | | : "登录失败,请重试"; |
| | | console.error('工单登录失败:', errorMsg); |
| | | } |
| | | } |
| | | // 从本地存储加载记住的密码 |
| | | onMounted(() => { |
| | | const savedUserInfo = uni.getStorageSync("rememberedUser"); |
| | |
| | | import Request from "uview-plus/libs/luch-request/index" |
| | | import configEnv from "@/config/env.js"; |
| | | import {getEnvObj} from "@/utils/index.js"; |
| | | import { useUserStore } from "@/store/index.js"; |
| | | import website from '@/config/website'; |
| | | import Base64 from '@/utils/base64.js'; |
| | | |
| | | const http = new Request() |
| | | |
| | |
| | | // 请求拦截器 |
| | | function requestInterceptors(http) { |
| | | |
| | | http.interceptors.request.use((config) => { |
| | | const {detail} = useUserStore().$state?.userInfo || {} |
| | | // 假设有token值需要在头部需要携带 |
| | | let accessToken = useUserStore()?.$state?.userInfo?.access_token; |
| | | if (accessToken) { |
| | | // config.header['Blade-Auth'] = 'bearer ' + accessToken; |
| | | config.header['authorization'] = accessToken; |
| | | } |
| | | // if (detail?.areaCode) { |
| | | // config.header['areaCode'] = detail.areaCode |
| | | // } |
| | | // 安全请求header |
| | | // config.header['Blade-Requested-With'] = 'BladeHttpRequest'; |
| | | // 客户端认证参数 |
| | | // config.header['Authorization'] = 'Basic ' + Base64.encode(website.clientId + ':' + website.clientSecret); |
| | | return config |
| | | }, config => { // 可使用async await 做异步操作 |
| | | return Promise.reject(config) |
| | | }) |
| | | http.interceptors.request.use((config) => { |
| | | const {detail} = useUserStore().$state?.userInfo || {} |
| | | // 假设有token值需要在头部需要携带 |
| | | let accessToken = useUserStore()?.$state?.userInfo?.gd_access_token; |
| | | if (accessToken) { |
| | | config.header['Blade-Auth'] = 'bearer ' + accessToken; |
| | | } |
| | | if (detail?.areaCode) { |
| | | config.header['areaCode'] = detail.areaCode |
| | | } |
| | | // 安全请求header |
| | | config.header['Blade-Requested-With'] = 'BladeHttpRequest'; |
| | | // 客户端认证参数 |
| | | config.header['Authorization'] = 'Basic ' + Base64.encode(website.clientId + ':' + website.clientSecret); |
| | | return config |
| | | }, config => { // 可使用async await 做异步操作 |
| | | return Promise.reject(config) |
| | | }) |
| | | } |
| | | |
| | | function responseInterceptors(http) { |
| | |
| | | export function setupRequest () { |
| | | http.setConfig(defaultConfig => { |
| | | /* defaultConfig 为默认全局配置 */ |
| | | defaultConfig.baseURL = getEnvObj().VITE_API_BASE_URL |
| | | defaultConfig.baseURL = getEnvObj().VITE_API_BASE_URL_GD |
| | | // #ifdef H5 |
| | | if (import.meta.env.VITE_APP_PROXY === "true") { |
| | | defaultConfig.baseURL = import.meta.env.VITE_API_PREFIX |