<script>
import {getToken} from "@/util"

export default {
  onLaunch: function () {
    console.log('App Launch')

  },
  onShow: async function () {
    console.log('App Show')
    this.overRoute()
    // let res = await http.get('/')
    // console.log(res)
  },
  onHide: function () {
    console.log('App Hide')
  },
  methods: {
    overRoute() {
      const token = getToken(); //获取token
      const pages = getCurrentPages(),  //获取页面栈
          page = pages[pages.length - 1];  //当前页面
      //白名单
      const urlList = [
        'pages/login/index'
      ];
      //不在白名单且token不存在的情况跳转登录
      if (!token) {
        uni.reLaunch({
          url: '/pages/login/index'
        })
      }
    }
  }
}
</script>

<style lang="scss">
/*每个页面公共css */
// @import "uview-plus/index.scss";
@import "@/uni_modules/uview-plus/index.scss";
@import "common/demo.scss";

page {
  background-color: #f5f5f5;

  > view.info-wrap {
    width: 680rpx;
    margin: 14rpx auto 0;
  }
}
</style>
