<script>
import { mapMutations, mapActions, mapGetters } from "vuex";
// 这个导入在小程序环境中是不需要的，因为小程序环境已经有全局的 setTimeout 函数
// import { setTimeout } from "timers";
import { getUser, wxLoginFn } from "@/utils/auth";
export default {
  // 全端，数据共享，还可以解决页面初始化模板访问不到值得问题
  // 有坑 分包里的页面访问不到
  globalData: {},
  onLaunch () {
    // this.getAllOptions()
    // 删除缓存
    if (process.env.NODE_ENV == "production") {
      uni.removeStorageSync("shopUser");
    }
    // #ifdef MP-WEIXIN
    // wxLoginFn()
    // uni.clearStorage()
    const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
    uni.setStorageSync("account", extConfig.account);
    // #endif

    // #ifdef H5
    // H5开发环境无法微信授权，使用固定的用户 shish 2020.4.30
    if (process.env.NODE_ENV == "development") {
      uni.setStorageSync(
        "token",
        "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM0MzEifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLm1hbGwuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5tYWxsLmh1YW1sLmNvbSIsImp0aSI6IjBfMTI1NDM0MzEiLCJpYXQiOjE1ODgyMzAwMjgsIm5iZiI6MTU4ODIzMDAyOCwiZXhwIjoxNTk2ODcwMDI4LCJ1bmlxdWVJZCI6IjEyNTQzNDMxIiwic291cmNlSWQiOjB9.Tmw2h9pucpyctvtB--i0dg-zTcVMIJZ1PtnWTLLwEEo"
      );
      uni.setStorageSync("account", "12358");
    }
    // #endif
  },
  onHide () { },
  onError (err) {
    console.error(err, "错误捕获");
  },
  methods: {
    isLogin () {
      let token = uni.getStorageSync("token");
      if (!token) {
        uni.reLaunch({
          url: "/pages/page/login/index"
        });
      }
    }
  }
};
</script>

<style lang="scss">
//没有scss变量方法的，主要引入 这样打包的时候就不会所有的组件都打包进去
@import "./static/iconfont/iconfont.css";
@import "./static/css/uni2.css";
@import "./static/css/base.scss";
@import "./static/css/common.scss";
@import "./static/css/reset.scss";
page {
  height: 100%;
}
</style>