<!--
 * @Descripttion: 
 * @version: 0.0.0
 * @Author: genglw
 * @Date: 2022-01-29 16:40:40
 * @LastEditors: genglw
 * @LastEditTime: 2022-10-20 16:35:42
-->
<template>
  <view :style="vuex_theme">
    <u-toast ref="uToast" />
  </view>
</template>

<script>
import { themeList } from "./common/theme.js";

import { mapActions } from "vuex";
export default {
  // 此处globalData为了演示其作用,不是uView框架的一部分
  globalData: {
    username: "",
  },

  data() {
    return {
      themeList,
    };
  },

  onLaunch(e) {
    let colorObj = this.themeList[this.vuex_appId].value;
    let styles = "";
    for (let i in colorObj) {
      styles += colorObj[i].name + ":" + colorObj[i].value + ";";
    }

    this.$u.vuex("vuex_theme", styles);
    this.$u.vuex("vuex_baseImgUrl", this.themeList[this.vuex_appId].imagePath);
    // console.log('vuex_theme----', this.vuex_theme)

    uni.setTabBarStyle({
      selectedColor: "var(--primary-color)",
    });

    // if (this.vuex_phone && this.vuex_token) {
    //   my.login({
    //     success: (res) => {
    //       this.$store.dispatch(`user/login1`, {
    //         type: "student",
    //         way: "wechat",
    //         jsCode: res.code,
    //         phone: this.vuex_phone,
    //         formType: "3",
    //       });
    //     },
    //   });
    // }
    if (e.query && e.query.id) {
      return;
    }

    try {
      // 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
      let lifeData = uni.getStorageSync("lifeData");
      if (
        !lifeData ||
        JSON.stringify(lifeData) == "{}" ||
        this.vuex_role == ""
      ) {
        uni.$u.route("/pages/common/select-role/select-role");
      }
    } catch (e) {
      console.log(e);
    }
  },

  methods: {
    setTabBar() {
      let tabBar = tabBarList.find(
        (item) => item.themeName == uni.getStorageSync("themeName")
      );
      uni.setTabBarItem({
        index: 0,
        selectedIconPath: tabBar.home,
      });
      uni.setTabBarItem({
        index: 1,
        selectedIconPath: tabBar.task,
      });
      uni.setTabBarItem({
        index: 2,
        selectedIconPath: tabBar.user,
      });
    },
  },
};
</script>

<style lang="scss">
@import "uview-ui/index.scss";
@import "common/demo.scss";
// @import '@/static/common/css/icon.css';

/* #ifdef MP-WEIXIN */
wx-swiper .wx-swiper-dot {
  width: 20rpx;
  height: 10rpx;
  border-radius: 5rpx;
}

wx-swiper .wx-swiper-dot-active {
  background-color: #000;
  width: 30rpx;
  height: 15rpx;
  border-radius: 7.5rpx;
}

::-webkit-scrollbar {
  display: none;
  width: 0 !important;
  height: 0 !important;
  -webkit-appearance: none;
  background: transparent;
}

/* #endif */
</style>