App.vue 2.2 KB

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