Преглед изворни кода

feat: 登录页二维码改为动态获取最新APP版本下载链接

yusheng пре 9 месеци
родитељ
комит
94e7dd822b
2 измењених фајлова са 25 додато и 16 уклоњено
  1. 8 0
      src/api/login/index.js
  2. 17 16
      src/views/login/index.vue

+ 8 - 0
src/api/login/index.js

@@ -71,3 +71,11 @@ export async function getUserInfo(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+export async function getLatestVersion() {
+  const res = await request.get(`/sys/appupdates/getLatestVersion`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 17 - 16
src/views/login/index.vue

@@ -12,17 +12,15 @@
       :rules="rules"
       class="login-form ele-bg-white"
       @keyup.enter.native="submit"
-    > 
-      <el-popover
-        width="150"
-        trigger="hover">
+    >
+      <el-popover width="150" trigger="hover">
         <div>
-          <img style="width: 100%;" :src="qrcodeUrl" alt="" srcset="">
-          <div style="text-align: center;">下载APP</div>
+          <img style="width: 100%" :src="qrcodeUrl" alt="" srcset="" />
+          <div style="text-align: center">下载APP</div>
         </div>
         <div slot="reference" class="switch-btn"></div>
       </el-popover>
-      
+
       <h4>{{ $t('login.title') }}</h4>
       <el-form-item prop="loginName">
         <el-input
@@ -118,7 +116,7 @@
 <script>
   import I18nIcon from '@/layout/components/i18n-icon.vue';
   import { getToken } from '@/utils/token-util';
-  import { login, getCaptcha } from '@/api/login';
+  import { login, getCaptcha, getLatestVersion } from '@/api/login';
   import xyy from '@/assets/xyy.jpg';
   import { getPathAddress } from '@/api/system/file';
   import { setCurrentUser } from '@/utils/token-util';
@@ -201,13 +199,16 @@
     },
     methods: {
       generateQRCode() {
-        QRCode.toDataURL('http://aiot.zoomwin.com.cn:51008/__UNI__45B3907__20250418095147.apk', {
-          errorCorrectionLevel: 'H',
-          margin: 2,
-          scale: 8,
-        }).then(url => {
-          console.log('qrcodeUrl', url);
-          this.qrcodeUrl = url;
+        getLatestVersion().then((res) => {
+          console.log(res, 'dasdasd');
+          QRCode.toDataURL(res.fileUrl, {
+            errorCorrectionLevel: 'H',
+            margin: 2,
+            scale: 8
+          }).then((url) => {
+            console.log('qrcodeUrl', url);
+            this.qrcodeUrl = url;
+          });
         });
       },
       /* 提交 */
@@ -320,7 +321,7 @@
   }
 
   .switch-btn:hover {
-      background-position: 0 -40px;
+    background-position: 0 -40px;
   }
 
   /* 背景 */