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

<script>
import '@/assets/style/reset.css'
import '@/assets/style/public.css'
import wx from 'weixin-js-sdk'
import jsonp from 'jsonp'

export default {
  name: 'App',
  data () {
    return {

    }
  },
  methods: {
    wxShare () {
      let url = location.href.split('#')[0]
      jsonp('https://www.4dage.com/wechat/jssdk/share/?uri=' +
  window.escape(url) + '&name=4dageshare', 'success_jsonp', function (err, data) {
        if (err) {
          console.err(err)
        } 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: '掌间遍览115处文物', //  描述
            link: window.location.href, //  分享的URL，必须和当前打开的网页的URL是一样的
            imgUrl: 'http://4d-tjw.oss-cn-shenzhen.aliyuncs.com/images/share.jpg', //  缩略图地址
            success: function () {

            },
            cancel: function () {

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

<style>

</style>
