Browse Source

fix: yh238刷新webview页面

ldong 6 months ago
parent
commit
98459937ef
2 changed files with 13 additions and 7 deletions
  1. 7 4
      pages-report/chapterDetail.vue
  2. 6 3
      pages-report/reportDetail.vue

+ 7 - 4
pages-report/chapterDetail.vue

@@ -1,5 +1,5 @@
 <template>
-  <web-view :src="url" @message="handleGetMessage"/>
+    <web-view v-if="url" :src="url" @message="handleGetMessage"/>
 </template>
 
 <script>
@@ -10,11 +10,11 @@ export default {
     return {
       url:'',
       msgObj:{},
-	  options:{}
+	    options:{}
     };
   },
   onLoad(options) {
-	this.options=options
+	  this.options=options
     wx.setVisualEffectOnCapture({visualEffect:'hidden'})
   },
   onShow(){
@@ -32,6 +32,7 @@ export default {
   },
   methods: {
     async init(options){
+	    this.url=''
       if(options.scene){
         const res=await apiGetSceneToParams({scene_key:options.scene})
         if(res.code==200){
@@ -44,7 +45,9 @@ export default {
       let fromPage=options.fromPage||''
       const timestamp=new Date().getTime()
       const token=this.$store.state.user.token
-      this.url=`${h5BaseUrl}/hzyb/report/chapterdetail?chapterId=${chapterId}&userId=${this.userInfo.user_id}&fromPage=${fromPage}&token=${token}&timestamp=${timestamp}#wechat_redirect`
+      setTimeout(()=>{
+		    this.url=`${h5BaseUrl}/hzyb/report/chapterdetail?chapterId=${chapterId}&userId=${this.userInfo.user_id}&fromPage=${fromPage}&token=${token}&timestamp=${timestamp}#wechat_redirect`
+	    },100)
     },
 
     handleGetMessage(e){

+ 6 - 3
pages-report/reportDetail.vue

@@ -1,5 +1,5 @@
 <template>
-    <web-view :src="url" @message="handleGetMessage"></web-view>
+    <web-view v-if="url" :src="url" @message="handleGetMessage"></web-view>
 </template>
 
 <script>
@@ -33,6 +33,7 @@ export default {
     methods: {
         async init(options){
             console.log('options',options);
+			this.url=''
             if(options.scene){
                 const res=await apiGetSceneToParams({scene_key:options.scene})
                 if(res.code==200){
@@ -47,8 +48,10 @@ export default {
             let reportId=options.reportId
             const timestamp=new Date().getTime()
             const token=this.$store.state.user.token
-            this.url=`${h5BaseUrl}/hzyb/report/detail?reportId=${reportId}&userId=${this.userInfo.user_id}&fromPage=${options.fromPage||''}&token=${token}&timestamp=${timestamp}#wechat_redirect`
-        },
+			setTimeout(()=>{
+				this.url=`${h5BaseUrl}/hzyb/report/detail?reportId=${reportId}&userId=${this.userInfo.user_id}&fromPage=${options.fromPage||''}&token=${token}&timestamp=${timestamp}#wechat_redirect`
+			},100)
+		},
 
         handleGetMessage(e){
             const data=e.detail.data[e.detail.data.length-1]