<template>
  <view class="loading"></view>
</template>

<script setup>
import {} from 'vue';
import { signIn } from '../../utils/signIn';
import testJson from '../../static/json/test.json';
import { getTokenUser } from '../../api/index';
import { getToken } from '../../utils/auth';

onMounted(async () => {
  // await signIn();
  if (!getToken()) await signIn2();
  xma.reLaunch({ url: '/pages/index/index' });
});

// 登录
const signIn2 = () => {
  xma.showLoading({
    title: '加载中',
    mask: true,
  });
  return getTokenUser(testJson).then((res) => {
    const token = res.data.access_token;
    const userInfo = res.data.user_info;
    xma.setStorageSync('Authorization', token);
    xma.setStorageSync('userInfo', userInfo);
    console.log('登录...');
  });
};
</script>

<style lang="scss" scoped></style>
