<template>
  <div id="app" :class="isElder ? 'elder' : ''">
    <router-view @setElder="setElder" />
  </div>
</template>
<script>
// import vConsole from 'vconsole'
export default {
  data() {
    return {
      isElder: false,
    }
  },
  watch: {
    $route(to, from) {
      console.log('zheliban 》》》 ', to, from)
      this.$zwlogPvGlobal({ url: to.meta.pagePath, enterPageTime: new Date() })
      this.$zwlogPvGlobal({
        url: from.meta.pagePath,
        leavePageTime: new Date(),
      })
    },
  },
  mounted() {
    ZWJSBridge.onReady(() => {
      console.log('初始化完成后，执行bridge方法')
    })
    const isElder = localStorage.getItem('isElder')
    if (isElder) {
      this.isElder = true
    } else {
      ZWJSBridge.getUiStyle({})
        .then((result) => {
          console.log(result)
          if (result.uiStyle == 'elder') {
            this.isElder = true
            localStorage.setItem('isElder', 1)
          }
        })
        //浙里办APP 6.11.0 版本以下版本标准模式兼容
        .catch((error) => {
          console.log(error)
        })
    }
    // 健康地址调用
    this.yxAxios.get(`https://ocp.sxsedu.net/szsh/health/check`).then((res) => {
      console.log('健康地址:', JSON.stringify(res.data))
      const bodyElement = document.getElementsByTagName('body')[0]
      bodyElement.append(JSON.stringify(res.data))
    })
  },
  methods: {
    setElder(e) {
      this.isElder = e
    },
  },
}
</script>
<style>
html,
body,
#app {
  height: 100%;
  color: #333333;
  font-size: 0;
}
p {
  margin: 0;
}
</style>
