App.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. },
  10. onLaunch() {
  11. // this.getAllOptions()
  12. // #ifdef MP-WEIXIN
  13. // wxLoginFn()
  14. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  15. console.log('extConfig', extConfig)
  16. uni.setStorageSync('account', extConfig.account)
  17. // #endif
  18. // 开发
  19. if (process.env.NODE_ENV == 'development') {
  20. // uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfMTI1NDM3NDUifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLmIuaHVhbWwuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5iLmh1YW1sLmNvbSIsImp0aSI6IjBfMTI1NDM3NDUiLCJpYXQiOjE1ODA3MTA1NjEsIm5iZiI6MTU4MDcxMDU2MSwiZXhwIjoxNTg5MzUwNTYxLCJ1bmlxdWVJZCI6IjEyNTQzNzQ1Iiwic291cmNlSWQiOjB9.kHrIKm0MUOnX8fCDjOXwd7wQ4jOSEV8gvwR4H4hn_hQ')
  21. uni.setStorageSync('account', '12362')
  22. }
  23. },
  24. onShow() {
  25. // this.isLogin()
  26. },
  27. onHide() {
  28. },
  29. onError(err) {
  30. console.error(err, '错误捕获')
  31. },
  32. methods: {
  33. isLogin() {
  34. let token = uni.getStorageSync('token')
  35. if (!token) {
  36. uni.reLaunch({
  37. url: '/pages/page/login/index'
  38. })
  39. }
  40. }
  41. // ...mapMutations(['setLoginInfo'])
  42. // #ifdef MP-WEIXIN
  43. // wxLogin() {
  44. // uni.login({
  45. // provider: 'weixin',
  46. // success: res => {
  47. // uni.setStorageSync('code', res.code)
  48. // console.log(res.code, 'res.code')
  49. // postWxCode({ code: res.code }).then(subRes => {
  50. // const { openid, session_key, unionid } = subRes.data
  51. // this.setLoginInfo({
  52. // openid,
  53. // session_key,
  54. // unionid
  55. // })
  56. // })
  57. // }
  58. // })
  59. // }
  60. // #endif
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. //没有scss变量方法的,主要引入 这样打包的时候就不会所以的组件都打包进去
  66. @import './static/iconfont/iconfont.css';
  67. @import './static/css/uni2.css';
  68. @import './static/css/base.scss';
  69. @import './static/css/common.scss';
  70. @import './static/css/reset.scss';
  71. page {
  72. height: 100%;
  73. }
  74. </style>