pending.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <html lang="zh-hans">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>跳转中</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. .container {
  14. width: 100vw;
  15. height: 100vh;
  16. display: flex;
  17. justify-content: center;
  18. align-items: center;
  19. }
  20. .loading {
  21. display: block;
  22. position: relative;
  23. width: 6px;
  24. height: 10px;
  25. animation: rectangle infinite 1s ease-in-out -0.2s;
  26. background-color: #409EFF;
  27. }
  28. .loading:before,
  29. .loading:after {
  30. position: absolute;
  31. width: 6px;
  32. height: 10px;
  33. content: "";
  34. background-color: #409EFF;
  35. }
  36. .loading:before {
  37. left: -14px;
  38. animation: rectangle infinite 1s ease-in-out -0.4s;
  39. }
  40. .loading:after {
  41. right: -14px;
  42. animation: rectangle infinite 1s ease-in-out;
  43. }
  44. @keyframes rectangle {
  45. 0%,
  46. 80%,
  47. 100% {
  48. height: 20px;
  49. box-shadow: 0 0 #409EFF;
  50. }
  51. 40% {
  52. height: 30px;
  53. box-shadow: 0 -20px #409EFF;
  54. }
  55. }
  56. </style>
  57. <link rel="stylesheet" href="./utils/message.css">
  58. <script src="./utils/message.js"></script>
  59. <script src="./utils/axios.min.js"></script>
  60. </head>
  61. <body>
  62. <div class="container">
  63. <div class="loading"></div>
  64. </div>
  65. <script src="./config.js"></script>
  66. <script>
  67. const _request = axios.create({
  68. baseURL: window.GLOBAL_CONFIG.api,
  69. timeout: 60 * 1000,
  70. headers: {
  71. 'Content-Type': 'application/x-www-form-urlencoded',
  72. },
  73. method: 'post'
  74. })
  75. function hrefTo(url) {
  76. setTimeout(() => {
  77. location.replace(url)
  78. }, 1000)
  79. }
  80. </script>
  81. <script>
  82. const userInfo = localStorage.getItem('userInfo')
  83. const SearchMap = new URLSearchParams(location.search)
  84. const from = SearchMap.get('from')
  85. // bind | login
  86. const type = SearchMap.get('type')
  87. const gaeatoken = SearchMap.get('gaeatoken')
  88. switch (type) {
  89. case 'bind': {
  90. _request({
  91. url: `/openapi/oauth/${from}/index.php`,
  92. data: {
  93. type: 'bind',
  94. token: userInfo.token,
  95. gaeatoken
  96. }
  97. }).then(res => {
  98. if (res.code === '1') {
  99. Message.success('绑定成功')
  100. hrefTo(`${window.location.origin}/#/personal/setting/${userInfo.user_id}`)
  101. } else {
  102. confirm(res.msg)
  103. }
  104. })
  105. break;
  106. }
  107. case 'unbind': {
  108. _request({
  109. url: `/openapi/oauth/${from}/index.php`,
  110. data: {
  111. type: 'unbind',
  112. token: userInfo.token,
  113. }
  114. }).then(res => {
  115. if (res.code === '1') {
  116. Message.success('解绑成功')
  117. hrefTo(`${window.location.origin}/#/personal/setting/${userInfo.user_id}`)
  118. } else {
  119. confirm(res.msg)
  120. }
  121. })
  122. break;
  123. }
  124. // 登录
  125. case 'login': {
  126. _request({
  127. url: `/openapi/oauth/${from}/index.php`,
  128. data: {
  129. type: 'user2local',
  130. gaeatoken,
  131. }
  132. }).then(response => {
  133. const res = response.data
  134. if (res.code === '1') {
  135. const userInfo = res.data
  136. localStorage.removeItem('userInfo')
  137. localStorage.setItem('userInfo', JSON.stringify(userInfo))
  138. hrefTo(SearchMap.get('redirect'))
  139. } else {
  140. confirm(res.msg)
  141. }
  142. })
  143. break;
  144. }
  145. case 'loginback': {
  146. _request({
  147. url: `/openapi/oauth/${from}/index.php`,
  148. data: {
  149. type: 'user2local',
  150. gaeatoken,
  151. }
  152. }).then(response => {
  153. const res = response.data
  154. if (res.code === '1') {
  155. const userInfo = res.data
  156. localStorage.removeItem('userInfo')
  157. localStorage.setItem('userInfo', JSON.stringify(userInfo))
  158. hrefTo(`${window.location.origin}/manage/`)
  159. } else {
  160. confirm(res.msg)
  161. }
  162. })
  163. break;
  164. }
  165. default: {
  166. alert('错误的方式访问页面')
  167. break;
  168. }
  169. }
  170. </script>
  171. </body>
  172. </html>