From e0afc7aeb6b1445a8cc9dddf3e37de1ce0ecd0c7 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Thu, 08 Jan 2026 09:49:08 +0800
Subject: [PATCH] feat:更新小程序
---
uniapps/work-wx/src/pages/login/index.vue | 25 +++++++++++++------------
uniapps/work-wx/src/config/env.js | 2 +-
uniapps/work-wx/src/api/user/index.js | 6 ++++--
3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/uniapps/work-wx/src/api/user/index.js b/uniapps/work-wx/src/api/user/index.js
index bbd5f7c..14685d4 100644
--- a/uniapps/work-wx/src/api/user/index.js
+++ b/uniapps/work-wx/src/api/user/index.js
@@ -26,7 +26,7 @@
// 用户登录接口
export const loginByUsername = (tenantId, deptId, roleId, username, password, type, key, code) => {
return request({
- url: '/blade-auth/oauth/token',
+ url: '/auth/login',
method: 'post',
header: {
'Tenant-Id': tenantId,
@@ -35,10 +35,12 @@
'Captcha-Key': key,
'Captcha-Code': code,
},
- params: {
+ data: {
tenantId,
username,
password,
+ checkCode:'',
+ mobile: false,
grant_type: 'password',
scope: 'all',
type,
diff --git a/uniapps/work-wx/src/config/env.js b/uniapps/work-wx/src/config/env.js
index 36ad8ff..4b84f6f 100644
--- a/uniapps/work-wx/src/config/env.js
+++ b/uniapps/work-wx/src/config/env.js
@@ -14,7 +14,7 @@
// 开发环境这里改为自己的
VITE_APP_WEBVIEW_URL: 'https://wrj.shuixiongit.com/drone-app-web-view/#/webViewWrapper',
// VITE_APP_WEBVIEW_URL: 'http://localhost:5173/drone-app-web-view/#/webViewWrapper',
- VITE_API_BASE_URL: 'https://wrj.shuixiongit.com/api',
+ VITE_API_BASE_URL: 'http://218.202.104.82:8200',
// VITE_API_BASE_URL: 'https://aisky.org.cn/api',
VITE_APP_WS_API_URL:'wss://wrj.shuixiongit.com/drone-wss/api/v1/ws',
diff --git a/uniapps/work-wx/src/pages/login/index.vue b/uniapps/work-wx/src/pages/login/index.vue
index f1c735b..5a9709c 100644
--- a/uniapps/work-wx/src/pages/login/index.vue
+++ b/uniapps/work-wx/src/pages/login/index.vue
@@ -123,7 +123,8 @@
userInfo.deptId,
userInfo.roleId,
userInfo.username,
- md5(userInfo.password),
+ // md5(userInfo.password),
+ userInfo.password,
userInfo.type,
userInfo.key,
userInfo.code
@@ -152,29 +153,29 @@
uni.showToast({ title: '请先同意协议', icon: 'none' });
return;
}
-
+
// loading.value = true;
-
+
try {
// 2. 获取登录凭证 (code)
const loginRes = await uni.login({
provider: 'weixin',
timeout: 10000
});
-
+
if (!loginRes.code) {
throw new Error('获取登录码失败');
}
console.log('获取到code:', loginRes.code);
-
+
// 3. 获取用户信息 (需要用户授权弹窗)
const userProfileRes = await uni.getUserProfile({
desc: '用于完善您的会员信息', // 声明用途,会展示给用户
lang: 'zh_CN'
});
-
+
console.log('用户信息:', userProfileRes.userInfo);
-
+
// 4. 调用后端登录接口
const serverRes = await uni.request({
// url: 'https://你的域名.com/api/wx-login', // 替换为你的真实接口
@@ -189,16 +190,16 @@
// },
// header: { 'Content-Type': 'application/json' }
});
-
+
// 5. 处理登录结果
const { data } = serverRes;
if (data.success && data.token) {
// 保存登录状态
uni.setStorageSync('token', data.token);
uni.setStorageSync('userInfo', data.userInfo || userProfileRes.userInfo);
-
+
uni.showToast({ title: '登录成功', icon: 'success' });
-
+
// 登录成功后的跳转逻辑
const pages = getCurrentPages();
if (pages.length > 1) {
@@ -209,7 +210,7 @@
} else {
throw new Error(data.message || '登录失败');
}
-
+
} catch (error) {
console.error('登录全过程失败:', error);
uni.showToast({
@@ -356,7 +357,7 @@
@apply border-none;
}
}
-
+
.wechat-login-btn {
z-index: 1;
@apply flex items-center justify-center py-12rpx px-0 text-30rpx border-none;
--
Gitblit v1.9.3