Browse Source

feat: 登录页添加APP下载二维码功能

liujt 9 months ago
parent
commit
86f76a4ed4
3 changed files with 42 additions and 3 deletions
  1. 2 1
      package.json
  2. BIN
      src/assets/qr-code-sprites.png
  3. 40 2
      src/views/login/index.vue

+ 2 - 1
package.json

@@ -35,7 +35,8 @@
     "vuex": "^3.6.2",
     "vuex-persistedstate": "^4.1.0",
     "xgplayer-vue": "^1.1.5",
-    "xlsx": "^0.18.5"
+    "xlsx": "^0.18.5",
+    "qrcode": "^1.5.3"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^5.0.8",

BIN
src/assets/qr-code-sprites.png


+ 40 - 2
src/views/login/index.vue

@@ -12,7 +12,17 @@
       :rules="rules"
       class="login-form ele-bg-white"
       @keyup.enter.native="submit"
-    >
+    > 
+      <el-popover
+        width="150"
+        trigger="hover">
+        <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
@@ -113,6 +123,7 @@
   import { getPathAddress } from '@/api/system/file';
   import { setCurrentUser } from '@/utils/token-util';
   import { factoryareaId } from '@/api/system/user';
+  import QRCode from 'qrcode';
 
   export default {
     // eslint-disable-next-line vue/multi-word-component-names
@@ -142,7 +153,8 @@
         // 验证码base64数据
         captcha: '',
         // 验证码内容, 实际项目去掉
-        text: ''
+        text: '',
+        qrcodeUrl: ''
       };
     },
     computed: {
@@ -179,6 +191,7 @@
     },
     created() {
       this.changeCaptcha();
+      this.generateQRCode();
       if (getToken()) {
         this.goHome();
       } else {
@@ -187,6 +200,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;
+        });
+      },
       /* 提交 */
       submit() {
         this.$refs.form.validate((valid) => {
@@ -285,6 +308,21 @@
 </script>
 
 <style lang="scss" scoped>
+  .switch-btn {
+    background: url(@/assets/qr-code-sprites.png) 0 0 / 40px auto no-repeat;
+    cursor: pointer;
+    height: 40px;
+    left: 8px;
+    position: absolute;
+    top: 8px;
+    width: 40px;
+    z-index: 1;
+  }
+
+  .switch-btn:hover {
+      background-position: 0 -40px;
+  }
+
   /* 背景 */
   .login-wrapper {
     padding: 50px 20px;