App.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <script>
  2. import {
  3. getToken
  4. } from '@/utils/auth';
  5. import {
  6. ParseAccessToken
  7. } from '@/api/api';
  8. import {
  9. loginControlIsEffectiveUser
  10. } from '@/api/user.js';
  11. export default {
  12. onLaunch: function(options) {
  13. // console.log(window.location);
  14. },
  15. onShow: function() {
  16. // console.log('App Show')
  17. },
  18. onHide: function() {
  19. // console.log('App Hide')
  20. },
  21. /* 配置页面未找到 */
  22. onPageNotFound: function(options) {
  23. const openShare = 'open/share/exercise';
  24. const _path = window.location.hash;
  25. if (_path.includes(openShare)) {
  26. const share_record_id = options.query.share_record_id;
  27. uni.getStorage({
  28. key: 'AccessToken',
  29. success: function(res) {
  30. ParseAccessToken({
  31. access_token: res.data
  32. }).then(({
  33. is_effective
  34. }) => {
  35. if (is_effective == 'true' && share_record_id) {
  36. uni.navigateTo({
  37. url: '/pages/answer_question/answer/index?share_record_id=' + share_record_id +
  38. '&isScanCode=true'
  39. })
  40. } else {
  41. uni.navigateTo({
  42. url: '/pages/login/index?share_record_id=' + share_record_id
  43. })
  44. }
  45. });
  46. },
  47. fail: function(error) {
  48. uni.navigateTo({
  49. url: '/pages/login/index?share_record_id=' + share_record_id
  50. })
  51. }
  52. })
  53. } else {
  54. uni.getStorage({
  55. key: 'AccessToken',
  56. success: function(res) {
  57. ParseAccessToken({
  58. access_token: res.data
  59. }).then(({
  60. is_effective
  61. }) => {
  62. if (is_effective == 'true') {
  63. uni.navigateTo({
  64. url: options.path,
  65. fail(error) {
  66. uni.redirectTo({
  67. url: "pages/404", // 404 页面的路径
  68. });
  69. }
  70. })
  71. } else {
  72. uni.navigateTo({
  73. url: '/pages/login/index'
  74. })
  75. }
  76. });
  77. },
  78. fail: function(error) {
  79. uni.navigateTo({
  80. url: '/pages/login/index'
  81. })
  82. }
  83. })
  84. }
  85. },
  86. }
  87. </script>
  88. <style>
  89. /*每个页面公共css */
  90. body {
  91. background-color: #f4f2f4;
  92. }
  93. /*去掉浏览器输入框自带小眼睛图标*/
  94. .uni-easyinput__content-input ::-ms-reveal {
  95. display: none;
  96. }
  97. .uni-easyinput__content-input ::-ms-clear {
  98. display: none;
  99. }
  100. .uni-easyinput__content-input ::-o-clear {
  101. display: none;
  102. }
  103. /*图片等比缩放*/
  104. /deep/ img {
  105. width: auto;
  106. height: auto;
  107. max-width: 100%;
  108. max-height: 100%;
  109. }
  110. </style>