Commit fdfd417b authored by 李维's avatar 李维

feat: 添加调试信息

parent afdbe638
No preview for this file type
......@@ -113,8 +113,8 @@ export default class NewClass extends middleLayerBase {
direction: data.direction, // 方向 up 向上 down 向下
ranking: data.ranking
}));
this.callNetworkApiPost(`api/dige/v1/user/score/rank`, {
this.callNetworkApiGet(`api/dige/v1/user/score/rank`, {
token: this.token,
syllabus_id: this.courseItem.course_id,
courseware_id: this.courseItem.id,
......
......@@ -68,10 +68,13 @@ export abstract class middleLayerBase extends cc.Component {
callNetworkApiPost(uri, data, callBack) {
const xhr = new XMLHttpRequest();
const url = `${this.API_BASE}${uri}`;
console.log('========== callNetworkApiPost ==========');
console.log(url);
xhr.open("POST", url, true);
xhr.setRequestHeader('content-type', 'application/json');
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
console.log(xhr.responseText);
callBack(JSON.parse(xhr.responseText));
}
}
......@@ -79,6 +82,7 @@ export abstract class middleLayerBase extends cc.Component {
}
callNetworkApiGet(uri, data, callBack) {
console.log('========== callNetworkApiGet ==========');
let queryStr = '?';
const params = [];
for (const key in data) {
......@@ -90,6 +94,7 @@ export abstract class middleLayerBase extends cc.Component {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
console.log(xhr.responseText);
callBack(xhr.responseText);
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment