<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
import wx from 'weixin-js-sdk'
import jsonp from 'jsonp'

export default {
  name: 'App',
  methods: {
    wxShare () {
      let url = location.href.split('#')[0]
      jsonp('https://www.4dage.com/wechat/jssdk/share/?uri=' +
  window.escape(url) + '&name=四维测试服务号', 'success_jsonp', function (err, data) {
        if (err) {
          console.err(err)
          console.log('出错啦')
        } else {
          wx.config({
            debug: false, // 开启调试模式
            appId: data.appId,
            timestamp: data.timestamp,
            nonceStr: data.nonceStr,
            signature: data.signature,
            jsApiList: ['checkJsApi',
              'onMenuShareTimeline',
              'onMenuShareAppMessage',
              'onMenuShareQQ',
              'onMenuShareWeibo',
              'hideMenuItems',
              'showMenuItems',
              'hideAllNonBaseMenuItem',
              'showAllNonBaseMenuItem',
              'translateVoice',
              'startRecord',
              'stopRecord',
              'onRecordEnd',
              'playVoice',
              'pauseVoice',
              'stopVoice',
              'uploadVoice',
              'downloadVoice']
          })
        }
        wx.ready(function () {
          var shareData = {
            title: '中德人工智能研究院', //  标题
            desc: '中德人工智能研究院', //  描述
            link: window.location.href, //  分享的URL，必须和当前打开的网页的URL是一样的
            imgUrl: 'http://4dscene.4dage.com/cgaii/PC/images/icon/foicon.jpg', //  缩略图地址
            success: function () {

            },
            cancel: function () {

            }
          }
          wx.onMenuShareAppMessage(shareData)
          wx.onMenuShareTimeline(shareData)
          wx.onMenuShareQQ(shareData)
          wx.onMenuShareQZone(shareData)
        })
      })
    }
  },
  mounted () {
    this.wxShare()
  }
}
</script>

<style>
  #app{
    overflow: hidden;
  }
</style>
