ZXCode.vue
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 浙学码页面
<template>
<div class="zx_code">
<iframe class="zx_iframe" v-if="iframeUrl" :src="iframeUrl" frameborder="0"></iframe>
</div>
</template>
<script>
export default {
data() {
return {
StudentDetialInfo: {},
iframeUrl: '',
}
},
mounted() {
this.setIframe()
window.addEventListener('message', (e) => {
if (e.data.type && e.data.type === 'zhexuema') {
console.log(e.data.data.cubeUserId)
this.bindLearnCode(e.data.data.cubeUserId)
}
})
},
destroyed() {
window.removeEventListener('message', (e) => {
if (e.data.type && e.data.type === 'zhexuema') {
console.log(e.data.data.cubeUserId)
this.bindLearnCode(e.data.data.cubeUserId)
}
})
},
methods: {
setIframe() {
let StudentDetialInfo = localStorage.getItem('StudentDetialInfo')
if (!StudentDetialInfo) {
this.$toast('未获取到用户信息,请退出重试')
} else {
StudentDetialInfo = JSON.parse(StudentDetialInfo)
this.StudentDetialInfo = StudentDetialInfo
let appId = '133199'
if (StudentDetialInfo.cubeUserId) {
this.iframeUrl = `https://zcode-images.zjedu.com:9060/QRCode/index.html?appId=${appId}&areaCode=330600&simple=true&cubeUserId=${StudentDetialInfo.cubeUserId}`
} else {
this.iframeUrl = `https://zcode-images.zjedu.com:9060/QRCode/index.html?appId=${appId}&areaCode=330600&simple=true&mobile=${StudentDetialInfo.travelerMobile}&nickName=${StudentDetialInfo.travelerName}&cardNo=${StudentDetialInfo.travelerIdCard}`
}
}
},
// 绑定浙学码
bindLearnCode(cubeUserId) {
let StudentDetialInfo = localStorage.getItem('StudentDetialInfo')
StudentDetialInfo = JSON.parse(StudentDetialInfo)
if (StudentDetialInfo.cubeUserId) return
this.yxAxios.get(`${this.proxyUrl}/user/info/bindLearnCode?travelerId=${this.StudentDetialInfo.id}&cubeUserId=${cubeUserId}`)
},
},
}
</script>
<style lang="scss" scoped>
.zx_code {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 100px 50px;
}
.zx_iframe {
width: 100%;
height: 100%;
}
</style>