Commit 1db83d81 authored by Li Mingzhe's avatar Li Mingzhe

feat: test

parent 19f4c54b
......@@ -13,7 +13,7 @@ import {
asyncPlayDragonBoneAnimation,
asyncPlayEffectByUrl,
RandomInt,
httpPost,
http,
dateFormat,
formatSeconds,
jelly
......@@ -277,10 +277,11 @@ cc.Class({
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
courseid: null,
ctor() {
this._imageResList = [];
this._audioResList = [];
this.courseid = '111444';
},
start() {
......@@ -295,11 +296,19 @@ cc.Class({
},
getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'Z_05_nxuan1');
} else {
func(defaultData);
}
http('GET', 'http://staging-teach.ireadabc.com/api/courseware/v1/getdata?courseid='+this.courseid, {}).then((resStr) => {
const res = JSON.parse(resStr)
console.log('res: ', res);
console.log('data: ', JSON.parse(res.data));
func(JSON.parse(res.data));
});
// if (window && window.courseware) {
// window.courseware.getData(func, 'Z_05_nxuan1');
// } else {
// func(defaultData);
// }
},
_imageResList: null,
......@@ -412,6 +421,10 @@ cc.Class({
},
onLoadFinish() {
this.initScrollView();
this.getUserInfo();
this.initListeners();
this._status = {
......@@ -420,11 +433,6 @@ cc.Class({
currentStrokeStageIdx: 0
}
this.updateLetter();
this.initScrollView();
this.getUserInfo();
},
......@@ -1143,10 +1151,14 @@ cc.Class({
finishLabel: null,
startTime: null,
rankLabel: null,
rankData: null,
initScrollView() {
this.rankData = [];
this.receiveData(this.courseid, (rankData) => {
this.rankData = rankData;
});
const rankData = this.receiveData('1');
console.log('rankData: ', rankData);
this.svItemArr = [];
this.topH = 60;
this.rankLineH = 60;
......@@ -1213,7 +1225,7 @@ cc.Class({
setScrollView() {
const rankData = this.receiveData('1');
const rankData = this.rankData;
console.log('rankData: ', rankData);
for (let i = 0; i < rankData.length; i++) {
this.addScrollViewItem(rankData[i], i + 1);
......@@ -1275,7 +1287,7 @@ cc.Class({
date: curTime
}
const rankData = this.receiveData('1');
const rankData = this.rankData;
const isExist = rankData.some((item, i) => {
if (item.id == newData.id) {
if (item.score > newData.score) {
......@@ -1293,28 +1305,43 @@ cc.Class({
return a.score - b.score;
})
const newRankData = []
for( let i = 0; i < rankData.length; i ++) {
if (rankData[i].score) {
newRankData.push(rankData[i]);
}
}
// const newRankData = []
// for( let i = 0; i < rankData.length; i ++) {
// if (rankData[i].score) {
// newRankData.push(rankData[i]);
// }
// }
this.sendData('1', newRankData);
this.sendData(this.courseid, rankData);
this.setScrollView();
cc.find('Canvas/scrollview').active = true;
},
sendData(id, data) {
localStorage.setItem(id, JSON.stringify(data));
// localStorage.setItem(id, JSON.stringify(data));
http('GET', 'http://staging-teach.ireadabc.com/api/dashboard/v1/studyinfo?courseid='+this.courseid, data).then((resStr) => {
const res = JSON.parse(resStr)
console.log('res: ', res);
});
},
receiveData(id) {
receiveData(id, cb) {
http('GET', 'http://staging-teach.ireadabc.com/api/dashboard/v1/studyinfo?courseid='+this.courseid, {}).then((resStr) => {
const res = JSON.parse(resStr)
console.log('res: ', res);
});
let strData = localStorage.getItem(id);
if (!strData) {
strData = '[]'
}
return JSON.parse(strData);
if (cb) {
cb(JSON.parse(strData));
}
},
getLabel() {
const node = new cc.Node();
......
......@@ -33,6 +33,7 @@ cc.Class({
start () {
setTimeout(() => {
cc.director.loadScene('n_xuan1')
console.log('aaa');
}, 1000);
},
......
......@@ -157,15 +157,12 @@ export function formatSeconds(value) {
return result;
}
export async function httpPost(url) {
console.log(' in httpPost ');
url = "http://localhost:1338/" + 'cps' + "/getView/"
const data = {
service: 'service',
method: 'getCoursewareData',
parms: {id:'1'}
}
export async function http(type, url, data) {
console.log(' in http ');
console.log(' type: ', type);
console.log(' url: ', url);
console.log(' data: ', data);
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
......@@ -178,8 +175,8 @@ export async function httpPost(url) {
console.log('xhr: ', xhr);
}
};
xhr.open("POST", url, true);
// xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
xhr.send('service=service&method=getCoursewareData&parms={"id":1}');
xhr.open(type, url, true);
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
xhr.send(data);
});
}
{
"title": "play",
"packageName": "org.cocos2d.demo",
"startScene": "47e552a5-ddf7-471f-8f5b-c13cdfbd30e5",
"startScene": "22b2dba2-ea25-4168-92a5-4a6d94152917",
"excludeScenes": [],
"includeSDKBox": false,
"orientation": {
......
......@@ -4,5 +4,5 @@
"separate_engine": false,
"REMOTE_SERVER_ROOT": "",
"subContext": "",
"startSceneAssetBundle": false
"startSceneAssetBundle": true
}
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