Commit 987a5093 authored by limingzhe's avatar limingzhe

first

parent baec353a
This diff is collapsed.
{ {
"name": "ng-template-generator", "name": "ng-template-generator",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"start": "ng serve", "start": "ng serve",
"build": "ng build --build--optimizer --aot --base-href /JGT/v3/", "build": "ng build --build--optimizer --aot --base-href /JGT/v3/",
"publish": "node ./bin/publish.js" "publish": "node ./bin/publish.js"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"nedb": "^1.8.0", "nedb": "^1.8.0",
"ng-lottie": "^0.3.1", "ng-lottie": "^0.3.1",
"ng-zorro-antd": "^7.2.0", "ng-zorro-antd": "^7.2.0",
"npm": "^6.5.0", "npm": "^6.13.4",
"rxjs": "^6.3.3", "rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3", "rxjs-compat": "^6.3.3",
"rxjs-tslint": "^0.1.6", "rxjs-tslint": "^0.1.6",
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^0.11.4", "@angular-devkit/build-angular": "^0.803.20",
"@angular/cli": "^7.2.10", "@angular/cli": "^7.2.10",
"@angular/compiler-cli": "^7.2.10", "@angular/compiler-cli": "^7.2.10",
"@angular/language-service": "^7.2.10", "@angular/language-service": "^7.2.10",
......
...@@ -4,99 +4,17 @@ ...@@ -4,99 +4,17 @@
<div *ngFor="let it of picArr; let i = index" <div style="padding: 3vw; display: flex; align-items: center">
nz-col nzSpan="8" >
<span style="padding-right: 1vw"> 人数: </span>
<nz-radio-group [(ngModel)]="item.contentObj.type" (ngModelChange)="log(item.contentObj.type)">
<div nz-row nzType="flex" nzJustify="space-around" nzAlign="middle">
<div class="item-box"> <div *ngFor="let pic of picArr; let i = index" nz-col nzSpan="6">
<label nz-radio nzValue={{i}}> {{pic.text}} </label>
</div>
<app-upload-image-with-preview
style="width: 100%"
[picUrl]="it.pic_url"
(imageUploaded)="onImageUploadSuccessByItem($event, it)"
></app-upload-image-with-preview>
<div style="display: flex; justify-items: center; padding-top: 10px">
<app-audio-recorder
[audioUrl]="it.audio_url"
(audioUploaded)="onAudioUploadSuccessByItem($event, it)">
</app-audio-recorder>
<button style="margin-left: 10px;" nz-button nzType="danger" (click)="deleteItem(it)">
<i nz-icon type="close"></i>
</button>
</div> </div>
</div> </nz-radio-group>
<!--<h5> id-{{i+1}} </h5>-->
<!--<div style="display: flex; align-items: center; justify-content: center; padding-bottom: 5px">-->
<!--<input type="text" nz-input placeholder="" [(ngModel)]="it.text" (blur)="saveItem()">-->
<!--<button style="margin-left: 10px;" nz-button nzType="danger" (click)="deleteItem(it)">-->
<!--<i nz-icon type="close"></i>-->
<!--</button>-->
<!--</div>-->
<!--<app-upload-image-with-preview-->
<!--style="width: 100%"-->
<!--[picUrl]="it.pic_url"-->
<!--(imageUploaded)="onImageUploadSuccessByItem($event, it)"-->
<!--&gt;</app-upload-image-with-preview>-->
<!--<div style="display: flex; align-items: center; justify-content: center">-->
<!--<span style="width: 80px;">-->
<!--question:-->
<!--</span>-->
<!--<app-audio-recorder-->
<!--[audioUrl]="it['q_audio_url']"-->
<!--(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'q')">-->
<!--</app-audio-recorder>-->
<!--</div>-->
<!--<div style="display: flex; align-items: center; justify-content: center">-->
<!--<span style="width: 80px;">-->
<!--answer:-->
<!--</span>-->
<!--<app-audio-recorder-->
<!--[audioUrl]="it['a_audio_url']"-->
<!--(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'a')">-->
<!--</app-audio-recorder>-->
<!--</div>-->
<!--<nz-radio-group [(ngModel)]="it.radioValue" >-->
<!--<label nz-radio nzValue="A" (click)="radioClick(it, 'A')"> <i nz-icon nzType="check" nzTheme="outline"></i> </label>-->
<!--<label nz-radio nzValue="B" (click)="radioClick(it, 'B')"> <i nz-icon nzType="close" nzTheme="outline"></i> </label>-->
<!--</nz-radio-group>-->
</div>
<div nz-col nzSpan="8" class="add-btn-box" >
<!--<div style="width: 100%; height: 100%;">-->
<button style=" margin: auto; width: 60%; height: 60%;" nz-button nzType="dashed" class="add-btn"
(click)="addPic()">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
Add
</button>
<!--</div>-->
</div> </div>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
.item-box{ .item-box{
width: 100%; //margin: auto;
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
flex-direction: column; flex-direction: column;
padding: 10px; padding: 10px;
padding-bottom: 5vw; padding-bottom: 2vw;
padding-top: 5vw; padding-top: 3vw;
} }
...@@ -41,14 +41,21 @@ ...@@ -41,14 +41,21 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
//width: 180px; //width: 180px;
height: 20vw; height: 15vw;
//background: #FFDC00; //background: #FFDC00;
padding: 10px; padding: 10px;
padding-top: 5vw; padding-top: 1vw;
} }
} }
.border {
border-radius: 20px;
border-style: dashed;
}
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core'; import {
Component,
EventEmitter,
Input,
OnDestroy,
OnChanges,
OnInit,
Output,
ApplicationRef,
ChangeDetectorRef
} from '@angular/core';
...@@ -10,15 +20,18 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap ...@@ -10,15 +20,18 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
picArr = []; picArr = [];
optionArr = [];
_item: any; _item: any;
KEY = 'hw_000'; KEY = 'dfzx_17';
answerType = 'A';
refreshTimeId;
refreshLabel = 0;
// @Input() // @Input()
set item(item) { set item(item) {
...@@ -35,7 +48,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -35,7 +48,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
constructor(private appRef: ApplicationRef) {
constructor(private appRef: ApplicationRef,
public changeDetectorRef: ChangeDetectorRef) {
} }
...@@ -60,6 +76,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -60,6 +76,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log('~data:', data); console.log('~data:', data);
this.init(); this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
}, this.KEY); }, this.KEY);
...@@ -71,6 +91,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -71,6 +91,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
ngOnDestroy() { ngOnDestroy() {
clearTimeout( this.refreshTimeId);
} }
...@@ -81,17 +103,36 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -81,17 +103,36 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} else { } else {
this.picArr = this.getDefaultPicArr(); this.picArr = this.getDefaultPicArr();
this.item.contentObj.picArr = this.picArr; this.item.contentObj.picArr = this.picArr;
this.item.contentObj.type = 0;
} }
console.log('item:' , this.item); }
// this.picArr = this.getDefaultPicArr();
// this.item.contentObj.picArr = this.picArr; startRefresh() {
// console.log('this.item:;', this.picArr);
this.refreshTimeId = setTimeout(() => {
this.refreshLabel ++;
this.startRefresh();
this.refresh();
}, 1000);
} }
getDefaultPicArr() { getDefaultPicArr() {
const arr = []; const arr = [
{
text: '一人',
type: '0'
},
{
text: '两人',
type: '1'
}
];
// for (let i = 0; i < 4; i ++) { // for (let i = 0; i < 4; i ++) {
// const data = {}; // const data = {};
// data['pic_url'] = ''; // data['pic_url'] = '';
...@@ -126,10 +167,26 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -126,10 +167,26 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
// this.update.emit(this.item); // this.update.emit(this.item);
this.refreshOptionsPicArr();
this.save(); this.save();
} }
deleteOption(data) {
const index = this.optionArr.indexOf(data);
if (index !== -1) {
this.optionArr.splice(index, 1);
}
this.save();
}
refreshOptionsPicArr() {
for (let i = 0; i < this.optionArr.length; i++) {
const option = this.optionArr[i];
option.picArr = this.getOptionPicArr();
}
}
...@@ -166,16 +223,55 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -166,16 +223,55 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
addPic() { addPic() {
this.picArr.push({
const data = {
text: '',
pic_url: '', pic_url: '',
audio_url: '', audio_url: '',
// text: '', // text: '',
// radioValue: 'A' // radioValue: 'A'
}); };
this.picArr.push(data);
this.refreshOptionsPicArr();
this.saveItem(); this.saveItem();
}
addOption() {
const data = {
text: '',
pic_url: '',
audio_url: '',
type: '0'
};
data['picArr'] = this.getOptionPicArr();
this.optionArr.push(data);
this.saveItem();
}
getOptionPicArr() {
const arr = [];
for (let i = 0; i < this.picArr.length; i++) {
const data = {};
data['label'] = '类别-' + (i + 1);
data['value'] = i;
arr.push(data);
}
return arr;
} }
radioClick(it, radioValue) { radioClick(it, radioValue) {
it.radioValue = radioValue; it.radioValue = radioValue;
...@@ -189,10 +285,18 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -189,10 +285,18 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
saveItem() { saveItem() {
console.log(' in saveItem');
// this.update.emit(this.item); // this.update.emit(this.item);
this.save(); this.save();
} }
log(a) {
console.log('a:', a);
this.save();
}
save() { save() {
(<any> window).courseware.setData(this.item, null, this.KEY); (<any> window).courseware.setData(this.item, null, this.KEY);
......
...@@ -1378,7 +1378,7 @@ export function getPosDistance(sx, sy, ex, ey) { ...@@ -1378,7 +1378,7 @@ export function getPosDistance(sx, sy, ex, ey) {
return len; return len;
} }
export function delayCall(callback, second) { export function delayCall(item, callback, second) {
const tween = new TWEEN.Tween(this) const tween = new TWEEN.Tween(this)
.delay(second * 1000) .delay(second * 1000)
.onComplete(() => { .onComplete(() => {
...@@ -1543,3 +1543,54 @@ export function shake(item, time = 0.5, callback = null, rate = 1) { ...@@ -1543,3 +1543,54 @@ export function shake(item, time = 0.5, callback = null, rate = 1) {
// --------------- custom class -------------------- // --------------- custom class --------------------
export function showBlingBling(starImg, rectArea, parent, mapScale = 1, num = 30, disTime = 0.1, showTime = 3) {
const timeId = setInterval(() => {
showBlingStar(starImg, num, rectArea, parent, mapScale);
}, disTime * 1000);
//
// const tmpObj = {};
// tmpObj['timeId'] = timeId;
setTimeout(() => {
clearInterval(timeId);
}, showTime * 1000);
}
function showBlingStar(starImg, num, rectArea, parent, mapScale) {
for (let i = 0; i < num; i++) {
const star = new MySprite();
star.init(starImg);
const px = rectArea.x + Math.random() * rectArea.width;
const py = rectArea.y + Math.random() * rectArea.height;
star.x = px;
star.y = py;
const randomS = (0.1 + Math.random() * 0.8) * mapScale;
star.setScaleXY(0);
parent.addChild(star);
scaleItem(star, randomS, 0.3, () => {
setTimeout(() => {
scaleItem(star, 0, 0.3, () => {
parent.removeChild(star);
});
}, 100 + Math.random() * 200);
});
}
}
This diff is collapsed.
const res = [ const res = [
['bg', "assets/play/bg.jpg"], ['bg', "assets/play/bg.jpg"],
['btn_left', "assets/play/btn_left.png"], ['panel', "assets/play/panel.png"],
['btn_right', "assets/play/btn_right.png"],
['text_bg', "assets/play/text_bg.png"], ['color_1', "assets/play/color/1.png"],
['color_2', "assets/play/color/2.png"],
['color_3', "assets/play/color/3.png"],
['color_4', "assets/play/color/4.png"],
['color_5', "assets/play/color/5.png"],
['icon_1', "assets/play/icon/hat.png"],
['icon_2', "assets/play/icon/clothes.png"],
['icon_3', "assets/play/icon/pants.png"],
['icon_4', "assets/play/icon/shoes.png"],
['boy', "assets/play/boy.png"],
['girl', "assets/play/girl.png"],
['icon', "assets/play/icon/icon.png"],
['icon_boy', "assets/play/icon/boy.png"],
['icon_girl', "assets/play/icon/girl.png"],
['hat_1', "assets/play/hat/1.png"],
['hat_2', "assets/play/hat/2.png"],
['hat_3', "assets/play/hat/3.png"],
['hat_4', "assets/play/hat/4.png"],
['hat_5', "assets/play/hat/5.png"],
['clothes_1', "assets/play/clothes/1.png"],
['clothes_2', "assets/play/clothes/2.png"],
['clothes_3', "assets/play/clothes/3.png"],
['clothes_4', "assets/play/clothes/4.png"],
['clothes_5', "assets/play/clothes/5.png"],
['pants_1', "assets/play/pants/1.png"],
['pants_2', "assets/play/pants/2.png"],
['pants_3', "assets/play/pants/3.png"],
['pants_4', "assets/play/pants/4.png"],
['pants_5', "assets/play/pants/5.png"],
['shoes_1', "assets/play/shoes/1.png"],
['shoes_2', "assets/play/shoes/2.png"],
['shoes_3', "assets/play/shoes/3.png"],
['shoes_4', "assets/play/shoes/4.png"],
['shoes_5', "assets/play/shoes/5.png"],
['star', "assets/play/star.png"],
]; ];
...@@ -13,7 +57,10 @@ const res = [ ...@@ -13,7 +57,10 @@ const res = [
const resAudio = [ const resAudio = [
// ['click', "assets/play/music/click.mp3"], ['click', "assets/play/music/click.mp3"],
['click_2', "assets/play/music/click_2.mp3"],
['click_3', "assets/play/music/click_3.mp3"],
['star', "assets/play/music/star.mp3"],
......
src/assets/play/bg.jpg

25.8 KB | W: | H:

src/assets/play/bg.jpg

12.2 KB | W: | H:

src/assets/play/bg.jpg
src/assets/play/bg.jpg
src/assets/play/bg.jpg
src/assets/play/bg.jpg
  • 2-up
  • Swipe
  • Onion skin
src/assets/play/default/pic.jpg

28.7 KB | W: | H:

src/assets/play/default/pic.jpg

28 KB | W: | H:

src/assets/play/default/pic.jpg
src/assets/play/default/pic.jpg
src/assets/play/default/pic.jpg
src/assets/play/default/pic.jpg
  • 2-up
  • Swipe
  • Onion skin
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