-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.js
170 lines (165 loc) · 6.5 KB
/
export.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
* Created by Administrator on 2016/8/19 0019.
*/
//TODO: pop change player ID
(function() {
var input;
ChangeIDLayer = cc.Layer.extend({
jsBind: {
block:{_layout:[[1,1],[0.5,0.5],[0,0],true] },
_event: {
},
back: {
_layout: [[0, 0.4], [0.5, 0.5], [0, 0]],
inputimg:{
input:{
_run:function() {
input = this;
},
_listener:function(sender,eType) {
switch (eType) {
case ccui.TextField.EVENT_DETACH_WITH_IME:
//SendChatMsg(false);
break;
}
}
}
},
send_btn:{
_click:function(btn,eT){
//change id
var id = parseInt(input.string)
if(id){
jsclient.data.pinfo.uid = id;
sendEvent("changeId");
jsclient.changeidui.removeFromParent(true);
jsclient.changeidui = null;
}
}
},
close:{
_click:function(btn,eT){
jsclient.changeidui.removeFromParent(true);
jsclient.changeidui = null;
}
}
}
},
ctor: function () {
this._super();
var changeidui = ccs.load("res/ChangeIdLayer.json");
ConnectUI2Logic(changeidui.node, this.jsBind);
this.addChild(changeidui.node);
jsclient.changeidui = this;
return true;
}
});
})();
//TODO: pop export data by id
(function() {
var playerId;
var homeId;
function printfLogToFile(now,logid,owner,hid,ip) {
jsclient.block();
var xhr = cc.loader.getXMLHttpRequest();
var playUrl="http://"+ip+":800/playlog/"+now.substr(0,10)+"/"+owner+"_"+hid+".json";
cc.log(playUrl);
xhr.open("GET", playUrl);
xhr.onreadystatechange = function () {
jsclient.unblock();
if (xhr.readyState == 4 && xhr.status == 200) {
// cc.log(JSON.parse(xhr.responseText));
jsb.fileUtils.writeStringToFile(xhr.responseText,
jsb.fileUtils.getWritablePath()+ owner + "_" + hid + '.json');
jsclient.showMsg("写入成功");
}
}
xhr.onerror = function (event) {jsclient.unblock(); }
xhr.send();
}
ExportDataLayer = cc.Layer.extend({
jsBind: {
block:{_layout:[[1,1],[0.5,0.5],[0,0],true] },
_event: {
},
back: {
_layout: [[0, 0.4], [0.5, 0.5], [0, 0]],
inputimg:{
input:{
_run:function() {
homeId = this;
},
_listener:function(sender,eType) {
switch (eType) {
case ccui.TextField.EVENT_DETACH_WITH_IME:
break;
}
}
}
},
player:{
input:{
_run:function() {
playerId = this;
},
_listener:function(sender,eType) {
switch (eType) {
case ccui.TextField.EVENT_DETACH_WITH_IME:
break;
}
}
}
},
send_btn:{
_click:function(btn,eT){
var pId = parseInt(playerId.string);
var hId = parseInt(homeId.string);
// hId = parseInt(169730);
// pId = parseInt(102639);
cc.log("==============="+pId+":"+hId);
if(pId && hId){
var logs = [];
jsclient.block();
jsclient.gamenet.request("pkplayer.handler.getSymjLog",{uid:pId},function(rtn){
if(rtn.result == 0) {
jsclient.data.playLog=rtn.playLog;
jsclient.data.pinfo.uid = pId;
logs = JSON.parse(JSON.stringify(rtn.playLog["logs"]));
if(logs.length > 0){
for(var i = 0;i < logs.length;i++){
if(parseInt(logs[i].tableid) == hId){
printfLogToFile(logs[i].now,logs[i].logid,logs[i].owner,hId,logs[i].ip);
}
}
}
else {
jsclient.showMsg("查询失败");
jsclient.unblock();
}
}
else {
jsclient.showMsg("查询失败");
jsclient.unblock();
}
});
}
}
},
close:{
_click:function(btn,eT){
jsclient.exportdataui.removeFromParent(true);
jsclient.exportdataui = null;
}
}
}
},
ctor: function () {
this._super();
var exportdataui = ccs.load("res/ExportDataLayer.json");
ConnectUI2Logic(exportdataui.node, this.jsBind);
this.addChild(exportdataui.node);
jsclient.exportdataui = this;
return true;
}
});
})();