Browse Source

向报告详情中的iframe图表传递参数

jwyu 2 years ago
parent
commit
bc136b01c3

+ 1 - 1
.env.development

@@ -3,7 +3,7 @@ VITE_APP_OUTDIR="raiwechat_link_h5"
 
 VITE_APP_CYGX_BASEAPIURL="http://8.136.199.33:8500/api"
 
-VITE_APP_HZYB_BASEAPIURL="http://8.136.199.33:8612/api"
+VITE_APP_HZYB_BASEAPIURL="https://ybpctest.hzinsights.com/api"
 
 VITE_APP_HZSL_BASEAPIURL="http://8.136.199.33:8608/api"
 

+ 1 - 1
.env.test

@@ -3,7 +3,7 @@ VITE_APP_OUTDIR="raiwechat_link_h5"
 
 VITE_APP_CYGX_BASEAPIURL="http://8.136.199.33:8500/api"
 
-VITE_APP_HZYB_BASEAPIURL="http://8.136.199.33:8612/api"
+VITE_APP_HZYB_BASEAPIURL="https://ybpctest.hzinsights.com/api"
 
 VITE_APP_HZSL_BASEAPIURL="http://8.136.199.33:8608/api"
 

+ 2 - 2
src/api/hzyb/http.js

@@ -11,7 +11,7 @@ import CryptoJS from './crypto'
 // 请求数
 let LOADINGCOUNT = 0;
 let LOADING;
-console.log(import.meta.env.VITE_APP_HZYB_BASEAPIURL);
+// console.log(import.meta.env);
 let config = {
   baseURL: import.meta.env.VITE_APP_HZYB_BASEAPIURL,
   timeout: 10*60 * 1000, // Timeout
@@ -62,7 +62,7 @@ _axios.interceptors.response.use(
     }else{
       data=response.data
     }
-    console.log(data);
+    // console.log(data);
     if(![200,403].includes(data.code)){
       setTimeout(() => {
         Toast(data.msg)

+ 2 - 0
src/views/hzyb/report/ChapterDetail.vue

@@ -140,6 +140,7 @@
 import moment from 'moment'
 import 'moment/dist/locale/zh-cn'
 moment.locale('zh-cn')
+import {addTokenToIframe} from '../utils/common'
 
 import {apiChapterDetail,apiChapterTickerValue,apiRddpShareImg,apiReportPPtImgs} from '@/api/hzyb/report'
 import {apiApplyPermission,apiUserInfo,apiSetCollect,apiCancelCollect} from '@/api/hzyb/user'
@@ -386,6 +387,7 @@ export default {
 
     /*内容分割*/
     splitContentHandle(content) {
+        content=addTokenToIframe(content,this.info.report_chapter_item.report_id,this.info.report_chapter_item.report_chapter_id)
         const arr = content.split('</p>');
         this.totalContent = arr.map(_ => _+'</p>');
         this.realContent = this.totalContent.slice(0,this.pageSize)

+ 3 - 1
src/views/hzyb/report/Detail.vue

@@ -64,7 +64,6 @@
                     </div>
                 </div>
             </div>
-
             <div id="report-rich-content" class="rich-content" style="position: relative;" ref="richConBox">
                 <div v-if="info.auth_ok">
                     <ul>
@@ -157,6 +156,7 @@
 import moment from 'moment'
 import 'moment/dist/locale/zh-cn'
 moment.locale('zh-cn')
+import {addTokenToIframe} from '../utils/common'
 
 import {apiReportDetail,apiRddpShareImg,apiReportPPtImgs} from '@/api/hzyb/report'
 import {apiApplyPermission,apiUserInfo,apiSetCollect,apiCancelCollect} from '@/api/hzyb/user'
@@ -167,6 +167,7 @@ import _ from 'lodash';
 import LeaveMessage from '../components/leaveMessage/index.vue'
 import collectIcon from '@/assets/hzyb/collect-icon.png'
 import collectIcons from '@/assets/hzyb/collect-icon-s.png'
+
 export default {
     components:{
         [Popup.name]:Popup,
@@ -430,6 +431,7 @@ export default {
 
         /*内容分割*/
         splitContentHandle(content) {
+            content=addTokenToIframe(content,this.reportId,0)
             const arr = content.split('</p>');
             this.totalContent = arr.map(_ => _+'</p>');
             this.realContent = this.totalContent.slice(0,this.pageSize)

+ 17 - 0
src/views/hzyb/utils/common.js

@@ -0,0 +1,17 @@
+// 公共工具方法
+
+/**
+ * 将报告详情字符串中的iframe加token,reportId参数
+ * @param str 报告详情
+ * @param reportId 
+ * @param chapterId
+ * @returns 
+ */
+export const addTokenToIframe=(str,reportId,chapterId=0)=>{
+    const token=localStorage.getItem('hzyb-token')||''
+    if(import.meta.env.MODE==='product'){
+        return str.replace(/<iframe src="https:\/\/chartlib.hzinsights.com\/chartshow\?/g,`<iframe src="https://chartlib.hzinsights.com/chartshow?token=${token}&reportId=${reportId}&chapterId=${chapterId}&source=ybxcx&`)
+    }else{
+        return str.replace(/<iframe src="https:\/\/charttest.hzinsights.com\/chartshow\?/g,`<iframe src="https://charttest.hzinsights.com/chartshow?token=${token}&reportId=${reportId}&chapterId=${chapterId}&source=ybxcx&`)
+    }
+}