Просмотр исходного кода

研报版图支持设置移动端字号大小

chenlei 2 месяцев назад
Родитель
Сommit
63294bf175
2 измененных файлов с 52 добавлено и 0 удалено
  1. 25 0
      src/views/smartReport/detail.vue
  2. 27 0
      src/views/smartReport/detailPdf.vue

+ 25 - 0
src/views/smartReport/detail.vue

@@ -250,6 +250,11 @@ export default {
       };
 
       this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
+      if(this.isMobileDevice()) {
+        this.headImgStyle.map(st =>{
+          st.size = st.sizeMobile || st.size;
+        })
+      }
       this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
       this.layoutBaseInfo['研报标题']=this.reportInfo.Title
       this.layoutBaseInfo['研报作者']=this.reportInfo.Author
@@ -278,6 +283,26 @@ export default {
         }
       });
     },
+    /**
+     * 判断是否为移动设备
+     *
+     * @returns 返回布尔值,表示是否为移动设备
+    */
+    isMobileDevice() {
+      const userAgent = navigator.userAgent || navigator.vendor || window.opera;
+      // Windows Phone must come first because its UA also contains "Android"
+      if (/windows phone/i.test(userAgent)) {
+        return true;
+      }
+      if (/android/i.test(userAgent)) {
+        return true;
+      }
+      // iOS detection
+      if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
+        return true;
+      }
+      return false;
+    },
 
     /*内容分割*/
     splitContentHandle() {

+ 27 - 0
src/views/smartReport/detailPdf.vue

@@ -110,6 +110,11 @@ export default {
       };
 
       this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
+      if(this.isMobileDevice()) {
+        this.headImgStyle.map(st =>{
+          st.size = st.sizeMobile || st.size;
+        })
+      }
       this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
       this.layoutBaseInfo['研报标题']=this.reportInfo.Title
       this.layoutBaseInfo['研报作者']=this.reportInfo.Author
@@ -121,6 +126,28 @@ export default {
         this.pageResize()
       })
     },
+
+    /**
+     * 判断是否为移动设备
+     *
+     * @returns 返回布尔值,表示是否为移动设备
+    */
+    isMobileDevice() {
+      const userAgent = navigator.userAgent || navigator.vendor || window.opera;
+      // Windows Phone must come first because its UA also contains "Android"
+      if (/windows phone/i.test(userAgent)) {
+        return true;
+      }
+      if (/android/i.test(userAgent)) {
+        return true;
+      }
+      // iOS detection
+      if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
+        return true;
+      }
+      return false;
+    },
+
     setReportContent(str){
       let ps = str.split('</iframe>')
       let returnStr=''