62448482 by zhen

update:更新iframe配置

1 parent da102b08
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
19 <el-button type="primary" @click="open">呼叫</el-button> 19 <el-button type="primary" @click="open">呼叫</el-button>
20 <el-button type="primary" @click="cancelCall">取消呼叫</el-button> 20 <el-button type="primary" @click="cancelCall">取消呼叫</el-button>
21 </p> 21 </p>
22 <iframe 22 <!-- <iframe
23 v-if="isStart" 23 v-if="isStart"
24 ref="srtcIframe" 24 ref="srtcIframe"
25 title="srtcIframe" 25 title="srtcIframe"
26 :src="target" 26 :src="target"
27 frameborder="2" 27 frameborder="2"
28 allow="microphone;camera;midi;encrypted-media;fullscreen;" 28 allow="microphone;camera;midi;encrypted-media;fullscreen;"
29 ></iframe> 29 ></iframe> -->
30 </div> 30 </div>
31 </template> 31 </template>
32 32
...@@ -34,17 +34,18 @@ ...@@ -34,17 +34,18 @@
34 export default { 34 export default {
35 data() { 35 data() {
36 return { 36 return {
37 baseUrl: 'https://pre-web-chery.situdata.com', 37 // baseUrl: 'https://pre-web-chery.situdata.com',
38 baseUrl: 'https://localhost:8081',
38 isStart: false, 39 isStart: false,
39 target: '', 40 target: '',
40 strWindowFeatures: ` 41 strWindowFeatures: `
41 left=2400, 42 left=2800,
42 top=200 43 top=200,
43 height=500, 44 height=500,
44 width=700, 45 width=700,
45 menubar=1, 46 menubar=1,
46 toolbar=1, 47 toolbar=1,
47 fullscreen=1 48 status=1
48 `, 49 `,
49 orderInfo: { 50 orderInfo: {
50 appUserName: '刘臻', 51 appUserName: '刘臻',
...@@ -61,15 +62,15 @@ export default { ...@@ -61,15 +62,15 @@ export default {
61 open() { 62 open() {
62 this.isStart = true 63 this.isStart = true
63 this.target = `${this.baseUrl}/#/srtc-iframe?path="https://localhost:8080"` 64 this.target = `${this.baseUrl}/#/srtc-iframe?path="https://localhost:8080"`
64 this.$nextTick().then(() => { 65 this.srtcIframe = window.open(this.target, 'srtc', this.strWindowFeatures)
65 this.$refs.srtcIframe.onload = () => { 66 this.srtcIframe.focus()
67 setTimeout(() => {
66 this.sendMessage() 68 this.sendMessage()
67 } 69 }, 2000)
68 })
69 }, 70 },
70 sendMessage() { 71 sendMessage() {
71 const { appUserName, appUserPhone, orderId, webUserName } = this.orderInfo 72 const { appUserName, appUserPhone, orderId, webUserName } = this.orderInfo
72 this.$refs.srtcIframe.contentWindow.postMessage( 73 this.srtcIframe.postMessage(
73 { 74 {
74 type: 'startCall', 75 type: 'startCall',
75 data: { 76 data: {
...@@ -83,12 +84,13 @@ export default { ...@@ -83,12 +84,13 @@ export default {
83 ) 84 )
84 }, 85 },
85 cancelCall() { 86 cancelCall() {
86 this.$refs.srtcIframe.contentWindow.postMessage( 87 this.srtcIframe.postMessage(
87 { 88 {
88 type: 'cancelCall' 89 type: 'cancelCall'
89 }, 90 },
90 this.baseUrl 91 this.baseUrl
91 ) 92 )
93 this.srtcIframe.close()
92 }, 94 },
93 receiveMessage(e) { 95 receiveMessage(e) {
94 if (e.origin !== this.baseUrl) { 96 if (e.origin !== this.baseUrl) {
...@@ -100,11 +102,14 @@ export default { ...@@ -100,11 +102,14 @@ export default {
100 switch (type) { 102 switch (type) {
101 case 'appHangUp': 103 case 'appHangUp':
102 this.isStart = false 104 this.isStart = false
105 this.srtcIframe.close()
103 break 106 break
104 case 'cancelCallCB': 107 case 'cancelCallCB':
108 this.srtcIframe.close()
105 this.isStart = false 109 this.isStart = false
106 break 110 break
107 case 'webHangUp': 111 case 'webHangUp':
112 this.srtcIframe.close()
108 this.isStart = false 113 this.isStart = false
109 break 114 break
110 } 115 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!