浏览代码

Merge branch 'ch/need_pool273' of eta_front/eta_report_front into master

leichen 3 月之前
父节点
当前提交
db451ec402
共有 2 个文件被更改,包括 58 次插入0 次删除
  1. 28 0
      src/views/smartReport/detail.vue
  2. 30 0
      src/views/smartReport/detailPdf.vue

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

@@ -251,6 +251,14 @@ export default {
 
       this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
       this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
+      if(this.isMobileDevice()) {
+        this.headImgStyle.map(st =>{
+          st.size = st.sizeMobile || st.size;
+        })
+        this.endImgStyle.map(st =>{
+          st.size = st.sizeMobile || st.size;
+        })
+      }
       this.layoutBaseInfo['研报标题']=this.reportInfo.Title
       this.layoutBaseInfo['研报作者']=this.reportInfo.Author
       // 已发布已通过的报告才显示发布时间
@@ -278,6 +286,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() {

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

@@ -111,6 +111,14 @@ export default {
 
       this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
       this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
+      if(this.isMobileDevice()) {
+        this.headImgStyle.map(st =>{
+          st.size = st.sizeMobile || st.size;
+        })
+        this.endImgStyle.map(st =>{
+          st.size = st.sizeMobile || st.size;
+        })
+      }
       this.layoutBaseInfo['研报标题']=this.reportInfo.Title
       this.layoutBaseInfo['研报作者']=this.reportInfo.Author
       // 已发布已通过的报告才显示发布时间
@@ -121,6 +129,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=''