App.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script>
  2. import { mapMutations, mapActions, mapGetters } from 'vuex'
  3. import { setTimeout } from 'timers'
  4. import { getCheckLogin, 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. let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  15. console.log('extConfig', extConfig)
  16. // #endif
  17. // 开发
  18. uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjFfMTI1MzY2MzAifQ.eyJpc3MiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJhdWQiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJqdGkiOiIxXzEyNTM2NjMwIiwiaWF0IjoxNTc0NDIzMDc4LCJuYmYiOjE1NzQ0MjMwNzgsImV4cCI6MTU3NDQyNjY3OCwidXNlcklkIjoxMjUzNjYzMH0.v_T9NuFRpzuI7GtwuuuNlVg6EylImaCUwqo2A6NRTE4')
  19. uni.setStorageSync('account', '12358')
  20. // 登录
  21. if (this.$constant.source == 'business') {
  22. getCheckLogin().then(res => {
  23. if (res) {
  24. getUser()
  25. }
  26. })
  27. }
  28. },
  29. onShow() {
  30. // this.isLogin()
  31. },
  32. onHide() {
  33. },
  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. // ...mapMutations(['setLoginInfo'])
  47. // #ifdef MP-WEIXIN
  48. // wxLogin() {
  49. // uni.login({
  50. // provider: 'weixin',
  51. // success: res => {
  52. // uni.setStorageSync('code', res.code)
  53. // console.log(res.code, 'res.code')
  54. // postWxCode({ code: res.code }).then(subRes => {
  55. // const { openid, session_key, unionid } = subRes.data
  56. // this.setLoginInfo({
  57. // openid,
  58. // session_key,
  59. // unionid
  60. // })
  61. // })
  62. // }
  63. // })
  64. // }
  65. // #endif
  66. }
  67. }
  68. </script>
  69. <style lang="scss">
  70. //没有scss变量方法的,主要引入 这样打包的时候就不会所以的组件都打包进去
  71. @import './static/iconfont/iconfont.css';
  72. @import './static/css/uni2.css';
  73. @import './static/css/base.scss';
  74. @import './static/css/common.scss';
  75. @import './static/css/reset.scss';
  76. page {
  77. height: 100%;
  78. }
  79. </style>