index.vue
3.29 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>
<div class="box_top">
<div v-for="(item,index) of homelist" :key="item.id" class="box_img">
<img :src="item.imgUrl" alt="" @click="handclick(index)">
</div>
</div>
</template>
<script>
import list from '@/assets/json/homecenter.json';
export default {
name: 'master',
components: {},
data(){
return {
homelist: []
}
},
methods: {
handclick(index){
this.$router.push({
path: '/master/maintab',
query: {
index: index
}
})
},
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);
if(ourl.indexOf("fromUser") != -1) {
var oUrls = ourl.split("&")[0];
var urls = oUrls.split("=")[1];
var tokens = urls;
}else {
var tokens = ourls.split('=')[1]
}
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:`${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.homelist = list.homecenter.home;
this.initWx()
},
beforeCreate () {
document.querySelector('body').setAttribute('style', 'background-color:#F5F9FC;')
},
beforeDestroy () {
document.querySelector('body').removeAttribute('style')
}
}
</script>
<style lang="" scoped>
h3{font-weight:600;text-align: center;font-size:.3rem;padding:3% 0 5% 0;}
.box_img{text-align:center;}
.box_img img{width:92%;margin-bottom:4%;}
.box_top{padding-top:4%;}
</style>