<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 () {
    document.title = '中德人工智能研究院'
    var oMeta = document.createElement('meta')
    oMeta.content = '中德人工智能研究院(CGAII)，由四维时代与德国人工智能研究中心联合建设，主要研究高精度高自动化三维数字化技术、智能图像三维数字化识别技术、智能机器人及自动驾驶技术等多个方向。'
    oMeta.name = 'description'
    var tMeta = document.createElement('meta')
    tMeta.content = '中德人工智能研究院，中德研究院，三维数字化，人工智能，AR，slam，机械手臂，四维时代，四维看看，matterport，众趣，4DAGE'
    tMeta.name = 'keywords'

    document.getElementsByTagName('head')[0].appendChild(oMeta)
    document.getElementsByTagName('head')[0].appendChild(tMeta)

    this.wxShare()
  }
}
</script>

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