فهرست منبع

Merge branch '165' of uskycloud/usky-web-mobile into master

xf15575941817 2 سال پیش
والد
کامیت
6052411412
4فایلهای تغییر یافته به همراه21 افزوده شده و 22 حذف شده
  1. 0 6
      src/config.js
  2. 17 13
      src/pages/login.vue
  3. 2 0
      src/pages/serveConfig.vue
  4. 2 3
      src/utils/request.js

+ 0 - 6
src/config.js

@@ -1,12 +1,6 @@
 // 应用全局配置
 export default {
-  //#ifdef H5
   baseUrl: import.meta.env.MODE === "production" ? "http://mobile.usky.cn:8099/prod-api" : "http://172.16.120.165:13200/prod-api",
-  //#endif
-
-  //#ifdef APP-PLUS
-  baseUrl: "http://" + uni.getStorageSync("serveUrl") + "/prod-api",
-  //#endif
 
   websiteUrl: "https://qhome.usky.cn",
   // NODE_ENV=devlopment

+ 17 - 13
src/pages/login.vue

@@ -76,7 +76,6 @@
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { reactive, getCurrentInstance, toRefs, inject, watchEffect } from "vue";
 import { getToken, setToken, removeToken } from "@/utils/auth";
-import { Lock, User, Cellphone } from "@element-plus/icons-vue";
 import { getCodeImg, getMobileTenantConfig } from "@/api/login";
 
 import publicStore from "@/store/modules/public.js";
@@ -221,6 +220,13 @@ function submitRes() {
   }
   //#endif
 
+  //#ifdef APP-PLUS
+  if (userChecked.value) {
+    proxy.$modal.msg("请在阅读并同意 用户协议和隐私协议后登录");
+    return;
+  }
+  //#endif
+
   if (switchText.value == "账号密码登录") {
     if (!phone.value) {
       proxy.$modal.msg("请输入手机号码");
@@ -234,6 +240,11 @@ function submitRes() {
       proxy.$modal.msg("请输入验证码");
       return;
     }
+    login({
+      phone: phone.value,
+      verify: verify.value,
+      tenantId: tenantId.value,
+    });
   } else {
     if (!username.value) {
       proxy.$modal.msg("请输入账户");
@@ -243,20 +254,13 @@ function submitRes() {
       proxy.$modal.msg("请输入密码");
       return;
     }
-  }
 
-  //#ifdef APP-PLUS
-  if (userChecked.value) {
-    proxy.$modal.msg("请在阅读并同意 用户协议和隐私协议后登录");
-    return;
+    login({
+      username: username.value,
+      password: password.value,
+      tenantId: tenantId.value,
+    });
   }
-  //#endif
-
-  login({
-    username: username.value,
-    password: password.value,
-    tenantId: tenantId.value,
-  });
 }
 
 /** 获取登录数据 */

+ 2 - 0
src/pages/serveConfig.vue

@@ -21,6 +21,7 @@
 </template>
 
 <script setup>
+import config from "@/config";
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
 import { getToken, setToken, removeToken } from "@/utils/auth";
@@ -91,6 +92,7 @@ function handleSubmit() {
   }
 
   uni.setStorageSync("serveUrl", linkUrl.value + ":" + port.value);
+  config.baseUrl = "http://" + uni.getStorageSync("serveUrl") + "/prod-api";
   navigateTo();
 }
 

+ 2 - 3
src/utils/request.js

@@ -1,11 +1,10 @@
 import useStores from "@/store/modules/user.js";
-import config from "@/config";
+import configs from "@/config";
 import { getToken } from "@/utils/auth";
 import modal from "@/plugins/modal";
 import common from "@/plugins/common";
 
 let timeout = 10000;
-const baseUrl = config.baseUrl;
 
 const request = (config) => {
   const useStore = useStores();
@@ -26,7 +25,7 @@ const request = (config) => {
       .request({
         method: config.method || "get",
         timeout: config.timeout || timeout,
-        url: config.baseUrl || baseUrl + config.url,
+        url: config.baseUrl || configs.baseUrl + config.url,
         data: config.data,
         header: config.header,
         dataType: "json",