Skip to content

Commit bad3b70

Browse files
author
songwei
committed
修改第三方绑定
1 parent 08d616f commit bad3b70

15 files changed

+975
-235
lines changed

MatchvsDemo_Egret/manifest.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@
1313
],
1414
"game": [
1515
"bin-debug/Game/GameUser.js",
16-
"bin-debug/GamePlayView.js",
16+
"bin-debug/screen/ErrorNote.js",
1717
"bin-debug/GameSceneView.js",
1818
"bin-debug/LoadingUI.js",
1919
"bin-debug/Main.js",
2020
"bin-debug/Platform.js",
2121
"bin-debug/ThemeAdapter.js",
2222
"bin-debug/Game/GameData.js",
2323
"bin-debug/AssetAdapter.js",
24+
"bin-debug/matchvs/ArrayTools.js",
2425
"bin-debug/matchvs/MsEngine.js",
2526
"bin-debug/matchvs/MsEvent.js",
2627
"bin-debug/matchvs/MsResponse.js",
27-
"bin-debug/screen/ErrorNote.js",
28-
"bin-debug/util/Toast.js",
28+
"bin-debug/matchvs/MvsHttpApi.js",
29+
"bin-debug/GamePlayView.js",
30+
"bin-debug/screen/GameResult.js",
2931
"bin-debug/screen/Lobby.js",
3032
"bin-debug/screen/Login.js",
3133
"bin-debug/screen/MatchProperty.js",
@@ -36,7 +38,8 @@
3638
"bin-debug/screen/RoomItem.js",
3739
"bin-debug/screen/RoomListUI.js",
3840
"bin-debug/screen/StartModelUI.js",
41+
"bin-debug/screen/WeChart.js",
3942
"bin-debug/util/MD5.js",
40-
"bin-debug/screen/GameResult.js"
43+
"bin-debug/util/Toast.js"
4144
]
4245
}

MatchvsDemo_Egret/resource/default.thm.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"MatchRoomID": "resource/eui_skins/MatchRoomID.exml",
2525
"GameResult": "resource/eui_skins/GameResult.exml",
2626
"ErrorNote": "resource/screen/ErrorNote.exml",
27-
"ReconnectUI": "resource/screen/ReconnectUI.exml"
27+
"ReconnectUI": "resource/screen/ReconnectUI.exml",
28+
"WeChart": "resource/eui_skins/WeChart.exml"
2829
},
2930
"autoGenerateExmlsList": true,
3031
"exmls": [
@@ -50,6 +51,7 @@
5051
"resource/eui_skins/ToggleSwitchSkin.exml",
5152
"resource/eui_skins/VScrollBarSkin.exml",
5253
"resource/eui_skins/VSliderSkin.exml",
54+
"resource/eui_skins/WeChart.exml",
5355
"resource/screen/ErrorNote.exml",
5456
"resource/screen/ReconnectUI.exml",
5557
"resource/screen/StartModel.exml"

MatchvsDemo_Egret/resource/eui_skins/RoomListUI.exml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<e:Skin class="RoomListUISkin" width="1280" height="720" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" >
33
<w:Config id="165c7fbef78" ></w:Config>
4-
<e:Image width="1280" height="720" x="0" y="0" source="bg_jpg" anchorOffsetX="0" anchorOffsetY="0" fillMode="repeat"/>
4+
<e:Image width="1280" height="720" x="0" y="0" source="bg_jpg" anchorOffsetX="0" anchorOffsetY="0" fillMode="repeat" locked="true"/>
55
<e:Group x="71" y="56">
66
<e:Label id="lab_userID" text="用户ID:" x="957" y="13" size="24" textColor="0x999999" textAlign="left" verticalAlign="middle" width="178"/>
77
<e:Button id="btn_return" label="" x="0" y="9" anchorOffsetY="0" height="32" width="32">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<e:Skin class="WeChartSkin" width="1280" height="720" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing" >
3+
<w:Config id="1680cd7f0de" ></w:Config>
4+
<e:Image width="1280" height="720" x="0" y="0" source="bg_jpg" anchorOffsetX="0" anchorOffsetY="0" fillMode="repeat"/>
5+
<e:Rect width="1280" height="720" x="0" y="0" fillAlpha="0"/>
6+
<e:Label text="MatchvsDemo-Egret" x="440.12" y="51" size="42" fontFamily="Arial"/>
7+
</e:Skin>

MatchvsDemo_Egret/src/GameSceneView.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GameSceneView extends egret.Sprite
3030
mvs.MsResponse.getInstance.addEventListener(mvs.MsEvent.EVENT_ERROR_RSP, this.errorResponses, this);
3131
this.thisContainer = new egret.Sprite();
3232
this.addChild(this.thisContainer);
33-
this.login();
33+
this.wechart();
3434
// this.startModel();
3535
}
3636

@@ -52,6 +52,13 @@ class GameSceneView extends egret.Sprite
5252
var loginview:Login = new Login();
5353
this.thisContainer.addChild(loginview);
5454
}
55+
56+
public wechart(){
57+
this.removeAll();
58+
let w:WeChart = new WeChart();
59+
this.thisContainer.addChild(w);
60+
}
61+
5562
public lobby():void
5663
{
5764
this.removeAll();
+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/*
2+
*
3+
* @author
4+
*
5+
*/
6+
class ArrayTools {
7+
public constructor() {
8+
}
9+
10+
11+
//随机打乱数组
12+
public static RandomSort(list:any):void {
13+
list.sort(function () {
14+
return Math.random() - 0.5;
15+
});
16+
}
17+
18+
//数组排序
19+
public static Sort(list:any):void {
20+
list.sort(function (a, b) {
21+
return a - b
22+
});
23+
}
24+
25+
/**
26+
* UTF16和UTF8转换对照表
27+
* U+00000000 – U+0000007F 0xxxxxxx
28+
* U+00000080 – U+000007FF 110xxxxx 10xxxxxx
29+
* U+00000800 – U+0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
30+
* U+00010000 – U+001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
31+
* U+00200000 – U+03FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
32+
* U+04000000 – U+7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
33+
*/
34+
// 转码表
35+
private static table = [
36+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
37+
'I', 'J', 'K', 'L', 'M', 'N', 'O' ,'P',
38+
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
39+
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
40+
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
41+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
42+
'w', 'x', 'y', 'z', '0', '1', '2', '3',
43+
'4', '5', '6', '7', '8', '9', '+', '/'
44+
];
45+
46+
public static UTF16ToUTF8(str) {
47+
var res = [], len = str.length;
48+
for (var i = 0; i < len; i++) {
49+
var code = str.charCodeAt(i);
50+
if (code > 0x0000 && code <= 0x007F) {
51+
// 单字节,这里并不考虑0x0000,因为它是空字节
52+
// U+00000000 – U+0000007F 0xxxxxxx
53+
res.push(str.charAt(i));
54+
} else if (code >= 0x0080 && code <= 0x07FF) {
55+
// 双字节
56+
// U+00000080 – U+000007FF 110xxxxx 10xxxxxx
57+
// 110xxxxx
58+
var byte1 = 0xC0 | ((code >> 6) & 0x1F);
59+
// 10xxxxxx
60+
var byte2 = 0x80 | (code & 0x3F);
61+
res.push(
62+
String.fromCharCode(byte1),
63+
String.fromCharCode(byte2)
64+
);
65+
} else if (code >= 0x0800 && code <= 0xFFFF) {
66+
// 三字节
67+
// U+00000800 – U+0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
68+
// 1110xxxx
69+
var byte1 = 0xE0 | ((code >> 12) & 0x0F);
70+
// 10xxxxxx
71+
var byte2 = 0x80 | ((code >> 6) & 0x3F);
72+
// 10xxxxxx
73+
var byte3 = 0x80 | (code & 0x3F);
74+
res.push(
75+
String.fromCharCode(byte1),
76+
String.fromCharCode(byte2),
77+
String.fromCharCode(byte3)
78+
);
79+
} else if (code >= 0x00010000 && code <= 0x001FFFFF) {
80+
// 四字节
81+
// U+00010000 – U+001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
82+
} else if (code >= 0x00200000 && code <= 0x03FFFFFF) {
83+
// 五字节
84+
// U+00200000 – U+03FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
85+
} else /** if (code >= 0x04000000 && code <= 0x7FFFFFFF)*/ {
86+
// 六字节
87+
// U+04000000 – U+7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
88+
}
89+
}
90+
return res.join('');
91+
}
92+
93+
public static UTF8ToUTF16(str) {
94+
var res = [], len = str.length;
95+
var i = 0;
96+
for (var i = 0; i < len; i++) {
97+
var code = str.charCodeAt(i);
98+
// 对第一个字节进行判断
99+
if (((code >> 7) & 0xFF) == 0x0) {
100+
// 单字节
101+
// 0xxxxxxx
102+
res.push(str.charAt(i));
103+
} else if (((code >> 5) & 0xFF) == 0x6) {
104+
// 双字节
105+
// 110xxxxx 10xxxxxx
106+
var code2 = str.charCodeAt(++i);
107+
var byte1 = (code & 0x1F) << 6;
108+
var byte2 = code2 & 0x3F;
109+
var utf16 = byte1 | byte2;
110+
res.push(String.fromCharCode(utf16));
111+
} else if (((code >> 4) & 0xFF) == 0xE) {
112+
// 三字节
113+
// 1110xxxx 10xxxxxx 10xxxxxx
114+
var code2 = str.charCodeAt(++i);
115+
var code3 = str.charCodeAt(++i);
116+
var byte1 = (code << 4) | ((code2 >> 2) & 0x0F);
117+
var byte2 = ((code2 & 0x03) << 6) | (code3 & 0x3F);
118+
var utf16 = ((byte1 & 0x00FF) << 8) | byte2
119+
res.push(String.fromCharCode(utf16));
120+
} else if (((code >> 3) & 0xFF) == 0x1E) {
121+
// 四字节
122+
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
123+
} else if (((code >> 2) & 0xFF) == 0x3E) {
124+
// 五字节
125+
// 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
126+
} else /** if (((code >> 1) & 0xFF) == 0x7E)*/ {
127+
// 六字节
128+
// 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
129+
}
130+
}
131+
132+
return res.join('');
133+
}
134+
135+
public static Base64Encode(str) {
136+
if (!str) {
137+
return '';
138+
}
139+
var utf8 = this.UTF16ToUTF8(str); // 转成UTF8
140+
var i = 0; // 遍历索引
141+
var len = utf8.length;
142+
var res = [];
143+
while (i < len) {
144+
var c1 = utf8.charCodeAt(i++) & 0xFF;
145+
res.push(this.table[c1 >> 2]);
146+
// 需要补2个=
147+
if (i == len) {
148+
res.push(this.table[(c1 & 0x3) << 4]);
149+
res.push('==');
150+
break;
151+
}
152+
var c2 = utf8.charCodeAt(i++);
153+
// 需要补1个=
154+
if (i == len) {
155+
res.push(this.table[((c1 & 0x3) << 4) | ((c2 >> 4) & 0x0F)]);
156+
res.push(this.table[(c2 & 0x0F) << 2]);
157+
res.push('=');
158+
break;
159+
}
160+
var c3 = utf8.charCodeAt(i++);
161+
res.push(this.table[((c1 & 0x3) << 4) | ((c2 >> 4) & 0x0F)]);
162+
res.push(this.table[((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6)]);
163+
res.push(this.table[c3 & 0x3F]);
164+
}
165+
166+
return res.join('');
167+
}
168+
169+
public static Base64Decode(str) {
170+
if (!str) {
171+
return '';
172+
}
173+
var len = str.length;
174+
var i = 0;
175+
var res = [];
176+
var code1 = 0;
177+
var code2 = 0;
178+
var code3 = 0;
179+
var code4 = 0;
180+
while (i < len) {
181+
code1 = this.table.indexOf(str.charAt(i++));
182+
code2 = this.table.indexOf(str.charAt(i++));
183+
code3 = this.table.indexOf(str.charAt(i++));
184+
code4 = this.table.indexOf(str.charAt(i++));
185+
186+
let c1 = (code1 << 2) | (code2 >> 4);
187+
res.push(String.fromCharCode(c1));
188+
189+
if (code3 != -1) {
190+
let c2 = ((code2 & 0xF) << 4) | (code3 >> 2);
191+
res.push(String.fromCharCode(c2));
192+
}
193+
if (code4 != -1) {
194+
let c3 = ((code3 & 0x3) << 6) | code4;
195+
res.push(String.fromCharCode(c3));
196+
}
197+
}
198+
return this.UTF8ToUTF16(res.join(''));
199+
}
200+
}

MatchvsDemo_Egret/src/matchvs/MsEngine.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module mvs {
5959
* @param {string} appkey 游戏 appkey
6060
* @param {string} secretkey 游戏 secretkey
6161
*/
62-
public login(userID:number, token:string, gameID:number, appkey:string, secretkey:string):number{
62+
public login(userID:number, token:string, gameID:number, appkey:string):number{
6363
let res = this._engine.login(userID,token,gameID,1,appkey,"eglejjddg");
6464
console.info("[MsEngine login] resCode:",res);
6565
return res;

0 commit comments

Comments
 (0)