<script>
import { mapState, mapMutations, mapActions } from 'vuex';
import { GET_USER_INFO, HEALTH_TYPE_STATUS } from 'api/api';
import { showLoading, hideLoading, showToast, showModal } from 'utils/ui';

export default {
  async onLaunch() {
    uni.getSetting({
      success(res) {
        if (!res.authSetting['scope.userLocation']) {
          uni.authorize({
            scope: 'scope.userLocation',
            success() {},
          });
        }
      },
    });

    await this.login();
	
	const startTime = +this.$moment()
		.startOf('year')
		.format('x');
	const endTime = +this.$moment()
		.endOf('day')
		.format('x');
	const params = {
		param: {
			startTime,
			endTime,
			token: this.token
		}
    };
    await this.getUserInfo(params);
    await this.getHealthTypeStatus();
  },

  computed: mapState('user', ['token']),

  methods: {
    ...mapActions('user', ['login', 'getUserInfo', 'getHealthTypeStatus']),
  },
};
</script>

<style lang="scss">
@import 'colorui/main.scss';
@import 'colorui/icon.scss';
@import 'colorui/animation.scss';
@import 'common/style/global';
@import 'common/style/iconfont';
</style>
