<template>
  <service-basekq :centerNo="centerNo" v-if="centerNo"></service-basekq>
</template>

<script>
import ServiceBasekq from './ServiceBaseKQ.vue'
export default {
  name: 'ServiceKQ',
  data () {
    return {
      centerNo: '',
    }
  },

  mounted () {
    console.log('xst mounted')
    this.checkAuth()

  },
  activated () {
    console.log('KQ activated')
    this.checkAuth()
  },
  methods: {
    checkAuth () {
      let centerNo = this.$route.query.center_no || sessionStorage.getItem('centerNo');
      if (centerNo) {
        alert('获取到centerNo,不跳登录')
        console.log('获取到centerNo,不跳登录')
        this.centerNo = centerNo
        sessionStorage.setItem('centerNo', centerNo);
      } else {
        const sUserAgent = window.navigator.userAgent.toLowerCase()
        const dtdreamweb = sUserAgent.indexOf("dtdreamweb") > -1
        const miniprogram = sUserAgent.indexOf("miniprogram") > -1 && sUserAgent.indexOf("alipay") > -1
        if (dtdreamweb) {
          alert('浙里办')
          window.location.href = `https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=hswsy`;
        }
        else if (miniprogram) {
          alert('支付宝')
          // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`;
        }
        else{
          alert('非浙里办或支付宝渠道访问')
        }
      }
    },

  },
  components: {
    ServiceBasekq
  }
}
</script>
