App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <script>
  2. import { mapMutations, mapActions, mapGetters } from "vuex";
  3. import { setTimeout } from "timers";
  4. import { getUser, wxLoginFn } from "@/utils/auth";
  5. export default {
  6. // 全端,数据共享,还可以解决页面初始化模板访问不到值得问题
  7. // 有坑 分包里的页面访问不到
  8. globalData: {},
  9. onLaunch () {
  10. // this.getAllOptions()
  11. // 删除缓存
  12. if (process.env.NODE_ENV == "production") {
  13. uni.removeStorageSync("shopUser");
  14. }
  15. // #ifdef MP-WEIXIN
  16. // wxLoginFn()
  17. // uni.clearStorage()
  18. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
  19. uni.setStorageSync("account", extConfig.account);
  20. // #endif
  21. // #ifdef H5
  22. // H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
  23. if (process.env.NODE_ENV == "development") {
  24. uni.setStorageSync(
  25. "token",
  26. "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM0MzEifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLm1hbGwuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5tYWxsLmh1YW1sLmNvbSIsImp0aSI6IjBfMTI1NDM0MzEiLCJpYXQiOjE1ODgyMzAwMjgsIm5iZiI6MTU4ODIzMDAyOCwiZXhwIjoxNTk2ODcwMDI4LCJ1bmlxdWVJZCI6IjEyNTQzNDMxIiwic291cmNlSWQiOjB9.Tmw2h9pucpyctvtB--i0dg-zTcVMIJZ1PtnWTLLwEEo"
  27. );
  28. uni.setStorageSync("account", "12358");
  29. }
  30. // #endif
  31. },
  32. onShow () {
  33. // this.isLogin()
  34. uni.hideTabBar()
  35. },
  36. onHide () { },
  37. onError (err) {
  38. console.error(err, "错误捕获");
  39. },
  40. methods: {
  41. isLogin () {
  42. let token = uni.getStorageSync("token");
  43. if (!token) {
  44. uni.reLaunch({
  45. url: "/pages/page/login/index"
  46. });
  47. }
  48. }
  49. // ...mapMutations(['setLoginInfo'])
  50. // #ifdef MP-WEIXIN
  51. // wxLogin() {
  52. // uni.login({
  53. // provider: 'weixin',
  54. // success: res => {
  55. // uni.setStorageSync('code', res.code)
  56. // console.log(res.code, 'res.code')
  57. // postWxCode({ code: res.code }).then(subRes => {
  58. // const { openid, session_key, unionid } = subRes.data
  59. // this.setLoginInfo({
  60. // openid,
  61. // session_key,
  62. // unionid
  63. // })
  64. // })
  65. // }
  66. // })
  67. // }
  68. // #endif
  69. }
  70. };
  71. </script>
  72. <style lang="scss">
  73. //没有scss变量方法的,主要引入 这样打包的时候就不会所有的组件都打包进去
  74. @import "./static/iconfont/iconfont.css";
  75. @import "./static/css/uni2.css";
  76. @import "./static/css/base.scss";
  77. @import "./static/css/common.scss";
  78. @import "./static/css/reset.scss";
  79. page {
  80. height: 100%;
  81. }
  82. </style>