Commit d0773456 authored by 李维's avatar 李维

Bug fix

parent 46aca9f7
......@@ -2,47 +2,47 @@
<nz-form-item>
<nz-form-label [nzSpan]="2" >左上</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.leftTop"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('leftTop')" [picUrl]="items.leftTop"
(imageUploaded)="onImageUploadSuccess($event, items, 'leftTop')"></app-upload-image-with-preview>
</nz-form-control>
<nz-form-label [nzSpan]="2" >中上</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.middleTop"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('middleTop')" [picUrl]="items.middleTop"
(imageUploaded)="onImageUploadSuccess($event, items, 'middleTop')"></app-upload-image-with-preview>
</nz-form-control>
<nz-form-label [nzSpan]="2" >右上</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.rightTop"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('rightTop')" [picUrl]="items.rightTop"
(imageUploaded)="onImageUploadSuccess($event, items, 'rightTop')"></app-upload-image-with-preview>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="2" >左中</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.leftMiddle"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('leftMiddle')" [picUrl]="items.leftMiddle"
(imageUploaded)="onImageUploadSuccess($event, items, 'leftMiddle')"></app-upload-image-with-preview>
</nz-form-control>
<div nz-col nzSpan="8"></div>
<nz-form-label [nzSpan]="2" >右中</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.rightMiddle"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('rightMiddle')" [picUrl]="items.rightMiddle"
(imageUploaded)="onImageUploadSuccess($event, items, 'rightMiddle')"></app-upload-image-with-preview>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="2" >左下</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.leftBottom"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('leftBottom')" [picUrl]="items.leftBottom"
(imageUploaded)="onImageUploadSuccess($event, items, 'leftBottom')"></app-upload-image-with-preview>
</nz-form-control>
<nz-form-label [nzSpan]="2" >中下</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.middleBottom"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('middleBottom')" [picUrl]="items.middleBottom"
(imageUploaded)="onImageUploadSuccess($event, items, 'middleBottom')"></app-upload-image-with-preview>
</nz-form-control>
<nz-form-label [nzSpan]="2">右下</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview style="width: 100%" [picUrl]="items.rightBottom"
<app-upload-image-with-preview style="width: 100%" canDelete="true" (delete)="deletePic('rightBottom')" [picUrl]="items.rightBottom"
(imageUploaded)="onImageUploadSuccess($event, items, 'rightBottom')"></app-upload-image-with-preview>
</nz-form-control>
</nz-form-item>
......
......@@ -16,4 +16,8 @@ export class BackgroundUploadComponent {
this.change.emit(items)
}
deletePic(key) {
this.items[key] = ""
this.change.emit(this.items)
}
}
......@@ -172,9 +172,9 @@
<div style="float: left; margin-left: 10px;">
<div>组合</div>
<div>
<nz-select *ngFor="let part of item.combin; let i = index" [(ngModel)]="item.combin[i]" style="float: left; margin-right: 5px;" (ngModelChange)="handlePartChange($event, item, i)">
<nz-option [nzValue]="-1" [nzLabel]="'L-' + bgItem.wordLeft_text"></nz-option>
<nz-option [nzValue]="-2" [nzLabel]="'R-' + bgItem.wordRight_text"></nz-option>
<nz-select *ngFor="let part of item.combin; let i = index" [(ngModel)]="item.combin[i]" style="float: left; margin-right: 5px; width: 150px;" (ngModelChange)="handlePartChange($event, item, i)">
<nz-option [nzDisabled]="checkDisabel(item.combin, -1, i)" [nzValue]="-1" [nzLabel]="'L-' + bgItem.wordLeft_text"></nz-option>
<nz-option [nzDisabled]="checkDisabel(item.combin, -2, i)" [nzValue]="-2" [nzLabel]="'R-' + bgItem.wordRight_text"></nz-option>
<nz-option *ngFor="let hot of hotZoneArr; let j = index;" [nzValue]="j" [nzLabel]="(j + 1) + '-' + hot.text"></nz-option>
</nz-select>
</div>
......
......@@ -79,7 +79,7 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
ngOnInit() {
if(!this.bgItem.url){
this.bgItem.url = "def_window"
this.bgItem.url = ""
}
this.initListener();
this.update();
......@@ -93,6 +93,20 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
}
checkDisabel(items, val, index) {
let valIndex_1 = items.indexOf(-1)
let valIndex_2 = items.indexOf(-2)
if(valIndex_1 == index || valIndex_2 == index) {
return false
} else {
if(valIndex_1 == -1 && valIndex_2 == -1 ) {
return false
} else {
return true
}
}
}
onBackgroundUploadSuccess(e) {
this.bgItem.url = e.url;
this.refreshBackground(() => {
......@@ -206,11 +220,11 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
item.x = saveRect.x / saveData.scale + newRect.x
item.y = saveRect.y / saveData.scale + newRect.y
});
// item.image_url = saveData.media.image_url
item.image_url = saveData.media.image_url
// item.text = saveData.media.text
// item.type = saveData.media.type
item.audio_url = saveData.media.audio_url?saveData.media.audio_url:""
item.image_url = "assets/play/bg_70_40.png"
// item.image_url = "assets/play/bg_70_40.png"
// item.text = ""
item.type = "Image"
} else {
......
......@@ -23,7 +23,7 @@
</div>
</div>
</nz-upload>
<div class="p-btn-delete" *ngIf="canDelete"
<div class="p-btn-delete" *ngIf="picUrl && canDelete"
nz-popconfirm nzTitle="Are you sure ?"
(nzOnConfirm)="onDelete()"
>
......
......@@ -60,8 +60,8 @@
.p-btn-delete {
position: absolute;
right: -0.5rem;
top: -0.5rem;
right: -2rem;
top: 0;
width: 2rem;
height: 2rem;
border: 0.2rem solid white;
......@@ -70,6 +70,7 @@
background-color: #fb781a;
color: white;
text-align: center;
line-height: 2rem !important;
}
.p-upload-progress-bg {
......@@ -95,7 +96,6 @@
}
}
:host ::ng-deep .ant-upload {
display: block;
}
......@@ -34,10 +34,12 @@ export class UploadImageWithPreviewComponent implements OnDestroy, OnChanges {
constructor(private nzMessageService: NzMessageService) {
this.uploadUrl = (<any> window).courseware.uploadUrl();
console.log("constructor", this.uploadUrl)
this.uploadData = (<any> window).courseware.uploadData();
window['air'].getUploadCallback = (url, data) => {
this.uploadUrl = url;
this.uploadData = data;
console.log("getUploadCallback", this.uploadUrl)
};
}
ngOnChanges() {
......
......@@ -12,7 +12,7 @@
></app-custom-hot-zone>
</div>
</div>
<div class="card-item-content">
<div class="card-item-content" style="margin-top: 10px;">
<div class="title">背景 设置</div>
<div class="section">
<app-background-upload
......
......@@ -95,3 +95,8 @@
font-family: 'MMTextBook-Italic';
src: url("../../assets/default/font/MMTextBook/MMTextBook-Italic.otf") ;
}
@font-face{
font-family: 'FuturaBT-Medium';
src: url("../../assets/play/font/Futura.ttc") ;
}
......@@ -273,7 +273,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
})
element.ref.x = this.g_partTitle_x - 20 * this.g_mapScale + (57*this.g_mapScale)/2;
let text = this.g_cartoon.createLabel(this.g_formData.bgItem.NO, "BerlinSansFBDemi-Bold", "#F7CB47", 48)
let text = this.g_cartoon.createLabel(this.g_formData.bgItem.NO, "BerlinSansFBDemi-Bold", "#FFFFFF", 48)
element.ref.addChild(text)
let partBG = this.g_cartoon.createCartoonElementImageFunc("part-title-background", "part_number_bg", (w, h)=>{
......@@ -294,7 +294,7 @@ export class PlayComponent implements OnInit, OnDestroy {
initTitle_Main(){
let labelWidth = 0
let text = this.g_cartoon.createCartoonElementLabelFunc("main-title", this.g_formData.bgItem.mainText, "FuturaBT-Bold", "#000000", 36 * this.g_mapScale, (w, h)=>{
let text = this.g_cartoon.createCartoonElementLabelFunc("main-title", this.g_formData.bgItem.mainText, "FuturaBT-Medium", "#000000", 36 * this.g_mapScale, (w, h)=>{
labelWidth = w/2
return {
x: this.g_partTitle_x - 20 * this.g_mapScale + labelWidth * this.g_mapScale,
......@@ -557,6 +557,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
let startX = -70
let totalWidth = 0
let answerIndex = []
this.m_answerAll.push([])
......@@ -569,11 +570,19 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_answerAll[index].push(`word-part-${index}-${item.key}-${partIndex}`)
let textShow = this.g_cartoon.createCartoonElementLabel(`word-part-${index}-${item.key}-${partIndex}`, item.value, "MMTextBook-Bold", color, 48, startX, 0)
textShow.isShown = false;
textShow.ref.alpha = 0;
textShow.ref.alpha = 1;
textShow.ref.x = startX + textShow.ref.width / 2
startX += textShow.ref.width
totalWidth += textShow.ref.width
element.ref.addChild(textShow.ref)
})
console.log(totalWidth)
startX = -totalWidth / 2 + 20
this.m_answerAll[index].forEach(element => {
let el = this.g_cartoon.getCartoonElement(element)
el.ref.x = startX + el.ref.width / 2
startX += el.ref.width
});
this.subscribeMapUpEvent(element.id, ()=>{
if(!this.m_elementDraged) {
......@@ -596,6 +605,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if(!textShow.isShown) {
textShow.isShown = true;
textShow.ref.alpha = 1;
this.g_cartoon.playAudio("sm-choice-correct")
break;
}
}
......@@ -751,8 +761,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
initBackgroundSide() {
const map = {
calcPosition(position, width, height) {
let map = {
leftTop: {x: 0, y: 0},
middleTop: {x: this.g_canvasWidth / 2, y: 0},
rightTop: {x: this.g_canvasWidth, y: 0},
......@@ -762,17 +772,52 @@ export class PlayComponent implements OnInit, OnDestroy {
middleBottom: {x: this.g_canvasWidth / 2, y: this.g_canvasHeight},
rightBottom: {x: this.g_canvasWidth, y: this.g_canvasHeight}
}
switch(position) {
case "leftTop":
map["leftTop"].x += width * this.g_mapScale / 2,
map["leftTop"].y += height * this.g_mapScale / 2;
return map["leftTop"];
case "middleTop":
map["middleTop"].y += height * this.g_mapScale / 2;
return map["middleTop"];
case "rightTop":
map["rightTop"].x -= width * this.g_mapScale / 2,
map["rightTop"].y += height * this.g_mapScale / 2;
return map["rightTop"];
case "leftMiddle":
map["leftMiddle"].x += height * this.g_mapScale / 2;
return map["leftMiddle"];
case "rightMiddle":
map["rightMiddle"].x -= height * this.g_mapScale / 2;
return map["rightMiddle"];
case "leftBottom":
map["leftBottom"].x += width * this.g_mapScale / 2,
map["leftBottom"].y -= height * this.g_mapScale / 2;
return map["leftBottom"];
case "middleBottom":
map["middleBottom"].y -= height * this.g_mapScale / 2;
return map["middleBottom"];
case "rightBottom":
map["rightBottom"].x -= width * this.g_mapScale / 2,
map["rightBottom"].y -= height * this.g_mapScale / 2;
return map["rightBottom"];
}
}
initBackgroundSide() {
for(let key in this.g_formData.bgImages) {
if(!this.g_formData.bgImages[key]) {
continue
}
let ele = this.g_cartoon.createCartoonElementImageFunc(`background-side-${key}`, this.g_formData.bgImages[key], (w, h)=>{
return {
sx: 1,
sy: 1,
sx: this.g_mapScale,
sy: this.g_mapScale,
}
}, (w, h)=>{
return map[key]
return this.calcPosition(key, w, h)
})
console.log(this.g_formData.bgImages[key])
this.render(ele.ref, -1)
......
export const defaultData = {
"version": "1.0",
"version": "1.1",
"dataKey": "DataKey_YM4-11",
"dataArray": [
......@@ -8,7 +8,7 @@ export const defaultData = {
],
"bgItem": {
"url": "",
"url": "assets/play/hotZooCard/defalut_bg.png",
"questions": [
],
......@@ -32,7 +32,7 @@ export const defaultData = {
}
export const demoData = {
version: "1.0",
version: "1.1",
dataKey: "DataKey_YM4-11",
dataArray: [],
hotZoneItemArr: [
......
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