App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <script>
  2. import config from './config'
  3. import store from '@/store'
  4. import { getToken,getTokens,getSsoAdminToken } from '@/utils/auth'
  5. export default {
  6. onLaunch: function() {
  7. this.initApp()
  8. },
  9. methods: {
  10. // 初始化应用
  11. initApp() {
  12. // 初始化应用配置
  13. this.initConfig()
  14. // 检查用户登录状态
  15. //#ifdef H5
  16. // this.checkLogins()
  17. //#endif
  18. },
  19. initConfig() {
  20. this.globalData.config = config
  21. // if (this.globalData.config.VITE_SSO_LOGIN == true&&!getToken()) {
  22. // this.$tab.reLaunch('/pages/loginSso')
  23. // // getSsoToken();
  24. // };
  25. },
  26. checkLogin() {
  27. if (!getToken()) {
  28. this.$tab.reLaunch('/pages/login')
  29. }
  30. },
  31. checkLogins() {
  32. if (!getTokens()) {
  33. this.$tab.reLaunch('/pages/work/CleanGov/')
  34. // // 非静默授权,第一次有弹框
  35. // this.code = ''
  36. // var callback_url = 'https://tools-m.huaxiazhizao.com/#/pages/work/CleanGov/index'
  37. // // 获取页面url
  38. // var appid = 'wx2cfd24c7380cdc08'
  39. // this.code = this.getUrlCode().code
  40. // // 截取code
  41. // if (this.code == null || this.code === '') {
  42. // // 如果没有code,则去请求
  43. // window.location.href =
  44. // `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent( callback_url )}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  45. // } else {
  46. // // 当code不等于空时,调用后端接口获取用户信息
  47. // this.getUserInfo()
  48. // // 你自己的业务逻辑
  49. // }
  50. }
  51. },
  52. getUrlCode() {
  53. // 截取url中的code方法
  54. var url = location.search
  55. var theRequest = new Object()
  56. if (url.indexOf('?') != -1) {
  57. var str = url.substr(1)
  58. var strs = str.split('&')
  59. for (var i = 0; i < strs.length; i++) {
  60. theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1]
  61. }
  62. }
  63. return theRequest
  64. },
  65. getUserInfo() {
  66. let data = {}
  67. data.code = this.code
  68. data.appid = 'wx2cfd24c7380cdc08'
  69. authorizeLogin(data).then(res => {
  70. uni.setStorageSync('X-Token', res.data.token)
  71. console.log(res.data.token)
  72. }).catch(() => {})
  73. },
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. @import '@/static/scss/index.scss'
  79. uni-checkbox .uni-checkbox-input {
  80. border-radius: 3upx !important;
  81. color: #ffffff !important;
  82. }
  83. uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked {
  84. color: #fff;
  85. border-color: rgb(0, 122, 255);
  86. background: rgb(0, 122, 255);
  87. }
  88. uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked:after {
  89. font-size: 18px;
  90. }
  91. .uni-numbox .uni-numbox__value{
  92. border: none;
  93. }
  94. .uni-fab__circle{
  95. width: 80px !important;
  96. height: 80px !important;
  97. }
  98. .uni-fab__circle--rightBottom{
  99. right: 18px;
  100. bottom: 81px;
  101. right: calc(18px + var(--window-right)) !important;
  102. bottom: calc(81px + var(--window-bottom)) !important;
  103. }
  104. </style>