123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <!DOCTYPE html>
- <html lang="zh-hans">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>跳转中</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- .container {
- width: 100vw;
- height: 100vh;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .loading {
- display: block;
- position: relative;
- width: 6px;
- height: 10px;
- animation: rectangle infinite 1s ease-in-out -0.2s;
- background-color: #409EFF;
- }
- .loading:before,
- .loading:after {
- position: absolute;
- width: 6px;
- height: 10px;
- content: "";
- background-color: #409EFF;
- }
- .loading:before {
- left: -14px;
- animation: rectangle infinite 1s ease-in-out -0.4s;
- }
- .loading:after {
- right: -14px;
- animation: rectangle infinite 1s ease-in-out;
- }
- @keyframes rectangle {
- 0%,
- 80%,
- 100% {
- height: 20px;
- box-shadow: 0 0 #409EFF;
- }
- 40% {
- height: 30px;
- box-shadow: 0 -20px #409EFF;
- }
- }
- </style>
- <link rel="stylesheet" href="./utils/message.css">
- <script src="./utils/message.js"></script>
- <script src="./utils/axios.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="loading"></div>
- </div>
- <script src="./config.js"></script>
- <script>
- const _request = axios.create({
- baseURL: window.GLOBAL_CONFIG.api,
- timeout: 60 * 1000,
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- method: 'post'
- })
- function hrefTo(url) {
- setTimeout(() => {
- location.replace(url)
- }, 1000)
- }
- </script>
- <script>
- const userInfo = JSON.parse(localStorage.getItem('userInfo'))
- const SearchMap = new URLSearchParams(location.search)
- const fromType = SearchMap.get('fromType')
- // 受限redirectTo只能带一个参数
- // const from = SearchMap.get('from')
- // const type = SearchMap.get('type')
- const [from, type, redirectUrl] = fromType.split('_')
- console.log('from, type :>> ', from, type);
- // jyej
- const gaeatoken = SearchMap.get('gaeatoken')
- // zlb
- const ticket = SearchMap.get('ticket')
- const RequestUrl = {
- jyej: '/openapi/oauth/jyej/index.php',
- zlb: '/openapi/oauth/zlb/checkticket.php',
- }
- const RequestTicket = {
- jyej: { gaeatoken },
- zlb: { ticket },
- }
- const RequestType = {
- jyej: {
- bind: 'bind',
- unbind: 'unbind',
- login: 'user2local',
- loginback: 'user2local',
- }, zlb: {
- bind: 'bind',
- unbind: 'unbind',
- login: 'login',
- }
- }
- switch (type) {
- case 'bind': {
- _request({
- url: RequestUrl[from],
- data: {
- type: RequestType[from][type],
- token: userInfo.token,
- ...RequestTicket[from]
- }
- }).then(response => {
- const res = response.data
- if (res.code === '1') {
- Message.success('绑定成功')
- // hrefTo(`${window.location.origin}/#/personal/setting/${userInfo.user_id}`)
- hrefTo(atob(redirectUrl))
- } else {
- confirm(res.msg)
- hrefTo(window.location.origin)
- }
- })
- break;
- }
- case 'unbind': {
- console.log('userInfo.token :>> ', userInfo.token);
- _request({
- url: RequestUrl[from],
- data: {
- type: RequestType[from][type],
- token: userInfo.token,
- }
- }).then(response => {
- const res = response.data
- if (res.code === '1') {
- Message.success('解绑成功')
- localStorage.setItem('userInfo', JSON.stringify(Object.assign(userInfo, {
- ext: {
- [`ue_${from}_account`]: "",
- [`ue_${from}_id`]: "",
- [`ue_${from}_nickname`]: "",
- }
- })))
- // hrefTo(`${window.location.origin}/#/personal/setting/${userInfo.user_id}`)
- hrefTo(atob(redirectUrl))
- } else {
- confirm(res.msg)
- }
- })
- break;
- }
- // 登录
- case 'login': {
- _request({
- url: RequestUrl[from],
- data: {
- type: RequestType[from][type],
- ...RequestTicket[from]
- }
- }).then(response => {
- const res = response.data
- if (res.code === '1') {
- const userInfo = res.data
- localStorage.removeItem('userInfo')
- localStorage.setItem('userInfo', JSON.stringify(userInfo))
- hrefTo(window.location.origin)
- } else {
- confirm(res.msg)
- hrefTo(window.location.origin)
- }
- })
- break;
- }
- case 'loginback': {
- _request({
- url: RequestUrl[from],
- data: {
- type: RequestType[from][type],
- ...RequestTicket[from]
- }
- }).then(response => {
- const res = response.data
- if (res.code === '1') {
- const userInfo = res.data
- localStorage.removeItem('userInfo')
- localStorage.setItem('userInfo', JSON.stringify(userInfo))
- hrefTo(`${window.location.origin}/manage/`)
- } else {
- confirm(res.msg)
- hrefTo(window.location.origin)
- }
- })
- break;
- }
- default: {
- alert('错误的方式访问页面')
- break;
- }
- }
- </script>
- </body>
- </html>
|