吉安感知网项目-前端
chenyao
2026-01-08 e0afc7aeb6b1445a8cc9dddf3e37de1ce0ecd0c7
feat:更新小程序
3 files modified
33 ■■■■ changed files
uniapps/work-wx/src/api/user/index.js 6 ●●●●● patch | view | raw | blame | history
uniapps/work-wx/src/config/env.js 2 ●●● patch | view | raw | blame | history
uniapps/work-wx/src/pages/login/index.vue 25 ●●●● patch | view | raw | blame | history
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,
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',
  
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;