<script>
import Cookies from 'js-cookie'
import {setToken} from '@/util'
import {useSensors} from "@/util/sensors";
export default {
  onLaunch: function () {
    useSensors({
      commonProps: {platform_type: 'H5'},
      settings: {},
    });
    setToken().then(() => {
      uni.$u.http.get('/api/blade-token/currentUser').then(res => {
        let {instType} = res.detail
        let userInfo = res
        userInfo = {...userInfo, ...res.detail}
        let isSingle = instType === 1
        userInfo.isSingle = isSingle
        this.$store.commit('setUser', userInfo)
        const Yxtoken = Cookies.get('congress')
        const redirect = window.location.href;
        if (Yxtoken) {
          uni.redirectTo({url: isSingle ? '/pages/home/me' : '/pages/home/home'});
        } else {
          // 跳转到iam 用户端登陆
          window.location.href = `${window._CONFIG.VUE_APP_BASE_URLS}/account/#/login?redirect=${redirect}`;
        }
      })
    })
  },
  onShow: function () {

  },
  onHide: function () {

  }
}
</script>

<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/uview-ui/index.scss";
@import "common/demo.scss";
@import "common/tool.css";
@import "common/home.scss";
page {
  background-color: #f6f6f6;
}
.iframe {
  width: 100%;
  height: calc(100% - 176rpx);
}
.u-picker {
  .u-picker__view__column__item {
    font-weight: 500 !important;
  }
}
</style>
