App.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script>
  2. import storage from '@/utils/storage'
  3. import constant from '@/utils/constant'
  4. import config from './config'
  5. import store from '@/store'
  6. import { getToken } from '@/utils/auth'
  7. import {
  8. getThemeColor
  9. } from '@/api/basics/miniApp.js'
  10. export default {
  11. onLaunch: function() {
  12. this.initApp()
  13. },
  14. methods: {
  15. // 初始化应用
  16. initApp() {
  17. // 初始化应用配置
  18. this.initConfig()
  19. // 检查用户登录状态
  20. //#ifdef H5
  21. this.checkLogin()
  22. //#endif
  23. this.handleGetThemeColor()
  24. },
  25. initConfig() {
  26. this.globalData.config = config
  27. },
  28. checkLogin() {
  29. if (!getToken()) {
  30. this.$tab.reLaunch('/pages/login')
  31. }
  32. },
  33. handleGetThemeColor(){
  34. const accountInfo = uni.getAccountInfoSync()
  35. getThemeColor(accountInfo.miniProgram.appId).then(res=>{
  36. if(res != "" && res != null && res != undefined )
  37. {
  38. this.globalData.config.appInfo.themeColor = res.data
  39. }
  40. })
  41. }
  42. }
  43. }
  44. </script>
  45. <style lang="scss">
  46. @import '@/static/scss/index.scss'
  47. </style>