Commit b1c207ea authored by Tt's avatar Tt

流程完成部分

parent 04f41b74
......@@ -8,3 +8,4 @@
/publish/publish/ios
/publish/publish/*.zip
/node_modules
/.vscode
\ No newline at end of file
@import '../style/common_mixin.css';
.model-content {
width: 100%;
height: 100%;
/* display: flex; */
/* justify-content: flex-start; */
/* align-items: flex-start; */
/* flex-wrap: wrap; */
}
.item-box {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 10px;
padding-bottom: 2vw;
padding-top: 3vw;
}
.radioPaire {
float: left;
margin: 3px;
border-style: dashed;
border-color: #000;
border-width: 1px;
.pic-sound-box {
width: 50%;
display: flex;
flex-direction: column;
}
.add-btn-box {
display: flex;
align-items: center;
justify-content: center;
height: 20vw;
padding: 10px;
padding-top: 5vw;
}
.border {
width: 450px;
height: 450px;
border-radius: 20px;
border-style: dashed;
padding: 20px;
margin: 20px;
/*width: 500px; */
/*//border-radius: 20px;*/
/*//border-width: 2px;*/
/*//border-color: #000000;*/
text-align: center;
float: left;
margin-left: 10px;
margin-bottom: 10px;
}
.border-lite {
border: 2px dashed #ddd;
border-radius: 0.5rem;
.group-title {
width: 100%;
}
.group-item {
width: 100%;
display: flex;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
padding: 10px;
margin: 10px;
}
.box-dbt-0 {
border: 1px solid gray;
width: 100%;
/* text-align: center; */
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border-bottom: 0px;
}
.box-dbt-1 {
border: 1px solid gray;
width: 100%;
text-align: left;
border-bottom-left-radius: 25px;
border-bottom-right-radius: 25px;
}
.box-dbt-2 {
margin-left: 25%;
width: 50%;
height: 100px;
text-align: center;
}
.box-lbt-0 {
border: 1px solid gray;
width: 100%;
text-align: center;
border-left: 0px;
border-right: 0px;
}
.box-lbt-1 {
border: 1px 0px 0px 0px solid gray;
width: 100%;
text-align: left;
}
.box-lbt-2 {
border: 1px 0px 0px 0px solid gray;
margin-left: 25%;
width: 50%;
height: 100px;
text-align: center;
}
.error-message {
border: 1px solid gray;
margin-top: 1%;
width: 100%;
height: 100px;
background-color: #fff;
border-radius: 15px;
text-align: center;
box-shadow: 0px 0px 5px 2px #888888;
overflow: hidden;
}
\ No newline at end of file
<div class="model-content">
<div>
<div *ngFor="let biaoti of picArr; let a = index">
<div class="box-dbt-0">
<div style="padding: 10px;">
<div style="width:100%;vertical-align:middle; padding-top: 10px; padding-bottom: 10px; text-align: center;">
<span style="font-weight: 700; font-size: 30px; vertical-align:middle;">标题:</span>
<input [(ngModel)]="biaoti.title" type="text"
style="width: 200px;height:35px;margin-left: 30px; vertical-align:middle;font-size: 30px; border: 1px solid #ccc; border-radius: 10px;" />
</div>
<div style="width: 300px;" align='center'>
<span>图1: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')">
</app-upload-image-with-preview>
</div>
<div style="width: 300px; margin-top: 5px;" align='center'>
<span>图2: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url_2"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url_2')">
<div class="box-dbt-1">
<div *ngFor="let zhulei of biaoti.child; let b = index">
<div class="box-lbt-0">
<div style="width:100%;vertical-align:middle; padding-top: 10px; padding-bottom: 10px; text-align: center;">
<span style="font-weight: 700; font-size: 30px; vertical-align:middle;">主类:</span>
<input [(ngModel)]="zhulei.title" type="text"
style="width: 200px;height:35px;margin-left: 30px; vertical-align:middle;font-size: 30px; border: 1px solid #ccc; border-radius: 10px;" />
</div>
</div>
<div class="box-lbt-1">
<div *ngFor="let fenlei of zhulei.child; let c = index">
<div class="box-lbt-0">
<div
style="width:100%;vertical-align:middle; padding-top: 10px; padding-bottom: 10px; text-align: center;">
<span style="font-weight: 700; font-size: 30px; vertical-align:middle;">分类{{c+1}}:</span>
<input [(ngModel)]="fenlei.title" type="text"
style="width: 200px;height:35px;margin-left: 30px; vertical-align:middle;font-size: 30px; border: 1px solid #ccc; border-radius: 10px;" />
</div>
</div>
<div class="box-lbt-1">
<div *ngFor="let sonlei of fenlei.child; let d = index">
<div class="box-lbt-0">
<div style="width: 50%;margin-left: 25%;">
<div
style="width:100%;vertical-align:middle; padding-top: 10px; padding-bottom: 10px; text-align: center;">
<span
style="font-weight: 700; font-size: 30px; vertical-align:middle;">分类{{c+1}}-子类{{d+1}}:</span>
<input [(ngModel)]="sonlei.title" type="text"
style="width: 200px;height:35px;margin-left: 30px; vertical-align:middle;font-size: 30px; border: 1px solid #ccc; border-radius: 10px;" />
<button style="margin-left: 30px;" nz-button nzType="danger" (click)="deleteSon(a, b, c,d)">
<span>删除</span>
</button>
</div>
</div>
</div>
<div class="box-lbt-1">
<div class="group-item">
<div *ngFor="let it of sonlei.child; let e = index">
<div class="border">
<div style="width: 100%; align-items:center;">
<div class="item-box" style="width: 50%;height:200px; margin-left: 25%; margin-top: 10%;">
<span>文字</span>
<input style="width: 80%; margin-bottom: 0.5vw" type="text"
nz-input placeholder="" [(ngModel)]="it.title" (blur)="saveItem()">
<span>图片</span>
<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>
</div> -->
</div>
<div class="item-box" style="width: 50%; margin-left: 25%;">
<button style="margin-bottom: 10px;" nz-button nzType="danger"
(click)="deleteItem(a,b,c,d,e)">
<span>删除</span>
</button>
</div>
</div>
</div>
</div>
<div class="border">
<h3 style="margin-top: 40%; width: 100%; line-height: 40px; text-align: center; color: red;">
每个子类卡片2~4个
</h3>
<button *ngIf="picArr[a].child[b].child[c].child[d].child.length >= 4" disabled nz-button
nzType="primary" (click)="addItem(a,b,c,d)">
<span>增加卡片</span>
</button>
<button *ngIf="picArr[a].child[b].child[c].child[d].child.length < 4" nz-button nzType="primary"
(click)="addItem(a,b,c,d)">
<span>增加卡片</span>
</button>
</div>
</div>
</div>
</div>
<div class="box-lbt-2">
<button *ngIf="picArr[a].child[b].child[c].child.length >= 4 || picArr[a].child[b].child[0].child.length + picArr[a].child[b].child[1].child.length >=6"
style="width: 100%; height: 100%; border-radius: 25px; " disabled nz-button nzType="solid"
(click)="addSon(a, b, c)">
<i nz-icon nzType="plus-circle"></i>
<span style="font-size: 20px;">增加子类</span>
</button>
<button *ngIf="picArr[a].child[b].child[c].child.length < 4 && picArr[a].child[b].child[0].child.length + picArr[a].child[b].child[1].child.length <6"
style="width: 100%; height: 100%; border-radius: 25px; " nz-button nzType="solid"
(click)="addSon(a, b, c)">
<i nz-icon nzType="plus-circle"></i>
<span style="font-size: 20px;">增加子类</span>
</button>
</div>
</div>
</div>
</div>
<div style="width: 300px; margin-top: 15px;">
<span>文本: </span>
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
</div>
<div style="margin-top: 5px">
<span>音频: </span>
<app-audio-recorder
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
</div>
</div>
</div>
<!-- <div class="box-testlet-0">
<div class="group-title">
<div style="width: 100%; height: 70px; text-align: center; padding-top: 10px;">
<span style="font-weight: 700; font-size: 30px; vertical-align:middle;">星-{{m+1}}</span>
<button *ngIf="picArr.length > 1" style="margin-left: 30px; height: 40px; vertical-align:middle;" nz-button nzType="danger"
(click)="deleteTestlet(m)">
<span style="font-size: 20px;">删除星</span>
</button>
<button *ngIf="picArr.length <= 1" style="margin-left: 30px; height: 40px; vertical-align:middle;" disabled nz-button nzType="danger"
(click)="deleteTestlet(m)">
<span style="font-size: 20px;">删除星</span>
</button>
</div>
</div>
</div>
<div class="box-testlet-1">
<div *ngFor="let page of testlet; let n = index">
<div class="box-group-0">
<div class="group-title">
<div style="width: 100%; height: 70px; text-align: center; padding-top: 10px;">
<span style="font-weight: 500; font-size: 27px; vertical-align:middle;">星-{{m+1}} 页-{{n+1}}</span>
<button *ngIf="picArr[m].length <= 1" style="margin-left: 30px; height: 40px; vertical-align:middle;"
disabled nz-button nzType="danger" (click)="deletePage(m,n)">
<span style="font-size: 20px;">删除页</span>
</button>
<button *ngIf="picArr[m].length > 1" style="margin-left: 30px; height: 40px; vertical-align:middle;"
nz-button nzType="danger" (click)="deletePage(m,n)">
<span style="font-size: 20px;">删除页</span>
</button>
</div>
</div>
</div>
<div class="box-group-1">
<div class="group-item">
<div *ngFor="let it of page; let i = index">
<div class="border">
<h3 style="width: 100%; line-height: 40px; text-align: center;">星-{{m+1}} 页-{{n+1}} 卡片-{{i+1}}</h3>
<hr />
<div style="display: flex; align-items:center; width: 100%;">
<div class="item-box" style="width: 45%;height:300px; margin-left: 5%;">
<nz-radio-group [(ngModel)]="it.left.radioValue">
<label nz-radio nzValue="A" (click)="radioClick(it, 'A')">文字
</label>
<label nz-radio nzValue="B" (click)="radioClick(it, 'B')">图片
</label>
<label nz-radio nzValue="C" (click)="radioClick(it, 'E')">音频
</label>
</nz-radio-group>
<input *ngIf="it.left.radioValue == 'A'" style="width: 80%; margin-bottom: 0.5vw" type="text"
nz-input placeholder="" [(ngModel)]="it.left.title" (blur)="saveItem()">
<app-upload-image-with-preview *ngIf="it.left.radioValue == 'B'" style="width: 100%"
[picUrl]="it.left.pic_url" (imageUploaded)="onImageUploadSuccessByItem($event, it.left)">
</app-upload-image-with-preview>
<div style="display: flex; justify-items: center; padding-top: 10px">
<app-audio-recorder [audioUrl]="it.left.audio_url"
(audioUploaded)="onAudioUploadSuccessByItem($event, it.left)">
</app-audio-recorder>
</div>
</div>
<div class="item-box" style="width: 45%;height:300px; margin-right: 5%">
<nz-radio-group [(ngModel)]="it.right.radioValue">
<label nz-radio nzValue="A" (click)="radioClick(it, 'C')">文字
</label>
<label nz-radio nzValue="B" (click)="radioClick(it, 'D')">图片
</label>
<label nz-radio nzValue="C" (click)="radioClick(it, 'F')">音频
</label>
</nz-radio-group>
<input *ngIf="it.right.radioValue == 'A'" style="width: 80%; margin-bottom: 0.5vw" type="text"
nz-input placeholder="" [(ngModel)]="it.right.title" (blur)="saveItem()">
<app-upload-image-with-preview *ngIf="it.right.radioValue == 'B'" style="width: 100%"
[picUrl]="it.right.pic_url" (imageUploaded)="onImageUploadSuccessByItem($event, it.right)">
</app-upload-image-with-preview>
<div style="display: flex; justify-items: center; padding-top: 10px">
<app-audio-recorder [audioUrl]="it.right.audio_url"
(audioUploaded)="onAudioUploadSuccessByItem($event, it.right)">
</app-audio-recorder>
</div>
</div>
</div>
<button style="margin-bottom: 10px;" nz-button nzType="danger" (click)="deleteItem(i,m,n)">
<span>删除</span>
</button>
</div>
</div>
<div class="border">
<h3 style="margin-top: 15%; width: 100%; line-height: 40px; text-align: center; color: red;">
每页卡片2~5个
</h3>
<h3 style="width: 100%; line-height: 40px; text-align: center; color: red;">
卡片2个是上传图片尺寸为280*298
</h3>
<h3 style="width: 100%; line-height: 40px; text-align: center; color: red;">
卡片3个是上传图片尺寸为250*268
</h3>
<h3 style="width: 100%; line-height: 40px; text-align: center; color: red;">
卡片4个是上传图片尺寸为250*268
</h3>
<h3 style="width: 100%; line-height: 40px; text-align: center; color: red;">
卡片5个是上传图片尺寸为200*214
</h3>
<button *ngIf="picArr[m][n].length < 5" style="margin-top: 10%;" nz-button nzType="primary"
(click)="addItem(m,n)">
<span>增加卡片</span>
</button>
<button *ngIf="picArr[m][n].length >= 5" style="margin-top: 10%;" nz-button nzType="primary" disabled
(click)="addItem(m,n)">
<span>增加卡片</span>
</button>
</div>
</div>
</div>
</div>
<div class="box-group-2" style="padding: 0.5vw;">
<button style="width: 100%; height: 100%; border-radius: 25px; " nz-button nzType="dashed" (click)="addPage(m)">
<i nz-icon nzType="plus-circle"></i>
<span style="font-size: 20px;">增加页</span>
</button>
</div>
</div>
</div>
<div class="box-testlet-2" style="padding: 0.5vw;">
<button style="width: 100%; height: 100%; border-radius: 25px; " nz-button nzType="dashed" (click)="addTestlet()">
<i nz-icon nzType="plus-circle"></i>
<span style="font-size: 20px;">增加星</span>
</button>
</div>
<div style="position: fixed;margin-left: 70%; width:25%; top: 1em;right: 1em;">
<div class="error-message">
<div *ngFor="let err of errs; let m = index" style="font-size: 17px; color: red;"> {{err}}</div>
</div>
</div> -->
\ No newline at end of file
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef } from '@angular/core';
@Component({
......@@ -9,102 +8,231 @@ import { JsonPipe } from '@angular/common';
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "test_001";
// 储存对象
item;
picArr = [];
_item: any;
KEY = 'hw_006';
errs = [];
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
// @Input()
set item(item) {
this._item = item;
// this.init();
}
createShell() {
this.item.wordList.push({
word: '',
audio: '',
backWord: '',
backWordAudio: '',
});
this.save();
get item() {
return this._item;
}
removeShell(idx) {
this.item.wordList.splice(idx, 1);
this.save();
@Output()
update = new EventEmitter();
constructor(private appRef: ApplicationRef) {
}
ngOnInit() {
this.item = {};
this.item.contentObj = {};
// 获取存储的数据
(<any>window).courseware.getData((data) => {
const getData = (<any>window).courseware.getData;
getData((data) => {
if (data) {
this.item = data;
} else {
this.item = {};
}
if (!this.item.contentObj) {
this.item.contentObj = {};
}
console.log('~data:', data);
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
}, this.KEY);
// this.initData();
}
ngOnChanges() {
}
ngOnDestroy() {
}
init() {
//在卡片组之上需要增加 两个组 0根->picArr 1题组->testlet 2页面->page 3卡片对->itemData
if (this.item.contentObj.picArr) {
this.picArr = this.item.contentObj.picArr;
this.check();
} else {
this.picArr = this.getDefaultPicArr();
this.item.contentObj.picArr = this.picArr;
}
console.log('item:', this.item);
}
cardItemData() {
return {
cardId: "",
title: "",
pic_url: "",
audio_url: "",
};
}
getDefaultPicArr() {
let arr = [];
let biaoti = { title: "", child: [] };
let zhulei = { title: "", child: [] };
for (let m = 0; m < 2; m++) {
let fenlei = { title: "", child: [] };
let sonlei = { title: "", child: [] };
let item = this.cardItemData();
sonlei.child.push(item);
fenlei.child.push(sonlei);
zhulei.child.push(fenlei);
}
biaoti.child.push(zhulei);
arr.push(biaoti);
return arr;
}
initData() {
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
onImageUploadSuccessByItem(e, item) {
item.pic_url = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
onAudioUploadSuccessByItem(e, item) {
item.audio_url = e.url;
this.save();
}
onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url;
//添加一对
addItem(a, b, c, d) {
//最多4个
if (this.picArr[a].child[b].child[c].child[d].child.length < 4) {
let item = this.cardItemData();
this.picArr[a].child[b].child[c].child[d].child.push(item);
this.saveItem();
}
}
deleteItem(a, b, c, d, e) {
if (e !== -1) {
this.picArr[a].child[b].child[c].child[d].child.splice(e, 1);
}
this.save();
}
//添加一页
addSon(a, b, c) {
let length = this.picArr[a].child[b].child[0].child.length + this.picArr[a].child[b].child[1].child.length;
if(length < 6){
let cla = {
title: "",
child: []
};
for (let i = 0; i < 1; i++) {
let item = this.cardItemData();
cla.child.push(item);
}
this.picArr[a].child[b].child[c].child.push(cla);
this.save();
}
}
deleteSon(a, b, c, d) {
if (d !== -1) {
this.picArr[a].child[b].child[c].child.splice(d, 1);
}
this.save();
}
//选择圆圈
radioClick(it, radioValue) {
it.radioValue = radioValue;
this.saveItem();
}
onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
saveItem() {
console.log(' in saveItem');
// this.update.emit(this.item);
this.save();
}
/**
* 储存数据
*/
check() {
if (1) return;
if (!this.picArr) return;
let picArr = this.picArr;
function tia(info) {
let str = "";
if (info.radioValue == "A") {
if (!info.title) str += ",图片";
} else if (info.radioValue == "B") {
if (!info.pic_url) str += ",图片";
} else if (info.radioValue == "C") {
if (!info.audio_url) str += ",音频";
} else {
str += "卡片"
}
if (str) str += "未上传"
return str;
}
this.errs.length = 0;
for (let m = 0; m < picArr.length; m++) {
for (let n = 0; n < picArr[m].length; n++) {
if (picArr[m][n].length < 2) {
this.errs.push(`星-${m + 1} 页-${n + 1} 卡片少于2个`);
}
for (let i = 0; i < picArr[m][n].length; i++) {
let item = picArr[m][n][i];
let left = item.left;
let right = item.right;
let code0 = tia(left);
let code1 = tia(right);
if (code0) this.errs.push(`星-${m + 1} 页-${n + 1}${i + 1}个卡片 左侧${code0}`);
if (code1) this.errs.push(`星-${m + 1} 页-${n + 1}${i + 1}个卡片 右侧${code1}`);
}
}
}
console.log("this.errs");
console.log(this.errs);
console.log("-------------------------");
}
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
//触发一次检测
// this.item.picArr;
// this.message.create("error", `This is a message of error`);
this.check();
this.refresh();
(<any>window).courseware.setData(this.item, null, this.KEY);
console.log('this.item = ' + JSON.stringify(this.item));
this.refresh();
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
......@@ -112,3 +240,4 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
function retData() {
// let item = {"contentObj":{"picArr":[[[{"cardId":"","left":{"title":"boy1","pic_url":"http://staging-teach.cdn.ireadabc.com/1baedb0b31dc5503e65e114ce21940ab.jpeg","audio_url":"http://staging-teach.cdn.ireadabc.com/495324991838775e49e3ca6593d432c9.mp3","radioValue":"C"},"right":{"title":"food","pic_url":"http://staging-teach.cdn.ireadabc.com/38117778476574c7ef8b445cf24d6eb5.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/495324991838775e49e3ca6593d432c9.mp3","radioValue":"A"},"radioValue":"B"},{"cardId":"","left":{"title":"boy2","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/17cc0e2a383e4632147dc495a1397915.mp3","radioValue":"C"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/21373528a7f38575e871de1d8e5a9671.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/17cc0e2a383e4632147dc495a1397915.mp3","radioValue":"B"},"radioValue":"E"}],[{"cardId":"","left":{"title":"girl1","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/205722475ccaca6233b2f28e635405ca.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/5d099c38000b804241f7dc1286b17457.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/205722475ccaca6233b2f28e635405ca.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"girl2","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/0b6ef24f15c6d8ad7bf27cc913445ebf.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/0abab9a26d537ebf1835a2ed8430162e.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/0b6ef24f15c6d8ad7bf27cc913445ebf.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"girl3","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/b2c170f84b85dddf554b5c837d1d6e30.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/5f34d4100a6ecb187fd715c99e917fc8.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/b2c170f84b85dddf554b5c837d1d6e30.mp3","radioValue":"B"},"radioValue":"D"}]],[[{"cardId":"","left":{"title":"rabbit","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/a7bd7c4de71319db5b6b0b60f0957e21.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/fe229e6b32f385fb8fe5eb9ec5843c66.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/a7bd7c4de71319db5b6b0b60f0957e21.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"cat","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/6c8dcd159d4f05bc93838cc47d3895f4.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/9c5fa50efd7a004f24ea7fcbcf81080e.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/6c8dcd159d4f05bc93838cc47d3895f4.mp3","radioValue":"B"},"radioValue":"A"},{"cardId":"","left":{"title":"coffe","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/3d0fea61d5d97f3caf04a9b738a0291b.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/9d114554c4760ff35f1ff5479504a531.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/a7bd7c4de71319db5b6b0b60f0957e21.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"tea","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/448291140d0b780c0278a14bf49277cb.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/bf26f92e4f0557ad70ac27006855dae9.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/6c8dcd159d4f05bc93838cc47d3895f4.mp3","radioValue":"B"},"radioValue":"D"}]],[[{"cardId":"","left":{"title":"cool","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/0e67aa701df18cbb5581ffb81ffa7836.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/38117778476574c7ef8b445cf24d6eb5.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/4c0379bc0f3bd0722874b2e11fb35336.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"big eye","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/fe226bc303f03ea994cb9a93d1620284.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/21373528a7f38575e871de1d8e5a9671.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/b985b71cd2f3c2d31e45992e4ae69d7f.mp3","radioValue":"B"},"radioValue":"A"},{"cardId":"","left":{"title":"cute","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/84c7b82de1a09da792237a174ebe071b.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/5d099c38000b804241f7dc1286b17457.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/7c1d1540233b6d050eae8215679104a8.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"shuai","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/9e799e7e86cd50c6699ca0e859c8aa1f.mp3","radioValue":"A"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/338dbee896e1fa8869495c84c603c33f.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/9a6b3177ab53ba75bcf293df1065bb64.mp3","radioValue":"B"},"radioValue":"D"},{"cardId":"","left":{"title":"big m","pic_url":"","audio_url":"http://staging-teach.cdn.ireadabc.com/495324991838775e49e3ca6593d432c9.mp3","radioValue":"C"},"right":{"title":"","pic_url":"http://staging-teach.cdn.ireadabc.com/0abab9a26d537ebf1835a2ed8430162e.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/17cc0e2a383e4632147dc495a1397915.mp3","radioValue":"B"},"radioValue":"E"}]]]}}
let item = {"contentObj":{"picArr":[[[{"cardId":"","left":{"title":"11","pic_url":"","audio_url":"","radioValue":"A"},"right":{"title":"11-1","pic_url":"","audio_url":"","radioValue":"A"},"radioValue":"C"},{"cardId":"","left":{"title":"22","pic_url":"","audio_url":"","radioValue":"A"},"right":{"title":"22-1","pic_url":"","audio_url":"","radioValue":"A"},"radioValue":"C"}]]]}}
let item = { "contentObj": { "picArr": [{ "title": "title", "child": [{ "title": "main", "child": [{ "title": "sub1", "child": [{ "title": "son11", "child": [{ "cardId": "", "title": "aa", "pic_url": "http://staging-teach.cdn.ireadabc.com/88b1cd55a3e2ff70447331078c0e2941.png", "audio_url": "" }, { "cardId": "", "title": "bb", "pic_url": "http://staging-teach.cdn.ireadabc.com/26524d3fa6a060d80664b40cfb6105f6.png", "audio_url": "" }, { "cardId": "", "title": "cc", "pic_url": "http://staging-teach.cdn.ireadabc.com/0cd859af88f946a66313cc06e4628fd2.png", "audio_url": "" }, { "cardId": "", "title": "dd", "pic_url": "http://staging-teach.cdn.ireadabc.com/021d3b3904cb6e675286ac8fcb60da2b.png", "audio_url": "" }] }, { "title": "son12", "child": [{ "cardId": "", "title": "a2", "pic_url": "http://staging-teach.cdn.ireadabc.com/1c897715153af629e0aa1bfbf54472a4.png", "audio_url": "" }, { "cardId": "", "title": "b2", "pic_url": "http://staging-teach.cdn.ireadabc.com/756083716a8ab9f2b6b66331e659845d.png", "audio_url": "" }, { "cardId": "", "title": "c2", "pic_url": "http://staging-teach.cdn.ireadabc.com/6c13e8f14b294ca866205633b9f44891.png", "audio_url": "" }, { "cardId": "", "title": "d2", "pic_url": "http://staging-teach.cdn.ireadabc.com/b3f29929c06d1af57bb6eb08d3f5b0d0.png", "audio_url": "" }] }, { "title": "son13", "child": [{ "cardId": "", "title": "a3", "pic_url": "http://staging-teach.cdn.ireadabc.com/88b1cd55a3e2ff70447331078c0e2941.png", "audio_url": "" }, { "cardId": "", "title": "b3", "pic_url": "http://staging-teach.cdn.ireadabc.com/26524d3fa6a060d80664b40cfb6105f6.png", "audio_url": "" }, { "cardId": "", "title": "c3", "pic_url": "http://staging-teach.cdn.ireadabc.com/88b1cd55a3e2ff70447331078c0e2941.png", "audio_url": "" }, { "cardId": "", "title": "d3", "pic_url": "http://staging-teach.cdn.ireadabc.com/26524d3fa6a060d80664b40cfb6105f6.png", "audio_url": "" }] }] }, { "title": "sub2", "child": [{ "title": "son21", "child": [{ "cardId": "", "title": "q1", "pic_url": "http://staging-teach.cdn.ireadabc.com/fde35aaec618529b0b2b6cb3a18d1f85.png", "audio_url": "" }, { "cardId": "", "title": "w1", "pic_url": "http://staging-teach.cdn.ireadabc.com/0cd859af88f946a66313cc06e4628fd2.png", "audio_url": "" }, { "cardId": "", "title": "e1", "pic_url": "http://staging-teach.cdn.ireadabc.com/021d3b3904cb6e675286ac8fcb60da2b.png", "audio_url": "" }] }, { "title": "son22", "child": [{ "cardId": "", "title": "q2", "pic_url": "http://staging-teach.cdn.ireadabc.com/756083716a8ab9f2b6b66331e659845d.png", "audio_url": "" }, { "cardId": "", "title": "q3", "pic_url": "http://staging-teach.cdn.ireadabc.com/6e9fec092bc8d547be4ad9fd5e01acf1.png", "audio_url": "" }] }, { "title": "son23", "child": [{ "cardId": "", "title": "q4", "pic_url": "http://staging-teach.cdn.ireadabc.com/b0f3c1a415015b254692a5d536b5b3fa.png", "audio_url": "" }, { "cardId": "", "title": "w4", "pic_url": "http://staging-teach.cdn.ireadabc.com/cfa80b631a57638fd27cdef0d5aa2c2d.png", "audio_url": "" }] }] }] }] }] } }
return item;
}
export const itemData = retData();
\ No newline at end of file
......@@ -2,17 +2,9 @@
class Card {
constructor(picItem, cardId) {
this.cardId = cardId;
this.type = GameManager.TYPE_NULL;
if (picItem.radioValue == "A" && picItem.title) {
this.txt = picItem.title;
this.type = GameManager.TYPE_TXT;
} else if (picItem.radioValue == "B" && picItem.pic_url) {
this.img = picItem.pic_url;
this.type = GameManager.TYPE_IMG;
} else if (picItem.radioValue == "C" && picItem.audio_url) {
this.audio = picItem.audio_url;
this.type = GameManager.TYPE_MP3;
}
}
}
class defClass {
......@@ -21,6 +13,7 @@ class defClass {
this.type = type;
this.title = title;
this.child = [];
this.success = [];
}
addChild(child) {
this.child.push(child);
......@@ -62,208 +55,210 @@ class GameManager {
this.parseData();
}
parseData(data) {
let obj = [{
id: 0,
title: "biaoti",
child: [
{
id: 0, title: "zhulei", child: [
{
id: 10,
title: "fenlei1",
child: [
{
id: 101,
title: "sonlei1",
child: [
{
id: 1001,
title: "card1",
title: "卡片1001",
radioValue: "A"
},
{
id: 1002,
title: "card2",
title: "卡片1002",
radioValue: "A"
},
{
id: 1003,
title: "card3",
title: "卡片1003",
radioValue: "A"
},
{
id: 1004,
title: "card4",
title: "卡片1004",
radioValue: "A"
}
]
},
{
id: 101,
title: "sonlei2",
child: [
{
id: 1001,
title: "card1",
title: "卡片1001",
radioValue: "A"
},
{
id: 1002,
title: "card2",
title: "卡片1002",
radioValue: "A"
},
{
id: 1003,
title: "card3",
title: "卡片1003",
radioValue: "A"
},
{
id: 1004,
title: "card4",
title: "卡片1004",
radioValue: "A"
}
]
}
]
},
{
id: 10,
title: "fenlei2",
child: [
{
id: 101,
title: "sonlei3",
child: [
{
id: 1001,
title: "card1",
title: "卡片1001",
radioValue: "A"
},
{
id: 1002,
title: "card2",
title: "卡片1002",
radioValue: "A"
},
{
id: 1003,
title: "card3",
title: "卡片1003",
radioValue: "A"
},
{
id: 1004,
title: "card4",
title: "卡片1004",
radioValue: "A"
}
]
},
{
id: 201,
title: "sonlei4",
child: [
{
id: 1001,
title: "card2",
title: "卡片2001",
radioValue: "A"
},
{
id: 1002,
title: "card2",
title: "卡片2002",
radioValue: "A"
},
{
id: 1003,
title: "card3",
title: "卡片2003",
radioValue: "A"
},
{
id: 1004,
title: "card4",
title: "卡片2004",
radioValue: "A"
}
]
},
{
id: 201,
title: "sonlei5",
child: [
{
id: 1001,
title: "card2",
title: "卡片2001",
radioValue: "A"
},
{
id: 1002,
title: "card2",
title: "卡片2002",
radioValue: "A"
},
{
id: 1003,
title: "card3",
title: "卡片2003",
radioValue: "A"
},
{
id: 1004,
title: "card4",
title: "卡片2004",
radioValue: "A"
}
]
},
{
id: 201,
title: "sonlei6",
child: [
{
id: 1001,
title: "card2",
title: "卡片2001",
radioValue: "A"
},
{
id: 1002,
title: "card2",
title: "卡片2002",
radioValue: "A"
},
{
id: 1003,
title: "card3",
title: "卡片2003",
radioValue: "A"
},
{
id: 1004,
title: "card4",
title: "卡片2004",
radioValue: "A"
}
]
}
]
}
]
}
]
}];
// let obj = [{
// id: 0,
// title: "biaoti",
// child: [
// {
// id: 0, title: "zhulei", child: [
// {
// id: 10,
// title: "fenlei1",
// child: [
// {
// id: 101,
// title: "sonlei1",
// child: [
// {
// id: 1001,
// title: "card1",
// title: "卡片1001",
// radioValue: "A"
// },
// {
// id: 1002,
// title: "card2",
// title: "卡片1002",
// radioValue: "A"
// },
// {
// id: 1003,
// title: "card3",
// title: "卡片1003",
// radioValue: "A"
// },
// {
// id: 1004,
// title: "card4",
// title: "卡片1004",
// radioValue: "A"
// }
// ]
// },
// {
// id: 101,
// title: "sonlei2",
// child: [
// {
// id: 1001,
// title: "card1",
// title: "卡片1001",
// radioValue: "A"
// },
// {
// id: 1002,
// title: "card2",
// title: "卡片1002",
// radioValue: "A"
// },
// {
// id: 1003,
// title: "card3",
// title: "卡片1003",
// radioValue: "A"
// },
// {
// id: 1004,
// title: "card4",
// title: "卡片1004",
// radioValue: "A"
// }
// ]
// }
// ]
// },
// {
// id: 10,
// title: "fenlei2",
// child: [
// {
// id: 101,
// title: "sonlei3",
// child: [
// {
// id: 1001,
// title: "card1",
// title: "卡片1001",
// radioValue: "A"
// },
// {
// id: 1002,
// title: "card2",
// title: "卡片1002",
// radioValue: "A"
// },
// {
// id: 1003,
// title: "card3",
// title: "卡片1003",
// radioValue: "A"
// },
// {
// id: 1004,
// title: "card4",
// title: "卡片1004",
// radioValue: "A"
// }
// ]
// },
// {
// id: 201,
// title: "sonlei4",
// child: [
// {
// id: 1001,
// title: "card2",
// title: "卡片2001",
// radioValue: "A"
// },
// {
// id: 1002,
// title: "card2",
// title: "卡片2002",
// radioValue: "A"
// },
// {
// id: 1003,
// title: "card3",
// title: "卡片2003",
// radioValue: "A"
// },
// {
// id: 1004,
// title: "card4",
// title: "卡片2004",
// radioValue: "A"
// }
// ]
// },
// {
// id: 201,
// title: "sonlei5",
// child: [
// {
// id: 1001,
// title: "card2",
// title: "卡片2001",
// radioValue: "A"
// },
// {
// id: 1002,
// title: "card2",
// title: "卡片2002",
// radioValue: "A"
// },
// {
// id: 1003,
// title: "card3",
// title: "卡片2003",
// radioValue: "A"
// },
// {
// id: 1004,
// title: "card4",
// title: "卡片2004",
// radioValue: "A"
// }
// ]
// },
// {
// id: 201,
// title: "sonlei6",
// child: [
// {
// id: 1001,
// title: "card2",
// title: "卡片2001",
// radioValue: "A"
// },
// {
// id: 1002,
// title: "card2",
// title: "卡片2002",
// radioValue: "A"
// },
// {
// id: 1003,
// title: "card3",
// title: "卡片2003",
// radioValue: "A"
// },
// {
// id: 1004,
// title: "card4",
// title: "卡片2004",
// radioValue: "A"
// }
// ]
// }
// ]
// }
// ]
// }
// ]
// }];
let obj = data.contentObj.picArr;
let fenId = 1;
let sonId = 100;
let cardId = 1000;
......@@ -288,7 +283,6 @@ class GameManager {
}
fenleiClass.addChild(sonleiClass);
}
sonId += 100;
zhuleiClass.addChild(fenleiClass);
}
this._allClass.push(zhuleiClass);
......
......@@ -73,7 +73,7 @@ pg.view = {
if (node.net_url == res) return;
let w = node.width;
let h = node.height;
node.active = false;//
// node.active = false;//
pg.load.loadNetImg(res).then((texture) => {
if (!cc.isValid(node)) return log.i("节点已销毁");
let nw = node.width = texture.width;
......@@ -91,7 +91,9 @@ pg.view = {
node.width = b * nw;
node.height = b * nh;
}
node.active = true;
node.scaleX = node.parent.scaleX;
node.scaleY = node.parent.scaleY;
// node.active = true;
resolve({ w: nw, h: nh });
})
})
......
......@@ -259,6 +259,17 @@ cc.Class({
this._boxItems.push(sonClone);
}
},
setSuccessItemPos(box, item) {
//判断当前item应该放在哪里
let itemA = box.data.id % 100 - 1;//坐标x
let itemB = box.data.success.length - 1;//坐标y
let x = -480;//-290
let addX = 190;
let y = 0;
let addY = -40;
item.x = x + addX * itemA;
item.y = y + addY * itemB;
},
initItems() {
//刷新子类
let son = pg.view.find(this, "items/item");
......@@ -332,6 +343,8 @@ cc.Class({
pg.view.setString(txt, data.txt);
pg.view.setString(pg.view.find(success, "txt"), data.txt);
pg.view.setNetImg(icon, data.img);
pg.view.setNetImg(pg.view.find(success, "icon"), data.img);
switch (item.moveState) {
case 1:
......@@ -373,6 +386,8 @@ cc.Class({
item.on(cc.Node.EventType.TOUCH_CANCEL, this.onCancelItem, this);
},
onStartItem(touch) {
let item = touch.target;
if (item.moveState == 2) return;
//判断是否是在原地并没有到处移动
this._startPos = cc.v2(touch.target.x, touch.target.y);
......@@ -386,6 +401,7 @@ cc.Class({
//3.失败效果--
onEndItem(touch) {
let item = touch.target;
if (item.moveState == 2) return;
let touchPos = touch.getLocation();
//判断是否是在原地并没有到处移动
if (this.checkCollider({
......@@ -415,6 +431,9 @@ cc.Class({
if (successed) {
item.moveState = 2;
this.updateItem(item);
box.data.success.push(item);
this.setSuccessItemPos(box, item);
//检测是否全部完成
} else {
item.moveState = 3;
this.updateItem(item);
......@@ -423,15 +442,15 @@ cc.Class({
this.moveItem(item, this._startPos);
}, 100);
}
} else {
this.moveItem(item, this._startPos);
}
},
onMoveItem(touch) {
let item = touch.target;
if (item.moveState == 2) return;
//获取到的location是 当前点击的位置 而不是按钮原本应该所在的位置。
let touchPos = touch.getLocation();
let item = touch.target;
//判断是否是在原地并没有到处移动
if (this.checkCollider({
x: touchPos.x - 1280 / 2,
......@@ -450,6 +469,8 @@ cc.Class({
touch.target.y = touchPos.y - 720 / 2;
},
onCancelItem(touch) {
let item = touch.target;
if (item.moveState == 2) return;
//碰撞失败退回原位置
touch.target.x = this._startPos.x;
touch.target.y = this._startPos.y;
......
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