|
@@ -2,31 +2,32 @@ import { _decorator, Component, Node, sys } from 'cc';
|
|
import { config } from './config';
|
|
import { config } from './config';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
@ccclass('http')
|
|
@ccclass('http')
|
|
-export class http {
|
|
|
|
- public static domain = config.debug ? "https://zcapi.xwrun.com" : "https://zcapi.hainanmlwl.com";
|
|
|
|
|
|
+export class http {
|
|
|
|
+ public static domain = config.debug ? "https://zcapi.xwrun.com" : "https://zcapi.hainanmlwl.com";
|
|
|
|
+ public static static_domain = config.debug ? "https://zcapi.xwrun.com" : "https://zaoca.oss-cn-beijing.aliyuncs.com"
|
|
public static statistics_domain = config.debug ? "http://logads.xwrun.com" : "https://logads.hainanmlwl.com";
|
|
public static statistics_domain = config.debug ? "http://logads.xwrun.com" : "https://logads.hainanmlwl.com";
|
|
|
|
|
|
- static post(url,data,call_back){
|
|
|
|
- var xml = new XMLHttpRequest()
|
|
|
|
- xml.open('POST',http.domain+url)
|
|
|
|
- xml.setRequestHeader('Content-Type','application/json');
|
|
|
|
- xml.send(JSON.stringify(data));
|
|
|
|
- var array:String[] = ['loadstart','abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
|
|
+ static post(url, data, call_back) {
|
|
|
|
+ var xml = new XMLHttpRequest()
|
|
|
|
+ xml.open('POST', http.domain + url)
|
|
|
|
+ xml.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
+ xml.send(JSON.stringify(data));
|
|
|
|
+ var array: String[] = ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'];
|
|
array.forEach(function (eventName) {
|
|
array.forEach(function (eventName) {
|
|
xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
- var str = '\nEvent : ' + eventName;
|
|
|
|
|
|
+ var str = '\nEvent : ' + eventName;
|
|
var lstr = ""
|
|
var lstr = ""
|
|
if (eventName === 'timeout') {
|
|
if (eventName === 'timeout') {
|
|
lstr += '(timeout)';
|
|
lstr += '(timeout)';
|
|
}
|
|
}
|
|
else if (eventName === 'loadend') {
|
|
else if (eventName === 'loadend') {
|
|
lstr += '...loadend!';
|
|
lstr += '...loadend!';
|
|
-
|
|
|
|
- }else if (eventName === 'onerror') {
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ } else if (eventName === 'onerror') {
|
|
|
|
+
|
|
}
|
|
}
|
|
- console.log("str==",str)
|
|
|
|
- console.log("lstr==",lstr)
|
|
|
|
|
|
+ console.log("str==", str)
|
|
|
|
+ console.log("lstr==", lstr)
|
|
};
|
|
};
|
|
});
|
|
});
|
|
|
|
|
|
@@ -35,136 +36,169 @@ export class http {
|
|
if (xml.readyState === 4 && xml.status >= 200) {
|
|
if (xml.readyState === 4 && xml.status >= 200) {
|
|
//label.string = handler(xml.responseText);
|
|
//label.string = handler(xml.responseText);
|
|
// console.log("xml.responseText==",xml.responseText)
|
|
// console.log("xml.responseText==",xml.responseText)
|
|
- call_back(null,xml.responseText);
|
|
|
|
|
|
+ call_back(null, xml.responseText);
|
|
} else if (xml.status === 404) {
|
|
} else if (xml.status === 404) {
|
|
- call_back('404 page not found!',null);
|
|
|
|
- console.log("status ==",'404 page not found!')
|
|
|
|
|
|
+ call_back('404 page not found!', null);
|
|
|
|
+ console.log("status ==", '404 page not found!')
|
|
} else if (xml.readyState === 3) {
|
|
} else if (xml.readyState === 3) {
|
|
- call_back('Request dealing!',null);
|
|
|
|
- console.log("status ==",'Request dealing!')
|
|
|
|
|
|
+ call_back('Request dealing!', null);
|
|
|
|
+ console.log("status ==", 'Request dealing!')
|
|
} else if (xml.readyState === 2) {
|
|
} else if (xml.readyState === 2) {
|
|
- call_back('Request received!',null);
|
|
|
|
|
|
+ call_back('Request received!', null);
|
|
console.log("status ==", 'Request received!')
|
|
console.log("status ==", 'Request received!')
|
|
} else if (xml.readyState === 1) {
|
|
} else if (xml.readyState === 1) {
|
|
- call_back('Server connection established! Request hasn\'t been received',null);
|
|
|
|
|
|
+ call_back('Server connection established! Request hasn\'t been received', null);
|
|
console.log("status ==", 'Server connection established! Request hasn\'t been received')
|
|
console.log("status ==", 'Server connection established! Request hasn\'t been received')
|
|
} else if (xml.readyState === 0) {
|
|
} else if (xml.readyState === 0) {
|
|
- call_back( 'Request hasn\'t been initiated!',null);
|
|
|
|
|
|
+ call_back('Request hasn\'t been initiated!', null);
|
|
console.log("status ==", 'Request hasn\'t been initiated!')
|
|
console.log("status ==", 'Request hasn\'t been initiated!')
|
|
}
|
|
}
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static getGameList(page:number,limit:number=6):string{
|
|
|
|
|
|
+ public static getGameList(page: number, limit: number = 6): string {
|
|
return `/smistatic/levels/${limit}_${page}.json`
|
|
return `/smistatic/levels/${limit}_${page}.json`
|
|
}
|
|
}
|
|
|
|
|
|
- public static get_dyopen_id():string{
|
|
|
|
|
|
+ public static get_dyopen_id(): string {
|
|
return `/note/user/get_dyopen_id`
|
|
return `/note/user/get_dyopen_id`
|
|
}
|
|
}
|
|
|
|
|
|
- public static get_login():string{
|
|
|
|
|
|
+ public static get_login(): string {
|
|
return `/note/user/login`
|
|
return `/note/user/login`
|
|
}
|
|
}
|
|
|
|
|
|
- public static get_sys_config():string{
|
|
|
|
|
|
+ public static get_sys_config(): string {
|
|
return `/smistatic/sys_config.json`
|
|
return `/smistatic/sys_config.json`
|
|
}
|
|
}
|
|
|
|
|
|
- public static get_level_info(id:number):string{
|
|
|
|
|
|
+ public static get_level_info(id: number): string {
|
|
return `/smistatic/level_info/${id}.json`
|
|
return `/smistatic/level_info/${id}.json`
|
|
}
|
|
}
|
|
//场景 scene 0=共用 1 = 场景1 2 = 场景2,
|
|
//场景 scene 0=共用 1 = 场景1 2 = 场景2,
|
|
- public static get_level_resource(id:number,scene:number):string{
|
|
|
|
|
|
+ public static get_level_resource(id: number, scene: number): string {
|
|
return `/smistatic/resource/${id}_${scene}.json`
|
|
return `/smistatic/resource/${id}_${scene}.json`
|
|
}
|
|
}
|
|
|
|
|
|
- public static get_test_user_list():string{
|
|
|
|
|
|
+ public static get_test_user_list(): string {
|
|
return `/smistatic/user_test.json`
|
|
return `/smistatic/user_test.json`
|
|
}
|
|
}
|
|
|
|
|
|
- public static sync_data(){
|
|
|
|
|
|
+ public static sync_data() {
|
|
return `/note/user/sync_data`
|
|
return `/note/user/sync_data`
|
|
}
|
|
}
|
|
|
|
|
|
- public static statistics_ads(){
|
|
|
|
- return `/smadspush`
|
|
|
|
|
|
+ public static statistics_ads() {
|
|
|
|
+ return `/smadspush`
|
|
}
|
|
}
|
|
|
|
|
|
public static user_unlock_number_status() {
|
|
public static user_unlock_number_status() {
|
|
return `/note/user/unlock_number_status`
|
|
return `/note/user/unlock_number_status`
|
|
}
|
|
}
|
|
|
|
|
|
- public static run_get(url,call_back){
|
|
|
|
- var xml = new XMLHttpRequest()
|
|
|
|
- xml.open('GET',http.domain+url)
|
|
|
|
- xml.setRequestHeader('Content-Type','application/json');
|
|
|
|
|
|
+ public static run_get(url, call_back) {
|
|
|
|
+ var xml = new XMLHttpRequest()
|
|
|
|
+ xml.open('GET', http.domain + url)
|
|
|
|
+ xml.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
+ xml.send();
|
|
|
|
+
|
|
|
|
+ var array: String[] = ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
+ array.forEach(function (eventName) {
|
|
|
|
+ xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
|
|
+ // var str = '\nEvent : ' + eventName;
|
|
|
|
+ var lstr = ""
|
|
|
|
+ if (eventName === 'timeout') {
|
|
|
|
+ lstr += '(timeout)';
|
|
|
|
+ }
|
|
|
|
+ else if (eventName === 'loadend') {
|
|
|
|
+ lstr += '...loadend!';
|
|
|
|
+
|
|
|
|
+ } else if (eventName === 'onerror') {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Special event
|
|
|
|
+ xml.onreadystatechange = function () {
|
|
|
|
+ if (xml.readyState === 4 && xml.status >= 200) {
|
|
|
|
+ call_back(null, xml.responseText);
|
|
|
|
+ } else if (xml.status === 404) {
|
|
|
|
+ call_back('404 page not found!', null);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static run_get_static(url, call_back) {
|
|
|
|
+ var xml = new XMLHttpRequest()
|
|
|
|
+ xml.open('GET', http.static_domain + url)
|
|
|
|
+ xml.setRequestHeader('Content-Type', 'application/json');
|
|
xml.send();
|
|
xml.send();
|
|
-
|
|
|
|
- var array:String[] = ['loadstart','abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
- array.forEach(function (eventName) {
|
|
|
|
- xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
|
|
- // var str = '\nEvent : ' + eventName;
|
|
|
|
- var lstr = ""
|
|
|
|
- if (eventName === 'timeout') {
|
|
|
|
- lstr += '(timeout)';
|
|
|
|
- }
|
|
|
|
- else if (eventName === 'loadend') {
|
|
|
|
- lstr += '...loadend!';
|
|
|
|
-
|
|
|
|
- }else if (eventName === 'onerror') {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // Special event
|
|
|
|
- xml.onreadystatechange = function () {
|
|
|
|
- if (xml.readyState === 4 && xml.status >= 200) {
|
|
|
|
- call_back(null,xml.responseText);
|
|
|
|
- } else if (xml.status === 404) {
|
|
|
|
- call_back('404 page not found!',null);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static run_post(url,data,call_back){
|
|
|
|
- var xml = new XMLHttpRequest()
|
|
|
|
- xml.open('POST',http.domain+url)
|
|
|
|
- xml.setRequestHeader('Content-Type','application/json');
|
|
|
|
- xml.setRequestHeader('token',config.TOKEN);
|
|
|
|
|
|
+
|
|
|
|
+ var array: String[] = ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
+ array.forEach(function (eventName) {
|
|
|
|
+ xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
|
|
+ // var str = '\nEvent : ' + eventName;
|
|
|
|
+ var lstr = ""
|
|
|
|
+ if (eventName === 'timeout') {
|
|
|
|
+ lstr += '(timeout)';
|
|
|
|
+ }
|
|
|
|
+ else if (eventName === 'loadend') {
|
|
|
|
+ lstr += '...loadend!';
|
|
|
|
+
|
|
|
|
+ } else if (eventName === 'onerror') {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Special event
|
|
|
|
+ xml.onreadystatechange = function () {
|
|
|
|
+ if (xml.readyState === 4 && xml.status >= 200) {
|
|
|
|
+ call_back(null, xml.responseText);
|
|
|
|
+ } else if (xml.status === 404) {
|
|
|
|
+ call_back('404 page not found!', null);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static run_post(url, data, call_back) {
|
|
|
|
+ var xml = new XMLHttpRequest()
|
|
|
|
+ xml.open('POST', http.domain + url)
|
|
|
|
+ xml.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
+ xml.setRequestHeader('token', config.TOKEN);
|
|
xml.send(JSON.stringify(data));
|
|
xml.send(JSON.stringify(data));
|
|
-
|
|
|
|
- var array:String[] = ['loadstart','abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
- array.forEach(function (eventName) {
|
|
|
|
- xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
|
|
- var str = '\nEvent : ' + eventName;
|
|
|
|
- var lstr = ""
|
|
|
|
- if (eventName === 'timeout') {
|
|
|
|
- lstr += '(timeout)';
|
|
|
|
- }
|
|
|
|
- else if (eventName === 'loadend') {
|
|
|
|
- lstr += '...loadend!';
|
|
|
|
-
|
|
|
|
- }else if (eventName === 'onerror') {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // Special event
|
|
|
|
- xml.onreadystatechange = function () {
|
|
|
|
- if (xml.readyState === 4 && xml.status >= 200) {
|
|
|
|
- call_back(null,xml.responseText);
|
|
|
|
- } else if (xml.status === 404) {
|
|
|
|
- call_back('404 page not found!',null);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static statistics_post(url,data,call_back){
|
|
|
|
- if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME){
|
|
|
|
|
|
+
|
|
|
|
+ var array: String[] = ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
+ array.forEach(function (eventName) {
|
|
|
|
+ xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
|
|
+ var str = '\nEvent : ' + eventName;
|
|
|
|
+ var lstr = ""
|
|
|
|
+ if (eventName === 'timeout') {
|
|
|
|
+ lstr += '(timeout)';
|
|
|
|
+ }
|
|
|
|
+ else if (eventName === 'loadend') {
|
|
|
|
+ lstr += '...loadend!';
|
|
|
|
+
|
|
|
|
+ } else if (eventName === 'onerror') {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Special event
|
|
|
|
+ xml.onreadystatechange = function () {
|
|
|
|
+ if (xml.readyState === 4 && xml.status >= 200) {
|
|
|
|
+ call_back(null, xml.responseText);
|
|
|
|
+ } else if (xml.status === 404) {
|
|
|
|
+ call_back('404 page not found!', null);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static statistics_post(url, data, call_back) {
|
|
|
|
+ if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
|
|
const options = {
|
|
const options = {
|
|
url: http.statistics_domain + url,
|
|
url: http.statistics_domain + url,
|
|
data: data,
|
|
data: data,
|
|
@@ -177,40 +211,40 @@ export class http {
|
|
}
|
|
}
|
|
// console.log('tt_options=',options)
|
|
// console.log('tt_options=',options)
|
|
|
|
|
|
- let task = tt.request({
|
|
|
|
|
|
+ let task = tt.request({
|
|
...options,
|
|
...options,
|
|
success(res) { //请求成功回调
|
|
success(res) { //请求成功回调
|
|
console.log("请求成功", res.data);
|
|
console.log("请求成功", res.data);
|
|
- call_back(null,JSON.stringify(res.data));
|
|
|
|
|
|
+ call_back(null, JSON.stringify(res.data));
|
|
},
|
|
},
|
|
fail(res) {//请求失败回调
|
|
fail(res) {//请求失败回调
|
|
console.log("请求失败", res);
|
|
console.log("请求失败", res);
|
|
- call_back( -1,null);
|
|
|
|
|
|
+ call_back(-1, null);
|
|
},
|
|
},
|
|
- complete(res){ //请求结束回调
|
|
|
|
- console.log("调用接口结束",res.data)
|
|
|
|
|
|
+ complete(res) { //请求结束回调
|
|
|
|
+ console.log("调用接口结束", res.data)
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- var xml = new XMLHttpRequest()
|
|
|
|
- xml.open('POST',http.statistics_domain+url)
|
|
|
|
- xml.setRequestHeader('Content-Type','application/json');
|
|
|
|
- xml.setRequestHeader('token',config.TOKEN);
|
|
|
|
|
|
+ var xml = new XMLHttpRequest()
|
|
|
|
+ xml.open('POST', http.statistics_domain + url)
|
|
|
|
+ xml.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
+ xml.setRequestHeader('token', config.TOKEN);
|
|
xml.send(JSON.stringify(data));
|
|
xml.send(JSON.stringify(data));
|
|
|
|
|
|
- var array:String[] = ['loadstart','abort', 'error', 'load', 'loadend', 'timeout'];
|
|
|
|
|
|
+ var array: String[] = ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'];
|
|
array.forEach(function (eventName) {
|
|
array.forEach(function (eventName) {
|
|
xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
|
|
- var str = '\nEvent : ' + eventName;
|
|
|
|
|
|
+ var str = '\nEvent : ' + eventName;
|
|
var lstr = ""
|
|
var lstr = ""
|
|
if (eventName === 'timeout') {
|
|
if (eventName === 'timeout') {
|
|
lstr += '(timeout)';
|
|
lstr += '(timeout)';
|
|
}
|
|
}
|
|
else if (eventName === 'loadend') {
|
|
else if (eventName === 'loadend') {
|
|
- lstr += '...loadend!';
|
|
|
|
- }else if (eventName === 'onerror') {
|
|
|
|
-
|
|
|
|
|
|
+ lstr += '...loadend!';
|
|
|
|
+ } else if (eventName === 'onerror') {
|
|
|
|
+
|
|
}
|
|
}
|
|
};
|
|
};
|
|
});
|
|
});
|
|
@@ -219,10 +253,10 @@ export class http {
|
|
xml.onreadystatechange = function () {
|
|
xml.onreadystatechange = function () {
|
|
// console.log('xml.readyState=',xml.readyState, 'xml.status=',xml.status, 'xml.responseText=',xml.responseText)
|
|
// console.log('xml.readyState=',xml.readyState, 'xml.status=',xml.status, 'xml.responseText=',xml.responseText)
|
|
if (xml.readyState === 4 && xml.status >= 200) {
|
|
if (xml.readyState === 4 && xml.status >= 200) {
|
|
- call_back(null,xml.responseText);
|
|
|
|
|
|
+ call_back(null, xml.responseText);
|
|
} else if (xml.status === 404) {
|
|
} else if (xml.status === 404) {
|
|
- call_back('404 page not found!',null);
|
|
|
|
- }
|
|
|
|
|
|
+ call_back('404 page not found!', null);
|
|
|
|
+ }
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|