Commit bce5060a authored by liujiangnan's avatar liujiangnan

添加接口修改

parent 29ed7445
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# dependencies # dependencies
/node_modules /node_modules
/publish
# profiling files # profiling files
chrome-profiler-events*.json chrome-profiler-events*.json
......
...@@ -8,19 +8,37 @@ import * as _ from 'lodash'; ...@@ -8,19 +8,37 @@ import * as _ from 'lodash';
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// titleObj = {
// audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3',
// content: 'what is this? ',
// icons: [],
// type: 'a'
// };
titleObj = { titleObj = {
audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', audio_url: '',
content: 'what is this? ', content: '',
icons: [], icons: [],
type: 'a' type: ''
}; };
constructor() { teststr = "";
constructor() {
} }
ngOnInit() { ngOnInit() {
var _this = this;
setTimeout(()=>{
this.titleObj.content = "Hello world!!!";
this.teststr = "************"
},2000);
// (<any>window).courseware.getData(function(data){
// if(data){
// _this.titleObj.content = data.content;
// }
// });
} }
ngOnChanges() { ngOnChanges() {
...@@ -32,15 +50,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -32,15 +50,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
updateTitleObjSuccess(titleObj) { updateTitleObjSuccess(titleObj) {
this.titleObj = titleObj;
this.save();
} }
onTitleAudioUploadSuccess(res) { onTitleAudioUploadSuccess(res) {
this.titleObj.audio_url = res.url;
this.save();
} }
save() { save() {
(<any>window).courseware.setData(this.titleObj);
} }
} }
...@@ -20,7 +20,12 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni ...@@ -20,7 +20,12 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
audioElement: ElementRef; audioElement: ElementRef;
data = { data = {
contentObj:{titleObj:null} contentObj:{titleObj:{
audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3',
content: 'what is this?&nbsp;',
icons: [],
type: 'a'
}}
}; };
letters = []; letters = [];
...@@ -36,15 +41,15 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni ...@@ -36,15 +41,15 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
range(start, end) { range(start, end) {
return (new Array(end - start + 1)).fill(undefined).map((_, i) => i + start); return (new Array(end - start + 1)).fill(undefined).map((_, i) => i + start);
} }
ngOnInit() { ngOnInit() {
if (!this.data.contentObj.titleObj) {
this.data.contentObj.titleObj = { let _this = this;
audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', (<any>window).courseware.getData(function(data){
content: 'what is this?&nbsp;', if(data){
icons: [], _this.data.contentObj.titleObj = data;
type: 'a' }
}; });
}
// const letters = _.shuffle( [...this.range(97, 122), ...this.range(65, 90)]); // const letters = _.shuffle( [...this.range(97, 122), ...this.range(65, 90)]);
[...this.range(97, 122), ...this.range(65, 90)].forEach(c => { [...this.range(97, 122), ...this.range(65, 90)].forEach(c => {
this.lettersAscii[c] = String.fromCharCode(c); this.lettersAscii[c] = String.fromCharCode(c);
......
...@@ -7,15 +7,66 @@ ...@@ -7,15 +7,66 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
<script>
window.courseware = (function(){
if(window.parent.net){
window.net = window.parent.net;
var id = window.frameElement.getAttribute("dataid");
return {
getData: function(callback){
net.getData("getCoursewareData",id,function(res){
if(res){
res = JSON.parse(res);
if(res.msg==="success"){
let callData = null;
if(res.data&&res.data!='null'){
callData = JSON.parse(res.data);
}
callback&&callback(callData);
}else{
alert('数据加载失败!');
}
}else{
alert('数据加载失败!');
}
});
},
setData: function(data,callback){
let str = JSON.stringify(data);
net.getData("setCoursewareData",{id: id,data: str},function(res){
if(res){
res = JSON.parse(res);
if(res.msg==="success"){
callback&&callback();
}else{
alert('数据保存失败!');
}
}else{
alert('数据保存失败!');
}
});
}
}
} else {
return {
getData: function(callback){
let data = localStorage.getItem("courseware_data");
callback&&callback(data);
},
setData: function(data,callback){
localStorage.setItem("courseware_data",data);
callback&&callback();
}
}
}
})();
</script>
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
</body> </body>
<script>
window.net = window.parent.net||{};
window.net.doUpload = function(){
console.log("*********");
}
</script>
</html> </html>
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