<script>
import { useUserStore } from "./stores/user";
import { userOpenApp } from "./api/auth";

const openApp = async () => {
  try {
    const res = await userOpenApp();
    if (res?.points && res.points > 0) {
      uni.showToast({
        title: `每日登录 +${res.points} 积分`,
        icon: "none",
      });
    }
    const userStore = useUserStore();
    await userStore.fetchUserAssets();
  } catch (e) {
    console.error("userOpenApp error", e);
  }
};

export default {
  onLaunch() {
    const userStore = useUserStore();
    userStore.loadFromStorage();
    if (userStore.userInfo.id) {
      openApp();
    }
  },
};
</script>

<style lang="scss">
@import url("common/style/common-style.scss");
wx-swiper .wx-swiper-dot {
  position: relative;
  right: -260rpx;
  bottom: 110rpx;
}
/* tabBar */
.customtabbar {
  display: flex;
  justifycontent: spacearound;
  alignitems: center;
  height: 50px;
  backgroundcolor: #fff;
  bordertop: 1px solid #ccc;
}
.customtabbar .item {
  display: flex;
  flexdirection: column;
  alignitems: center;
}
.customtabbar .item span {
  fontsize: 12px;
  color: #999;
}
.customtabbar .item i {
  width: 10px;
  height: 10px;
}
// .segmented-control__item--text{
// 	color: #fff !important;
// 	border-top: none;
// 	    border-right: none;
// 	    border-bottom: none;
// 	    border-left: none;
// }
</style>
