import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './styles/index.scss'; // global css

import setWechatTitle from './utils/setWechatTitle'

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  console.log(localStorage.getItem("token"))
  if(!localStorage.getItem("token")){
    localStorage.setItem("token","oZXSFtw8JcLyFIdtKc6TvkJm4crA")
    next()
    // // 这个redirectUrl用 当前页路径
    // let redirectUrl = window.location.href
    // redirectUrl = encodeURIComponent(redirectUrl)
    // console.log(redirectUrl)
    // const appid='wx0201b63e761568b8'
    // window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`
  }else{
    next()
  }
})

router.afterEach((transition) => {
  setWechatTitle(transition.meta.title)
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
