From 6e0dc60c729fa23cb53b8bdbc20e33be6cbebfc2 Mon Sep 17 00:00:00 2001 From: zhoudw <zhoudw@infobird.com> Date: Mon, 10 Jan 2022 16:40:01 +0800 Subject: [PATCH] 通讯 --- src/views/iframe/iframe.vue | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/views/iframe/iframe.vue b/src/views/iframe/iframe.vue index 0aba94b..cd9944b 100644 --- a/src/views/iframe/iframe.vue +++ b/src/views/iframe/iframe.vue @@ -42,7 +42,7 @@ let url = process.env.INTERFACE_SERVER_PATH+process.env.ETS_APP_NEWRECORD_URL; this.live_url = url + "?scenes_id="+this.scenes_id+"&scenes_name="+this.scenes_name+"&client_id="+this.client_id+"&sid="+this.token; console.log(this.live_url); - this.getwsConfig(); + this.loadWxjs(); }, methods:{ ...mapActions({ @@ -71,17 +71,19 @@ });; }, postMessageEvent(){ + let _this = this; window.addEventListener("message", function(e){ var data = e.data; + console.log(data,'收到消息'); switch (data.action) { case 'init': // 初始化 wx.config({ beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 - appId: appId, // 必填,企业微信的corpID - timestamp: timeStamp, // 必填,生成签名的时间戳 - nonceStr: nonceStr, // 必填,生成签名的随机串 - signature: signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法 + appId: _this.corpId, // 必填,企业微信的corpID + timestamp: _this.timeStamp, // 必填,生成签名的时间戳 + nonceStr: _this.nonceStr, // 必填,生成签名的随机串 + signature: _this.signature,// 必填,签名,见 附录-JS-SDK使用权限签名算法 jsApiList: [ 'startRecord', 'stopRecord', @@ -165,14 +167,13 @@ script.type = 'text/javascript'; script.src = wx_js; document.body.appendChild(script); - if(index == 0){ - script.onload=function(){ - _this.jsload = true; - } + script.onload=function(){ + _this.jsload = true; } }else{ _this.jsload = true; } + this.getwsConfig(); } } } -- Gitblit v1.8.0