ServiceKQ.vue 3.56 KB
<template>
  <service-basekq :centerNo="centerNo" v-if="showData"></service-basekq>
</template>

<script>
// import ServiceBaseKQ from './ServiceBaseKQ.vue'
import ServiceBasekq from './ServiceBaseKQ.vue'
// import vConsole from 'vconsole'
export default {
  name: 'ServiceKQ',
  data () {
    return {
      centerNo: '',
      showData: false,
      publicName: 'KQ',
      appId: 'wx1305e88d2bc74073',
    }
  },

  mounted () {
    console.log('xst mounted')
    // sessionStorage.setItem('publicName', this.publicName);
    // sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab }));
    // sessionStorage.setItem('prePage', 'Service' + this.publicName);
    // sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU');
    const sUserAgent = window.navigator.userAgent.toLowerCase()
    alert(sUserAgent)
    console.log(sUserAgent)
    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`;
    }

    if (miniprogram) {
      alert('支付宝')
      // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`;
    }
    sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU');
    this.$nextTick(() => {
      this.getUserInfo()
    })
  },
  activated () {
    console.log('KQ activated')
    sessionStorage.setItem('publicName', this.publicName);
    sessionStorage.setItem('prePageQuery', JSON.stringify({ showTab: this.$route.query.showTab }));
    sessionStorage.setItem('prePage', 'Service' + this.publicName);
    const sUserAgent = window.navigator.userAgent.toLowerCase()
    console.log(sUserAgent)
    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=passp&goto=`;
    }

    if (miniprogram) {
      alert('支付宝')
      // window.location.href = `https://puser.zjzwfw.gov.cn/sso/alipay.do?action=ssoLogin&servicecode=passp&goto=`;
    }
    sessionStorage.setItem('unionId', 'oJPmPuLaAx2x2DaRGfCFeYuLWzLU');
    this.$nextTick(() => {
      this.getUserInfo()
    })
  },
  methods: {
    // 获取用户信息
    getUserInfo () {
      let userInfo = sessionStorage.getItem('userInfo');
      let unionId = sessionStorage.getItem('unionId');
      if (userInfo) {
        userInfo = JSON.parse(userInfo)
        this.centerNo = userInfo.centerNo
        this.showData = true;
      } else {
        this.$toast.loading({
          message: '加载中...',
          duration: 0,
          forbidClick: true
        })
        this.yxAxios.get(`${this.proxyUrl}/prod/api/wx/${this.appId}/getUserInfo?unionId=${unionId}`).then((res) => {
          this.$toast.clear()
          if (res.data.code == 200) {
            this.centerNo = res.data.data.centerNo
            this.showData = true
            sessionStorage.setItem('userInfo', JSON.stringify(res.data.data))
          } else {
            console.log('getUserInfo失败')
            this.showData = true;
            // this.$router.push({ name: 'LoginPublic', query: { publicName: this.publicName } })
          }
        })
      }
    },
  },
  components: {
    ServiceBasekq,
    // ServiceBaseKQ
  }
}
</script>