Commit 040a0b77 authored by liujiangnan's avatar liujiangnan

feat: 上送星星到后台

parent f5085024
...@@ -162,7 +162,18 @@ cc.Class({ ...@@ -162,7 +162,18 @@ cc.Class({
}, },
addStar(count, animationFlag) { addStar(count, animationFlag) {
// TODO 添加星星的动画并且保存星星到后台
if(animationFlag){
// TODO 添加星星的动画
}
this.callNetworkApiPost(this.baseApiUrl, `v1/terminal/star/save`, {
syllabus_id: this.courseItem.course_id,
courseware_id: this.courseItem.id,
engine_code: this.engineCode,
template_name: this.courseItem.template_name,
stars: count,
})
}, },
preloadAll() { preloadAll() {
...@@ -622,16 +633,19 @@ cc.Class({ ...@@ -622,16 +633,19 @@ cc.Class({
} }
window.courseware.sendAnswer = (answerObj) => { window.courseware.sendAnswer = (answerObj) => {
this.log("===成功调用sendAnswer===" + JSON.stringify(answerObj)); this.log("===成功调用sendAnswer===" + JSON.stringify(answerObj));
this.callNetworkApiPost(`https://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/saveanswer`, answerObj, (data) => { this.addStar(3, true); // 上报成绩则获得三颗星星并展示动画
this.callNetworkApiPost(this.baseApiUrl, `v1/terminal/save/answer`, {
syllabus_id: this.courseItem.course_id,
courseware_id: this.courseItem.id,
engine_code: this.engineCode,
name: this.name,
template_name: this.courseItem.template_name,
result: JSON.stringify(answerObj),
}, (data) => {
answerObj.callback && answerObj.callback(JSON.stringify(data.row)); answerObj.callback && answerObj.callback(JSON.stringify(data.row));
}); });
} }
window.courseware.getAnswer = (queryObj, callback) => { window.courseware.addStar = this.addStar;
this.log("===成功调用getAnswer===" + JSON.stringify(queryObj));
this.callNetworkApiGet(`http://staging-teach.ireadabc.com`, `/api/oxford/courseware/v1/${this.courseItem.id}/getanswer`, queryObj, (data) => {
callback && callback(JSON.stringify(data.rows));
});
}
}, },
callNativeFunction(param) { callNativeFunction(param) {
......
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