wudada commited on
Commit
9dc5991
1 Parent(s): 500b611

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +117 -21
index.html CHANGED
@@ -1,23 +1,119 @@
1
  <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://nps.uocms.com" target="_blank">Spaces documentation</a>.
16
-
17
- </p>
18
- <p>
19
- <a href="https://ihoho.tv" target="_blank">to visit ihoho.tv</a>.
20
- </p>
21
- </div>
22
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </html>
 
1
  <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <!--<script src="https://web-9gikcbug35bad3a8-1304825656.tcloudbaseapp.com/sdk/1.3.0/mplogin2.min.js"></script>
7
+ <script src="https://web-9gikcbug35bad3a8-1304825656.tcloudbaseapp.com/sdk/1.3.0/cloud.js"></script>-->
8
+ <title></title>
9
+ </head>
10
+
11
+ <body>
12
+ <script>
13
+ alert("href: "+location.href);
14
+ var GWC = {
15
+ version: '1.1.1',
16
+ urlParams: {},
17
+ appendParams: function(url, params) {
18
+ if (params) {
19
+ var baseWithSearch = url.split('#')[0];
20
+ var hash = url.split('#')[1];
21
+ for (var key in params) {
22
+ var attrValue = params[key];
23
+ if (attrValue !== undefined) {
24
+ var newParam = key + "=" + attrValue;
25
+ if (baseWithSearch.indexOf('?') > 0) {
26
+ var oldParamReg = new RegExp('^' + key + '=[-%.!~*\'\(\)\\w]*', 'g');
27
+ if (oldParamReg.test(baseWithSearch)) {
28
+ baseWithSearch = baseWithSearch.replace(oldParamReg, newParam);
29
+ } else {
30
+ baseWithSearch += "&" + newParam;
31
+ }
32
+ } else {
33
+ baseWithSearch += "?" + newParam;
34
+ }
35
+ }
36
+ }
37
+ if (hash) {
38
+ url = baseWithSearch + '#' + hash;
39
+ } else {
40
+ url = baseWithSearch;
41
+ }
42
+ }
43
+ return url;
44
+ },
45
+ getUrlParams: function() {
46
+ var pairs = location.search.substring(1).split('&');
47
+ for (var i = 0; i < pairs.length; i++) {
48
+ var pos = pairs[i].indexOf('=');
49
+ if (pos === -1) {
50
+ continue;
51
+ }
52
+ GWC.urlParams[pairs[i].substring(0, pos)] = decodeURIComponent(pairs[i].substring(pos + 1));
53
+ }
54
+ },
55
+ doRedirect: function() {
56
+ var code = GWC.urlParams['code'];
57
+ var appId = GWC.urlParams['appid'];
58
+ var scope = GWC.urlParams['scope'] || 'snsapi_base';
59
+ var state = GWC.urlParams['state'];
60
+ var isMp = GWC.urlParams['isMp']; //isMp为true时使用开放平台作授权登录,false为网页扫码登录
61
+ var baseUrl;
62
+ var redirectUri;
63
+ if (!code) {
64
+ baseUrl = "https://open.weixin.qq.com/connect/oauth2/authorize#wechat_redirect";
65
+ if(scope == 'snsapi_login' && !isMp){
66
+ baseUrl = "https://open.weixin.qq.com/connect/qrconnect";
67
+ }
68
+ //第一步,没有拿到code,跳转至微信授权页面获取code
69
+ alert(appId);
70
+ //alert("href: "+location.href);
71
+ var url = document.location.toString();
72
+ var arrUrl = url.split("?");
73
+ //let currentHost = "https://wx-1257268355.cos-website.ap-shanghai.myqcloud.com";//arrUrl[0];
74
+ alert("currentHost: "+location.href);
75
+ redirectUri = GWC.appendParams(baseUrl, {
76
+ 'appid': appId,
77
+ // 'redirect_uri': 'https://app-1257268355.cos-website.ap-shanghai.myqcloud.com',//location.href,
78
+ 'redirect_uri': encodeURIComponent(location.href),
79
+ // 'redirect_uri': 'https://wx-1257268355.cos-website.ap-shanghai.myqcloud.com',
80
+ // 'redirect_uri': encodeURIComponent("http://wx-1257268355.cos-website.ap-shanghai.myqcloud.com/get-weixin-code.html"),
81
+ //'redirect_uri': encodeURIComponent(currentHost),
82
+ 'response_type': 'code',
83
+ 'scope': scope,
84
+ 'state': state,
85
+ });
86
+ } else {
87
+ //第二步,从微信授权页面跳转回来,已经获取到了code,再次跳转到实际所需页面
88
+ alert("p.83-code:"+code);
89
+ redirectUri = GWC.appendParams(GWC.urlParams['redirect_uri2'], {
90
+ 'code': code,
91
+ 'state': state
92
+ });
93
+ }
94
+ alert("p.89-redirectUri:"+redirectUri);
95
+ console.log(redirectUri);
96
+ location.href = redirectUri;
97
+ }
98
+ };
99
+ GWC.getUrlParams();
100
+ GWC.doRedirect();
101
+
102
+ // window.onload = function () {
103
+ // var appId = GWC.urlParams['appid'];
104
+ // var scope = GWC.urlParams['scope'] || 'snsapi_base';
105
+ // window.mplogin2.doLogin({
106
+ // appid: appId, // 必填,公众号appid,将以此 appid 名义进行请求
107
+ // scope: scope, // 必填,登录方式:snsapi_userinfo、snsapi_base// 必填,登录方式:snsapi_userinfo、snsapi_base
108
+ // // noback: true, // 选填,登录完不直接返回业务页面,执行自定义附加操作
109
+ // redirect: GWC.urlParams['redirect_uri2'] // 跳转的页面,默认是当前页面,如果你有自定义登录成功页,可以联动设置
110
+ // }).then(res => {
111
+ // // noback为 true 时,将不会返回业务页面,执行到这里
112
+ // // 此时需要自行控制跳转回业务页面
113
+ // console.log(res)
114
+ // })
115
+ // }
116
+ </script>
117
+ </body>
118
+
119
  </html>