Przeglądaj źródła

单点登录优化

xiaohaizhao 4 miesięcy temu
rodzic
commit
ae12f7d167
2 zmienionych plików z 46 dodań i 16 usunięć
  1. 44 14
      pages/login/login.vue
  2. 2 2
      utils/api.js

+ 44 - 14
pages/login/login.vue

@@ -57,9 +57,8 @@
                     <view class="iconfont icon-duanxinyanzheng" style="margin-right: 30rpx;" />
                     <input type="text" :value="imagecaptcha" @input="onInput($event, 'imagecaptcha')"
                         placeholder="登录验证码" class="input" />
-                    <image v-if="timestamp" style="width: 200rpx;"
-                        :src="`https://crm.meida.com:16691/yos/rest/index/imagecaptcha?timestamp=${timestamp}`"
-                        @click="changeTimestamp" mode="widthFix" />
+                    <image v-if="timestamp" style="width: 200rpx;" :src="imageUrl" @click="changeTimestamp"
+                        mode="widthFix" />
                 </view>
             </view>
             <view style="height: 20rpx;">
@@ -156,12 +155,29 @@ function onInput(e, name) {
         inputMap[name].value = e.detail.value;
     }
 }
-let timestamp = ref(Date.now());
+let timestamp = ref(Date.now()),
+    imageUrl = ref(null);
 
 function changeTimestamp() {
     timestamp.value = Date.now();
+    imagecaptcha.value = '';
+    uni.downloadFile({
+        url: 'https://crm.meida.com:16691/yos/rest/index/imagecaptcha?timestamp=' + timestamp.value, //仅为示例,并非真实的资源
+        success: (res) => {
+            imageUrl.value = res.tempFilePath;
+            $Http._handleSessionCookies(res)
+        }
+    });
 }
 
+uni.downloadFile({
+    url: 'https://crm.meida.com:16691/yos/rest/index/imagecaptcha?timestamp=' + timestamp.value, //仅为示例,并非真实的资源
+    success: (res) => {
+        imageUrl.value = res.tempFilePath;
+        $Http._handleSessionCookies(res)
+    }
+});
+
 function validatephonenumber() {
     const selectedCountry = countryCodes.find(country => country.code === countryCode.value);
     if (!selectedCountry || !selectedCountry.regex.test(phonenumber.value)) {
@@ -186,7 +202,7 @@ const downTime = ref(0); // 倒计时初始值
 function getAuthCode() {
     if (downTime.value > 0) return;
     if (!validatephonenumber()) return;
-    $Http.getpassword({ "phonenumber": phonenumber.value, "systemclient": "wechatsaletool" }).then(res => {
+    $Http.getpassword({ "phonenumber": phonenumber.value, "systemclient": "wmeidaserve" }).then(res => {
         console.log('获取验证码结果:', res);
         if (res.code == 1) {
             downTime.value = 60;
@@ -216,7 +232,7 @@ function logIn() {
     if (!validatephonenumber()) return;
     if (isAgreement.value == false) return showModal.value = true;
     loading.value = true;
-    $Http.plogin({ "phonenumber": phonenumber.value, "password": hexMD5(password.value), "systemclient": "wechatsaletool" }).then(res => {
+    $Http.plogin({ "phonenumber": phonenumber.value, "password": hexMD5(password.value), "systemclient": "wmeidaserve" }).then(res => {
         if (res.code == 1) {
             if (res.account_list.length == 1) {
                 handleLogin(res.account_list[0]);
@@ -236,9 +252,7 @@ function logIn() {
 async function accLogIn() {
     if (isAgreement.value == false) return showModal.value = true;
     loading.value = true;
-
-    let isRelease = uni.getAccountInfoSync().miniProgram.envVersion == 'release';
-    const s = isRelease ? await $Http.OldLogin(`?username=${accountno.value}&password=${encodeURIComponent(password1.value)}`) : {
+    const s = $Http.baseUrl == "https://crm.meida.com:16691" ? await $Http.OldLogin(`?username=${accountno.value}&password=${encodeURIComponent(password1.value)}`) : {
         success: false
     };
     console.log("单点登录", s)
@@ -246,8 +260,8 @@ async function accLogIn() {
         "accountno": s.data.userinfo.username,
         "password": s.data.cookie.split("=")[1],
         "imagecaptcha": imagecaptcha.value || '',
-        "systemclient": "wechatsaletool"
-    }) : await $Http.login({ "accountno": accountno.value, "imagecaptcha": imagecaptcha.value, "password": hexMD5(password1.value), "systemclient": "wechatsaletool" });
+        "systemclient": "wmeidaserve"
+    }) : await $Http.login({ "accountno": accountno.value, "imagecaptcha": imagecaptcha.value, "password": hexMD5(password1.value), "systemclient": "wmeidaserve" });
 
     if (res.code == 1) {
         if (res.remindchangepassword) return uni.showModal({
@@ -349,9 +363,25 @@ function handleLogin1(data) {
         uni.setStorageSync('accountnoPwd', '');
     }
 
-    uni.redirectTo({
-        url: '/pages/index/index',
-    });
+
+    $Http.basic({
+        "classname": "sysmanage.develop.userauth.userauth",
+        "method": "query_userauth", //获取用户权限
+        content: {
+            nocache: true
+        }
+    }).then(res => {
+        if (!res.data.length) {
+            uni.showToast({
+                title: '当前用户无使用权限,请联系管理员',
+                icon: 'none',
+            });
+        } else {
+            uni.redirectTo({
+                url: '/pages/index/index',
+            });
+        }
+    })
 
     $Http.basic({
         "classname": "webmanage.site.site",

+ 2 - 2
utils/api.js

@@ -25,13 +25,13 @@ class ApiModel extends HTTP {
     /* 老CRM登录 */
     OldLogin(data) {
         return this.getRequest({
-            url: 'http://61.164.207.46:9082/dmsService/rest/login' + data
+            url: 'https://crm.meida.com/dmsService/rest/login' + data
         })
     }
     SSO(data) {
         return this.request({
             data,
-            suffix: 'http://61.164.207.46:9089/yos/rest/sso/crm'
+            suffix: 'https://crm.meida.com:16691/yos/rest/sso/crm'
         })
     }
     /* 验证码登录 */