App.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <script>
  2. import { mapMutations, mapActions, mapGetters } from "vuex";
  3. // 这个导入在小程序环境中是不需要的,因为小程序环境已经有全局的 setTimeout 函数
  4. // import { setTimeout } from "timers";
  5. import { getUser, wxLoginFn } from "@/utils/auth";
  6. export default {
  7. // 全端,数据共享,还可以解决页面初始化模板访问不到值得问题
  8. // 有坑 分包里的页面访问不到
  9. globalData: {},
  10. onLaunch () {
  11. // this.getAllOptions()
  12. // 删除缓存
  13. if (process.env.NODE_ENV == "production") {
  14. uni.removeStorageSync("shopUser");
  15. }
  16. // #ifdef MP-WEIXIN
  17. // wxLoginFn()
  18. // uni.clearStorage()
  19. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
  20. uni.setStorageSync("account", extConfig.account);
  21. // #endif
  22. // #ifdef H5
  23. // H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
  24. if (process.env.NODE_ENV == "development") {
  25. uni.setStorageSync(
  26. "token",
  27. "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM0MzEifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLm1hbGwuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5tYWxsLmh1YW1sLmNvbSIsImp0aSI6IjBfMTI1NDM0MzEiLCJpYXQiOjE1ODgyMzAwMjgsIm5iZiI6MTU4ODIzMDAyOCwiZXhwIjoxNTk2ODcwMDI4LCJ1bmlxdWVJZCI6IjEyNTQzNDMxIiwic291cmNlSWQiOjB9.Tmw2h9pucpyctvtB--i0dg-zTcVMIJZ1PtnWTLLwEEo"
  28. );
  29. uni.setStorageSync("account", "12358");
  30. }
  31. // #endif
  32. },
  33. onHide () { },
  34. onError (err) {
  35. console.error(err, "错误捕获");
  36. },
  37. methods: {
  38. isLogin () {
  39. let token = uni.getStorageSync("token");
  40. if (!token) {
  41. uni.reLaunch({
  42. url: "/pages/page/login/index"
  43. });
  44. }
  45. }
  46. }
  47. };
  48. </script>
  49. <style lang="scss">
  50. //没有scss变量方法的,主要引入 这样打包的时候就不会所有的组件都打包进去
  51. @import "./static/iconfont/iconfont.css";
  52. @import "./static/css/uni2.css";
  53. @import "./static/css/base.scss";
  54. @import "./static/css/common.scss";
  55. @import "./static/css/reset.scss";
  56. page {
  57. height: 100%;
  58. }
  59. </style>