index.vue
5.35 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
<div class="big_box">
<div class="banner">
<div class="head_portrait">
<span class="images"></span>
</div>
<div class="ewm">
<img src="http://gxb-file.oss-cn-beijing.aliyuncs.com/Huixuexi/ewmm.png" alt="">
</div>
</div>
</div>
</template>
<style lang="" scoped>
div.big_box{position: relative;}
div.banner{
background: url(http://www.huikeint.com/wp-content/uploads/2019/03/画板-1-3.png) no-repeat center;
background-size:cover;
padding-top:7%;
padding-bottom:172%;
}
.head_portrait{padding: 0 0 0 5%;text-align:left;font-size:.3rem;letter-spacing: .01rem;}
.head_portrait span{color:#fff;}
.head_portrait .images{width:1rem;height:1rem;border-radius: 100%;}
.tea_content{background:#fff;border-radius:.1rem;}
.teacher{margin-top:5rem;position: relative;}
.teacher .teacher_logo{width:1.42rem;margin:auto;position: absolute;left:0;right:0;top:-.8rem;}
.teacher .teacher_logo span{font-weight:600;font-family: "PingFang SC";font-size:.16rem;}
.teacher .teacher_logo img{width:100%;}
.teacher .tea_content{margin:0 .38rem;padding:1rem .37rem .28rem .37rem;font-family: "PingFang SC";font-size:.16rem;text-align: left;line-height: .2rem;letter-spacing: .03rem;font-weight: 600;}
.ewm{margin-top:128%;position: absolute;width:100%;text-align: center;}
.ewm img{width:30%;}
</style>
<script>
import axios from 'axios'
import qs from 'querystring'
export default {
name: "homePage",
components: {},
data() {
return {}
},
methods: {
GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = decodeURI(window.location.search.substr(1)).match(reg);
if (r != null)return unescape(r[2]);
return null;
},
getUserInfo(){
var ourl = window.location.href;
// alert(ourl)
if(ourl.indexOf("fromUser") != -1) {
var ourls = ourl.split("&")[1];
var urls = ourls.split("=")[1];
var tokens = urls;
}else {
var tokens = ourl.split('=')[1]
}
axios({
method:'post',
url:this.$config.baseURL+'getAuthorize',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'token':tokens
}
})
.then(function (res) {
if(res.data.status == 200) {
localStorage.setItem('token', res.data.userinfo.token);
$('.images').append(`<img src=${res.data.userinfo.headimgurl} style="width:1rem;height:1rem;border-radius: 100%;">`)
}
})
.catch(function(error){
})
},
initWx(){
const baseUrl = this.$config.baseURL;
if (/from=[^&$?]{1,}(&|$)/.test(location.search) || /isappinstalled=[^&$?]{1,}(&|$)/.test(location.search)) {
var newSearch = location.search.replace(/from=[^&$?]{1,}(&|$)/, '').replace(/isappinstalled=[^&$?]{1,}(&|$)/, '').replace(/&$|\?$/, '');
var newUrl = location.origin + location.pathname + newSearch + location.hash;
location.replace(newUrl);
}
var ourl = window.location.href
var ourls = ourl.substr(1);
// alert(ourl)
if(ourl.indexOf("fromUser") != -1) {
var oUrls = ourl.split("&")[0];
var urls = oUrls.split("=")[1];
var tokens = urls;
}else {
var tokens = ourls.split('=')[1]
}
// alert(tokens)
let url = location.href.split('#')[0];
var paths = this.$route.path;
$.ajax({
url: 'https://esjelly.com/jsApi',
type: "GET",
data: {
url: url
},
dataType: 'json',
success: function (res) {
wx.config({
debug: false,
appId: res.appid,
timestamp: res.timestamp,
nonceStr: res.nonceStr,
signature: res.signature,
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'checkJsApi']
})
let shareParam = {
title: '慧学习', // 分享标题
link:'https://yjsapp.gaoxiaobang.com/test?page='+paths+'&fromUser='+tokens,
// link:`${baseUrl}test?page=${paths}&fromUser=${tokens}`,
desc: '会学习,免费学,从此以后让你爱上学习。', // 分享描述
type: 'link', // 分享类型
dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
imgUrl:'https://gxbfile-gs.gaoxiaobang.com/Huixuexi/logo.jpg',//分享图标
success: function (res) {console.log('分享成功')},
fail: function (res) {console.log('分享失败')}
};
wx.ready(function () {
wx.onMenuShareTimeline(shareParam)
wx.onMenuShareAppMessage(shareParam);
})
},
err: function (err) {
console.log(err)
}
})
}
},
created() {
this.getUserInfo();
this.initWx();
},
beforeCreate () {
document.querySelector('body').setAttribute('style', 'background-color:#5154f7;')
},
beforeDestroy () {
document.querySelector('body').removeAttribute('style')}
}
</script>