ServiceKQ.vue
3.37 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
<service-basekq :centerNo="centerNo" v-if="showData" @setWxShare="setWxShare"></service-basekq>
</template>
<script>
// import ServiceBaseKQ from './ServiceBaseKQ.vue'
import ServiceBasekq from './ServiceBaseKQ.vue'
// import vConsole from 'vconsole'
export default {
name: 'ServiceKQ',
data () {
return {
centerNo: '',
showData: false,
publicName: 'KQ',
appId: 'wx1305e88d2bc74073',
}
},
mounted () {
console.log('xst mounted')
sessionStorage.setItem('publicName', this.publicName);
sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab }));
sessionStorage.setItem('prePage', 'Service' + this.publicName);
if (process.env.NODE_ENV === "production") {
let openId = sessionStorage.getItem('openId' + this.publicName);
if (!openId) {
this.$router.push({ name: 'Authorize' + this.publicName })
} else {
this.getUserInfo()
}
} else {
sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU');
this.$nextTick(()=>{
this.getUserInfo()
})
}
},
activated () {
console.log('KQ activated')
sessionStorage.setItem('publicName', this.publicName);
sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab }));
sessionStorage.setItem('prePage', 'Service' + this.publicName);
if (process.env.NODE_ENV === "production"&&this.common.isWeiXin()) {
let openId = sessionStorage.getItem('openId' + this.publicName);
if (!openId) {
this.$router.push({ name: 'Authorize' + this.publicName })
} else {
this.getUserInfo()
}
} else {
sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU');
this.$nextTick(()=>{
this.getUserInfo()
})
}
},
methods: {
setWxShare (tabName) {
// 设置分享
this.$emit('getWxConfig', {
title: '趣研学啦', // 分享标题
desc: '现在世界是孩子的书本,一起学才更好玩!', // 分享描述
link: 'https://payment.myjxt.com/center/#/service_kq?showTab=' + tabName, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: 'https://payment.myjxt.com/share_qxy.png', // 分享图标
})
},
// 获取用户信息
getUserInfo () {
let userInfo = sessionStorage.getItem('userInfo');
let unionId = sessionStorage.getItem('unionId');
if (userInfo) {
userInfo = JSON.parse(userInfo)
this.centerNo = userInfo.centerNo
this.showData = true;
} else {
this.$toast.loading({
message: '加载中...',
duration: 0,
forbidClick: true
})
this.yxAxios.get(`${this.proxyUrl}/prod/api/wx/${this.appId}/getUserInfo?unionId=${unionId}`).then((res) => {
this.$toast.clear()
if (res.data.code == 200) {
this.centerNo = res.data.data.centerNo
this.showData = true
sessionStorage.setItem('userInfo', JSON.stringify(res.data.data))
} else {
console.log('getUserInfo失败')
this.showData = true;
// this.$router.push({ name: 'LoginPublic', query: { publicName: this.publicName } })
}
})
}
},
},
components: {
ServiceBasekq,
// ServiceBaseKQ
}
}
</script>