Commit a7e92ed4 authored by limingzhe's avatar limingzhe

update template

parent c915a859
This diff is collapsed.
......@@ -5,50 +5,4 @@
width: 100%;
height: 100%;
.item-box{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 10px;
padding-bottom: 5vw;
padding-top: 5vw;
}
.pic-sound-box {
width: 50%;
display: flex;
//align-items: center;
flex-direction: column
}
.add-btn-box {
display: flex;
align-items: center;
justify-content: center;
//width: 180px;
height: 20vw;
//background: #FFDC00;
padding: 10px;
padding-top: 5vw;
}
}
......@@ -9,30 +9,10 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
picArr = [];
_item: any;
KEY = 'hw_000';
// @Input()
set item(item) {
this._item = item;
// this.init();
}
get item() {
return this._item;
}
@Output()
update = new EventEmitter();
// 储存数据用
saveKey = "test_0011";
// 储存对象
item;
constructor(private appRef: ApplicationRef) {
......@@ -43,162 +23,68 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() {
this.item = {};
this.item.contentObj = {};
const getData = (<any> window).courseware.getData;
getData((data) => {
// 获取存储的数据
(<any> window).courseware.getData((data) => {
if (data) {
this.item = data;
} else {
this.item = {};
}
if ( !this.item.contentObj ) {
this.item.contentObj = {};
}
console.log('~data:', data);
this.init();
this.refresh();
}, this.KEY);
}, this.saveKey);
// this.initData();
}
ngOnChanges() {
}
ngOnDestroy() {
}
init() {
if (this.item.contentObj.picArr) {
this.picArr = this.item.contentObj.picArr;
} else {
this.picArr = this.getDefaultPicArr();
this.item.contentObj.picArr = this.picArr;
}
console.log('item:' , this.item);
// this.picArr = this.getDefaultPicArr();
// this.item.contentObj.picArr = this.picArr;
// console.log('this.item:;', this.picArr);
ngOnChanges() {
}
getDefaultPicArr() {
const arr = [];
// for (let i = 0; i < 4; i ++) {
// const data = {};
// data['pic_url'] = '';
//
// const soundArr = [];
// for (let i = 0; i < 3; i++) {
// const tmpData = {};
// tmpData['answer'] = false;
// tmpData['audio_url'] = '';
// soundArr.push(tmpData);
// }
// data['soundArr'] = soundArr;
//
// arr.push(data);
// }
return arr;
ngOnDestroy() {
}
initData() {
}
deleteItem(data) {
const index = this.picArr.indexOf(data);
if (index !== -1) {
this.picArr.splice(index, 1);
}
init() {
// this.update.emit(this.item);
this.save();
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
onImageUploadSuccessByItem(e, item, id = null) {
if (id != null) {
item[id + '_pic_url'] = e.url;
} else {
item.pic_url = e.url;
}
this.item[key] = e.url;
this.save();
// this.update.emit(this.item);
// console.log('this.item: ', this.item);
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
onAudioUploadSuccessByItem(e, item, id = null) {
if (id != null) {
item[id + '_audio_url'] = e.url;
} else {
item.audio_url = e.url;
}
// this.update.emit(this.item);
this.item[key] = e.url;
this.save();
}
addPic() {
this.picArr.push({
pic_url: '',
audio_url: '',
// text: '',
// radioValue: 'A'
});
this.saveItem();
}
radioClick(it, radioValue) {
it.radioValue = radioValue;
this.saveItem();
}
clickCheckBox() {
console.log(' in clickCheckBox');
this.saveItem();
}
saveItem() {
// this.update.emit(this.item);
this.save();
}
/**
* 储存数据
*/
save() {
(<any> window).courseware.setData(this.item, null, this.KEY);
(<any> window).courseware.setData(this.item, null, this.saveKey);
this.refresh();
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
......
......@@ -359,7 +359,7 @@ export class ColorSpr extends MySprite {
g = 0;
b = 0;
createGSCanvas(){
createGSCanvas() {
if (!this.img) {
return;
......@@ -1327,6 +1327,16 @@ export function removeItemFromArr(arr, item) {
export function getPosDistance(sx, sy, ex, ey) {
const _x = ex - sx;
const _y = ey - sy;
const len = Math.sqrt( Math.pow(_x, 2) + Math.pow(_y, 2) );
return len;
}
......@@ -1370,13 +1380,6 @@ export function circleMove(item, x0, y0, time = 2, addR = 360, xPer = 1, yPer =
}
export function getPosDistance(sx, sy, ex, ey) {
const _x = ex - sx;
const _y = ey - sy;
const len = Math.sqrt( Math.pow(_x, 2) + Math.pow(_y, 2) );
return len;
}
export function delayCall(callback, second) {
const tween = new TWEEN.Tween(this)
......
.game-container {
width: 100%;
height: 100%;
//background-image: url("/assets/listen-read-circle/bg.jpg");
background: #ffffff;
background-repeat: no-repeat;
background-size: cover;
}
......@@ -19,11 +17,3 @@
src: url("../../assets/font/BRLNSDB.TTF") ;
}
//
//
//@font-face
//{
// font-family: 'RoundedBold';
// src: url("../../assets/font/ArialRoundedBold.otf") ;
//}
This diff is collapsed.
const res = [
['bg', "assets/play/bg.jpg"],
// ['bg', "assets/play/bg.jpg"],
['btn_left', "assets/play/btn_left.png"],
['btn_right', "assets/play/btn_right.png"],
['text_bg', "assets/play/text_bg.png"],
// ['text_bg', "assets/play/text_bg.png"],
];
......@@ -12,10 +11,7 @@ const res = [
const resAudio = [
// ['click', "assets/play/music/click.mp3"],
['click', "assets/play/music/click.mp3"],
];
......
import { TestBed } from '@angular/core/testing';
import { ConfigService } from './config.service';
describe('ConfigService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: ConfigService = TestBed.get(ConfigService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class ConfigService {
configUrl = 'proxy.conf.json';
constructor( private http: HttpClient ) { }
getConfig() {
return this.http.get(this.configUrl)
.pipe(
);
}
showConfig() {
this.getConfig()
.subscribe((data) => {
console.log('data:', data);
});
}
test(data) {
// return new Promise<any> {
// return new Promise((resolve, reject) => {
// this.http.get(url).subscribe((res) => {
// resolve(res);
// }, reject);
// });
//
return this.get('/api/login');
// return this.http.post('/login', data);
}
get(url: string): Promise<any> {
return new Promise((resolve, reject) => {
this.http.get(url).subscribe((res) => {
resolve(res);
}, reject);
});
}
// login(user): Observable<any> {
//
//
// return this.http.post('/login', user).pipe(
// tap((data => {
// console.log('login', data)
// localStorage.setItem('token', _.get(data, 'token'));
// delete data['token'];
// localStorage.setItem('info', JSON.stringify(data));
// this.getInfoPromise = this.load('/user/getInfo');
// }))
// );
// }
}
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