pending.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 = JSON.parse(localStorage.getItem('userInfo'))
  83. const SearchMap = new URLSearchParams(location.search)
  84. const fromType = SearchMap.get('fromType')
  85. // 受限redirectTo只能带一个参数
  86. // const from = SearchMap.get('from')
  87. // const type = SearchMap.get('type')
  88. const [from, type, redirectUrl] = fromType.split('_')
  89. console.log('from, type :>> ', from, type);
  90. // jyej
  91. const gaeatoken = SearchMap.get('gaeatoken')
  92. // zlb
  93. const ticket = SearchMap.get('ticket')
  94. const RequestUrl = {
  95. jyej: '/openapi/oauth/jyej/index.php',
  96. zlb: '/openapi/oauth/zlb/checkticket.php',
  97. }
  98. const RequestTicket = {
  99. jyej: { gaeatoken },
  100. zlb: { ticket },
  101. }
  102. const RequestType = {
  103. jyej: {
  104. bind: 'bind',
  105. unbind: 'unbind',
  106. login: 'user2local',
  107. loginback: 'user2local',
  108. }, zlb: {
  109. bind: 'bind',
  110. unbind: 'unbind',
  111. login: 'login',
  112. }
  113. }
  114. switch (type) {
  115. case 'bind': {
  116. _request({
  117. url: RequestUrl[from],
  118. data: {
  119. type: RequestType[from][type],
  120. token: userInfo.token,
  121. ...RequestTicket[from]
  122. }
  123. }).then(response => {
  124. const res = response.data
  125. if (res.code === '1') {
  126. Message.success('绑定成功')
  127. // hrefTo(`${window.location.origin}/#/personal/setting/${userInfo.user_id}`)
  128. hrefTo(atob(redirectUrl))
  129. } else {
  130. confirm(res.msg)
  131. hrefTo(window.location.origin)
  132. }
  133. })
  134. break;
  135. }
  136. case 'unbind': {
  137. console.log('userInfo.token :>> ', userInfo.token);
  138. _request({
  139. url: RequestUrl[from],
  140. data: {
  141. type: RequestType[from][type],
  142. token: userInfo.token,
  143. }
  144. }).then(response => {
  145. const res = response.data
  146. if (res.code === '1') {
  147. Message.success('解绑成功')
  148. localStorage.setItem('userInfo', JSON.stringify(Object.assign(userInfo, {
  149. ext: {
  150. [`ue_${from}_account`]: "",
  151. [`ue_${from}_id`]: "",
  152. [`ue_${from}_nickname`]: "",
  153. }
  154. })))
  155. // hrefTo(`${window.location.origin}/#/personal/setting/${userInfo.user_id}`)
  156. hrefTo(atob(redirectUrl))
  157. } else {
  158. confirm(res.msg)
  159. }
  160. })
  161. break;
  162. }
  163. // 登录
  164. case 'login': {
  165. _request({
  166. url: RequestUrl[from],
  167. data: {
  168. type: RequestType[from][type],
  169. ...RequestTicket[from]
  170. }
  171. }).then(response => {
  172. const res = response.data
  173. if (res.code === '1') {
  174. const userInfo = res.data
  175. localStorage.removeItem('userInfo')
  176. localStorage.setItem('userInfo', JSON.stringify(userInfo))
  177. hrefTo(window.location.origin)
  178. } else {
  179. confirm(res.msg)
  180. hrefTo(window.location.origin)
  181. }
  182. })
  183. break;
  184. }
  185. case 'loginback': {
  186. _request({
  187. url: RequestUrl[from],
  188. data: {
  189. type: RequestType[from][type],
  190. ...RequestTicket[from]
  191. }
  192. }).then(response => {
  193. const res = response.data
  194. if (res.code === '1') {
  195. const userInfo = res.data
  196. localStorage.removeItem('userInfo')
  197. localStorage.setItem('userInfo', JSON.stringify(userInfo))
  198. hrefTo(`${window.location.origin}/manage/`)
  199. } else {
  200. confirm(res.msg)
  201. hrefTo(window.location.origin)
  202. }
  203. })
  204. break;
  205. }
  206. default: {
  207. alert('错误的方式访问页面')
  208. break;
  209. }
  210. }
  211. </script>
  212. </body>
  213. </html>