threethousanddream hai 3 semanas
pai
achega
66f6284f72
Modificáronse 3 ficheiros con 16 adicións e 12 borrados
  1. 3 3
      pages/detail/app.vue
  2. 11 7
      pages/detail/bigdata.vue
  3. 2 2
      util/index.js

+ 3 - 3
pages/detail/app.vue

@@ -1,7 +1,7 @@
 <template>
   <div style="height: 100vh">
     <yx-navbar :isBack="true" :title="title"></yx-navbar>
-    <iframe class="iframe" v-if="url" :src="url" frameborder="0"></iframe>
+    <iframe class="iframe" v-if="src" :src="src" frameborder="0"></iframe>
   </div>
 </template>
 <script>
@@ -12,7 +12,7 @@ export default {
   data() {
     return {
       title: '详情',
-      url: '',
+      src: '',
     }
   },
   onLoad(options) {
@@ -20,7 +20,7 @@ export default {
     appDetail({appId: options.id}).then(res => {
       let {createUserId,appName}= res.data
       let token = Cookies.get('congress')
-      this.url = `${window._CONFIG.APP_READY}?path=miniapp&appid=${options.id}&token=${token}#/newbi/auth`
+      this.src = `${window._CONFIG.APP_READY}?path=miniapp&appid=${options.id}&token=${token}#/newbi/auth`
       window.$sensors.track('appPreview', {
         attr1: appName, // 应用名称
         attr2: options.id, // 应用id

+ 11 - 7
pages/detail/bigdata.vue

@@ -1,26 +1,30 @@
 <template>
   <div style="height: 100vh">
     <yx-navbar :isBack="true" :title="title"></yx-navbar>
-    <iframe v-if="url" :src="url" style="width: 100vw;height: 100vh;" frameborder="0"></iframe>
+    <iframe id="iframe" :src="src" style="width: 100vw;height: 100vh;" frameborder="0"></iframe>
   </div>
 </template>
 <script>
 import Cookies from 'js-cookie'
-import {setToken} from "@/util";
 export default {
   data() {
     return {
       title: '详情',
-      url: '',
+      src: window._CONFIG.APP_READY + '#/newbi/h5',
+      id: ''
     }
   },
   onLoad(options) {
     this.title = options.title
-    setToken().then(() => {
+    this.id = options.id
+  },
+  mounted() {
+    let iframe = document.getElementById('iframe')
+    iframe.onload = () => {
       let token = Cookies.get('congress')
-      this.url = `${window._CONFIG.APP_READY}?token=${token}#/newbi/fullscreen/${options.id}`
-    })
-  }
+      iframe.contentWindow.postMessage({token: token, id: this.id}, '*')
+    }
+  },
 }
 </script>
 <style>

+ 2 - 2
util/index.js

@@ -17,11 +17,11 @@ export function setToken() {
     if (!Cookies.get('congress')) {
       window.insideH5ToApp({key: 'userInfo', void: 'getUserInfo'})
       setTimeout(() => {
-        // setToken().then(resolve)
+        setToken().then(resolve)
         resolve()
       }, 50)
     } else {
       resolve()
     }
   })
-}
+}