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

feat: test

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