index.vue 5.35 KB
<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>