index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. </template>
  3. <script>
  4. import http from '@/utils/request'
  5. import * as commonuni from '@/utils/commonuni'
  6. const ystabbar = () => {
  7. uni.setTabBarItem({
  8. index: 0,
  9. visible: true
  10. })
  11. uni.setTabBarItem({
  12. index: 1,
  13. visible: true
  14. })
  15. uni.setTabBarItem({
  16. index: 2,
  17. visible: false
  18. })
  19. uni.setTabBarItem({
  20. index: 3,
  21. visible: false
  22. })
  23. }
  24. const djtabbar = () => {
  25. uni.setTabBarItem({
  26. index: 0,
  27. visible: false
  28. })
  29. uni.setTabBarItem({
  30. index: 1,
  31. visible: false
  32. })
  33. uni.setTabBarItem({
  34. index: 2,
  35. visible: true
  36. })
  37. uni.setTabBarItem({
  38. index: 3,
  39. visible: true
  40. })
  41. }
  42. export default {
  43. onLoad(option) {
  44. if (option && (option.code || option.openId)) {
  45. console.log('code', option.code) // name eagle
  46. var code = option.code
  47. var openId = option.openId
  48. var url = openId != undefined ? "app-api/wxLogin/loginOpenId?openId=" + openId :
  49. "app-api/wxLogin/login?code=" + code
  50. http.get(url).then(e => {
  51. uni.setStorage({
  52. key: 'openId',
  53. data: e.openId,
  54. })
  55. // commonuni.setStorage("openId",e.openId)
  56. // 4001 没有该用户 4002未审核 4003审核拒绝
  57. if (e.code == '4001') {
  58. //注册页面
  59. uni.navigateTo({
  60. url: '../login/register'
  61. });
  62. return
  63. }
  64. if (e.code == '4002') {
  65. // 未审核
  66. uni.navigateTo({
  67. url: '../login/registerSuccess'
  68. });
  69. return
  70. }
  71. if (e.code == '4003') {
  72. // 未审核
  73. uni.navigateTo({
  74. url: '../login/registerFail'
  75. });
  76. return
  77. }
  78. uni.setStorage({
  79. key: 'token',
  80. data: e.token,
  81. })
  82. http.get("app-api/wxLogin/userInfo").then(user => {
  83. console.log(user)
  84. uni.setStorage({
  85. key: 'userInfo',
  86. data: user,
  87. })
  88. if(e.roleCode.toString().indexOf('YCAdmin')!= -1 && e.roleCode.toString().indexOf('flyAdmin') != -1){
  89. uni.navigateTo({
  90. url:'/pages/login/multipleRoles'
  91. })
  92. }
  93. if (e.roleCode.toString().indexOf('YCAdmin') != -1) {
  94. uni.switchTab({
  95. url: '../ypczk/djfk/index/djfkIndex'
  96. });
  97. djtabbar()
  98. }
  99. if(e.roleCode.toString().indexOf('flyAdmin') != -1){
  100. uni.switchTab({
  101. url: '../ypczk/index/leaderIndex'
  102. });
  103. ystabbar()
  104. }
  105. else {
  106. uni.navigateTo({
  107. url: '../login/registerFail'
  108. });
  109. }
  110. })
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style>
  117. </style>