فهرست منبع

Merge branch 'feature_20250331_日报分享' into uat(dev)

zhujindu 6 ماه پیش
والد
کامیت
619984db1a

+ 1 - 0
package.json

@@ -26,6 +26,7 @@
     "vue": "^2.6.11",
     "vue-baidu-map": "^0.21.22",
     "vue-jsonp": "^2.0.0",
+    "vue-qr": "^4.0.9",
     "vue-router": "^3.5.3",
     "vuex": "^3.6.0",
     "watermark-dom": "^2.3.0",

+ 42 - 63
src/components/share.vue

@@ -93,11 +93,14 @@
           <div>长按识别二维码</div>
           <div>查看详情&点评</div>
         </div>
-        <div class="QRcodes" ref="QRcodes">
-          <div class="logo">
-            <img :src="require('@/assets/logo1.png')" width="100%" height="100%" />
-          </div>
-        </div>
+        <vue-qr
+          class="QRcodes"
+          :callback="QRCallback"
+          :text="vueQrText"
+          :dotScale="0.8"
+          :margin="8"
+          :logoSrc="require('@/assets/logo1.png')"
+          :logoMargin="2"></vue-qr>
       </div>
     </div>
     <div
@@ -121,10 +124,11 @@
 </template>
 <script>
 import html2canvas from 'html2canvas';
-import QRCode from 'qrcodejs2';
 import { imgToBase64 } from '@/api/index';
+import VueQr from 'vue-qr';
 export default {
   name: 'share',
+  components: { VueQr },
   props: {
     // 日报数据
     reportTarget: {
@@ -156,37 +160,40 @@ export default {
       retryCount: 0,
       photosData: [],
       zIndex: -1,
+      qrcode: null,
+      vueQrText: '',
     };
   },
   created() {
     this.zIndex = -1;
     this.canvasImageUrl = '';
-  },
-  mounted() {
+    this.vueQrText = 'http://1.npz.cn/2/' + this.reportId;
     this.toastLoading(0, '生成中...', true);
-    // 二维码
-    this.creatQrCode();
-    if (this.urlList.length) {
-      imgToBase64({ urlList: this.urlList }).then((res) => {
-        if (res.data && res.code == 200) {
-          this.photosData = res.data;
-          this.$nextTick(async () => {
-            await this.htmlToCanvas();
-          });
-        } else {
-          this.$toast(res.msg);
-          this.$nextTick(async () => {
-            await this.htmlToCanvas();
-          });
-        }
-      });
-    } else {
-      this.$nextTick(async () => {
-        await this.htmlToCanvas();
-      });
-    }
   },
   methods: {
+    // 二维码生成成功回调
+    QRCallback() {
+      // 二维码
+      if (this.urlList.length) {
+        imgToBase64({ urlList: this.urlList }).then((res) => {
+          if (res.data && res.code == 200) {
+            this.photosData = res.data;
+            this.$nextTick(async () => {
+              await this.htmlToCanvas();
+            });
+          } else {
+            this.$toast(res.msg);
+            this.$nextTick(async () => {
+              await this.htmlToCanvas();
+            });
+          }
+        });
+      } else {
+        this.$nextTick(async () => {
+          await this.htmlToCanvas();
+        });
+      }
+    },
     //异步执行
     imageUrlToBase64(imageUrl) {
       return new Promise((resolve, reject) => {
@@ -289,46 +296,18 @@ export default {
           this.$toast('生成分享图失败,请稍后重试');
         });
     },
-    creatQrCode() {
-      // let proText = 'https://suishenbang.nipponpaint.com.cn';
-      let path = 'http://1.npz.cn/2/' + this.reportId || '';
-      var qrcode = new QRCode(this.$refs.QRcodes, {
-        text: path,
-        colorDark: '#000000',
-        colorLight: 'rgba(255,255,255,0)', // 完全透明背景
-        correctLevel: QRCode.CorrectLevel.H,
-        width: 90, // 固定尺寸保证安卓一致性
-        height: 90,
-        margin: 2,
-        render: 'canvas',
-        onRenderingEnd: () => {
-          const canvas = this.$refs.QRcodes.querySelector('canvas');
-          // 显式设置物理像素尺寸
-          const dpr = window.devicePixelRatio || 1;
-          canvas.width = 200 * dpr;
-          canvas.height = 200 * dpr;
-
-          // 设置CSS显示尺寸保持200x200
-          canvas.style.width = '200px';
-          canvas.style.height = '200px';
-
-          // 优化安卓设备显示
-          canvas.style.imageRendering = 'pixelated';
-          canvas.style.transform = 'translateZ(0)'; // 触发硬件加速
-          canvas.style.backgroundColor = '#fff';
-
-          // 调整画布缩放比例
-          const ctx = canvas.getContext('2d');
-          ctx.scale(dpr, dpr);
-        },
-      });
-    },
     closeShare() {
       this.canvasImageUrl = '';
       this.$emit('setShareImg', false);
       this.$emit('setDailyDetailsBox', true);
     },
   },
+  beforeDestroy() {
+    // 组件销毁时清除实例
+    if (this.qrcode) {
+      this.$refs.qrcode.innerHTML = '';
+    }
+  },
 };
 </script>
 <style lang="scss" scoped>

+ 6 - 0
src/views/week/weekly.vue

@@ -240,6 +240,7 @@ export default {
       type: '-1',
       JZQuota: false,
       YFQuota: false, //应用服务
+      GZdata: false,
     };
   },
   created() {
@@ -279,6 +280,11 @@ export default {
           if (res.data.postType == 'JZ') {
             this.JZQuota = true;
           }
+          if (res.data.postType == 'GZ') {
+            this.GZdata = true;
+          } else {
+            this.GZdata = false;
+          }
           var dayTime = res.data.date;
           this.type = res.data.userType;
           this.timeList = this.parseTimeParagraph(

+ 6 - 0
src/views/week/weeklyApproval.vue

@@ -240,6 +240,7 @@ export default {
       type: '-1',
       JZQuota: false,
       YFQuota: false, //应用服务
+      GZdata: false,
     };
   },
   created() {
@@ -352,6 +353,11 @@ export default {
           if (res.data.postType == 'JZ') {
             this.JZQuota = true;
           }
+          if (res.data.postType == 'GZ') {
+            this.GZdata = true;
+          } else {
+            this.GZdata = false;
+          }
           var dayTime = res.data.date;
           this.type = res.data.userType;
           this.timeList = this.parseTimeParagraph(

+ 6 - 0
src/views/week/weeklyApprovalDetils.vue

@@ -258,6 +258,7 @@ export default {
       ptitle: '',
       JZQuota: false,
       YFQuota: false, //应用服务
+      GZdata: false,
     };
   },
   created() {
@@ -293,6 +294,11 @@ export default {
           if (res.data.postType == 'JZ') {
             this.JZQuota = true;
           }
+          if (res.data.postType == 'GZ') {
+            this.GZdata = true;
+          } else {
+            this.GZdata = false;
+          }
           var dayTime = res.data.date;
           this.type = res.data.userType;
           this.ptitle = res.data.pdeptName + '-' + res.data.ppostName + '-' + res.data.pnickName;

+ 6 - 0
src/views/week/weeklyHistoricalDetils.vue

@@ -272,6 +272,7 @@ export default {
       type: '-1',
       JZQuota: false,
       YFQuota: false, //应用服务
+      GZdata: false,
     };
   },
   created() {
@@ -396,6 +397,11 @@ export default {
           if (res.data.postType == 'JZ') {
             this.JZQuota = true;
           }
+          if (res.data.postType == 'GZ') {
+            this.GZdata = true;
+          } else {
+            this.GZdata = false;
+          }
           var dayTime = res.data.date;
           this.type = res.data.userType;
           this.title =