Commit 349cbbd5 authored by 李维's avatar 李维

添加页头页尾图片配置

parent 52cca651
...@@ -866,7 +866,7 @@ ...@@ -866,7 +866,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1920, "width": 1920,
"height": 138 "height": 142
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -878,7 +878,7 @@ ...@@ -878,7 +878,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
531, 529,
0, 0,
0, 0,
0, 0,
...@@ -979,9 +979,7 @@ ...@@ -979,9 +979,7 @@
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": null,
"__uuid__": "cddea2ff-d29d-46e9-a62d-22fd51f0514a"
},
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
"_fillType": 0, "_fillType": 0,
...@@ -1201,9 +1199,7 @@ ...@@ -1201,9 +1199,7 @@
], ],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": null,
"__uuid__": "ed9aebd7-be72-4a8c-9cf0-05e55d7e82e5"
},
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
"_fillType": 0, "_fillType": 0,
......
import { import {
asyncDelay,
onHomeworkFinish,
playAudioByUrl, playAudioByUrl,
loadImageByUrl,
getSprNode, getSprNode,
} from "../script/util_DG_FAF"; } from "../script/util_DG_FAF";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG_FAF"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG_FAF";
...@@ -34,6 +33,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -34,6 +33,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(this.data); console.log(this.data);
this.initSize(); this.initSize();
this.initEventListener(); this.initEventListener();
this.initHeaderAndFooter();
await this.initHotZoneBg(); await this.initHotZoneBg();
this.initHotZoneItem(); this.initHotZoneItem();
} }
...@@ -107,7 +107,26 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -107,7 +107,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 检查是否可以提交 // 检查是否可以提交
this.checkCanSubmit(); this.checkCanSubmit();
}) })
}
// 初始化头部和底部图片
initHeaderAndFooter() {
loadImageByUrl(this.data.header_image_url, (sf)=>{
const imgNode = cc.find("Canvas/Header/img");
const sfSize = sf.getOriginalSize();
const sx = imgNode.parent.width / sfSize.width;
const sy = imgNode.parent.height / sfSize.height;
imgNode.scale = Math.min(sx, sy)
imgNode.getComponent(cc.Sprite).spriteFrame = sf;
})
loadImageByUrl(this.data.footer_image_url, (sf)=>{
const imgNode = cc.find("Canvas/Footer/img");
const sfSize = sf.getOriginalSize();
const sx = imgNode.parent.width / sfSize.width;
const sy = imgNode.parent.height / sfSize.height;
imgNode.scale = Math.min(sx, sy)
imgNode.getComponent(cc.Sprite).spriteFrame = sf;
})
} }
hotZoneBg = null; hotZoneBg = null;
......
This diff is collapsed.
...@@ -113,6 +113,16 @@ export function playAudioByUrl(audio_url, cb=null) { ...@@ -113,6 +113,16 @@ export function playAudioByUrl(audio_url, cb=null) {
} }
} }
export function loadImageByUrl(image_url, cb=null) {
if (image_url) {
cc.assetManager.loadRemote(image_url, (err, texture) => {
if (cb) {
const spriteFrame = new cc.SpriteFrame(texture)
cb(spriteFrame);
}
});
}
}
export function btnClickAnima(btn, time=0.15, rate=1.05) { export function btnClickAnima(btn, time=0.15, rate=1.05) {
btn.tmpScale = btn.scale; btn.tmpScale = btn.scale;
......
...@@ -3,6 +3,26 @@ ...@@ -3,6 +3,26 @@
<app-formula-input [(ngfModel)]="item.title" (ngfBlur)="save()"></app-formula-input><br> --> <app-formula-input [(ngfModel)]="item.title" (ngfBlur)="save()"></app-formula-input><br> -->
<div style="padding: 20px;"> <div style="padding: 20px;">
<div style="margin: 30px;"></div> <div style="margin: 30px;"></div>
<h2 style="margin-top: 10px;">页头-页尾配置</h2>
<div style="font-size: 16px; border: 2px solid #ccc; border-radius: 10px; padding: 10px; display: flex; height: 180px;">
<div style="width: 200px; height: 112px;">
<h5>页头图片:</h5>
<app-upload-image-with-preview
[picUrl]="item.header_image_url"
(imageUploaded)="onImageUploadSuccess($event, 'header_image_url', item)">
</app-upload-image-with-preview>
</div>
<div style="width: 200px; height: 112px; margin-left: 20px;">
<h5>页尾图片:</h5>
<app-upload-image-with-preview
[picUrl]="item.footer_image_url"
(imageUploaded)="onImageUploadSuccess($event, 'footer_image_url', item)">
</app-upload-image-with-preview>
</div>
</div>
<h2 >热区位置配置:</h2> <h2 >热区位置配置:</h2>
<app-custom-hot-zone <app-custom-hot-zone
[bgItem]="item.bgItem" [bgItem]="item.bgItem"
...@@ -38,21 +58,21 @@ ...@@ -38,21 +58,21 @@
<thead> <thead>
<tr> <tr>
<th nzWidth="100px" nzAlign="center">序号</th> <th nzWidth="100px" nzAlign="center">序号</th>
<th nzWidth="200px" nzAlign="center">正确答案</th> <th *ngIf="it.hotZoneType == '3' || it.hotZoneType == '4'" nzWidth="100px" nzAlign="center">正确答案</th>
<th *ngIf="it.hotZoneType == '4'" nzWidth="200px" nzAlign="center">分数</th> <th *ngIf="it.hotZoneType == '4'" nzWidth="100px" nzAlign="center">分数</th>
<th *ngIf="it.hotZoneType == '0'">文字</th> <th *ngIf="it.hotZoneType == '0'">文字</th>
<th *ngIf="it.hotZoneType == '1'">图片</th> <th *ngIf="it.hotZoneType == '1'">图片</th>
<th *ngIf="it.hotZoneType == '3' || it.hotZoneType == '4'">热区索引</th> <th *ngIf="it.hotZoneType == '3' || it.hotZoneType == '4'">热区索引</th>
<th nzWidth="10%">操作</th> <th nzWidth="150px">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of contentTable.data; let i = index;"> <tr *ngFor="let data of contentTable.data; let i = index;">
<ng-container *ngIf="!(editCache[i] && editCache[i].edit); else editTemplate"> <ng-container *ngIf="!(editCache[i] && editCache[i].edit); else editTemplate">
<td nzWidth="100px" nzAlign="center">{{ i + 1 }}</td> <td nzWidth="100px" nzAlign="center">{{ i + 1 }}</td>
<td *ngIf="it.hotZoneType == '3'" nzWidth="200px" nzAlign="center">{{ data.isCorrect?'正确':'错误' }}</td> <td *ngIf="it.hotZoneType == '3'" nzWidth="100px" nzAlign="center">{{ data.isCorrect?'正确':'错误' }}</td>
<td *ngIf="it.hotZoneType == '4'" nzWidth="200px" nzAlign="center">{{ data.isCheck?'勾选':'不勾选' }}</td> <td *ngIf="it.hotZoneType == '4'" nzWidth="100px" nzAlign="center">{{ data.isCheck?'勾选':'不勾选' }}</td>
<td *ngIf="it.hotZoneType == '4'" nzWidth="200px" nzAlign="center">{{ data.score }}</td> <td *ngIf="it.hotZoneType == '4'" nzWidth="100px" nzAlign="center">{{ data.score }}</td>
<td *ngIf="it.hotZoneType == '0'">{{ data.text }}</td> <td *ngIf="it.hotZoneType == '0'">{{ data.text }}</td>
<td *ngIf="it.hotZoneType == '1'"> <td *ngIf="it.hotZoneType == '1'">
<img *ngIf="data.image_url" [src]="data.image_url" width="200" height="200" style="object-fit: contain;"/> <img *ngIf="data.image_url" [src]="data.image_url" width="200" height="200" style="object-fit: contain;"/>
...@@ -61,7 +81,7 @@ ...@@ -61,7 +81,7 @@
<td *ngIf="it.hotZoneType == '3' || it.hotZoneType == '4'"> <td *ngIf="it.hotZoneType == '3' || it.hotZoneType == '4'">
<span style="margin-left: 10px;">索引: {{data.selectHotZoneIndex + 1}} 热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[data.selectHotZoneIndex] ? item.hotZoneItemArr[data.selectHotZoneIndex].itemName : "未配置"}}</span> <span style="margin-left: 10px;">索引: {{data.selectHotZoneIndex + 1}} 热区名:{{item.hotZoneItemArr && item.hotZoneItemArr[data.selectHotZoneIndex] ? item.hotZoneItemArr[data.selectHotZoneIndex].itemName : "未配置"}}</span>
</td> </td>
<td nzWidth="10%"> <td nzWidth="150px">
<a (click)="startHotZoneConfigEdit(i, data)">编辑</a> <a (click)="startHotZoneConfigEdit(i, data)">编辑</a>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<a (click)="deleteHotZoneConfigItem(it, i)">删除</a> <a (click)="deleteHotZoneConfigItem(it, i)">删除</a>
...@@ -69,13 +89,13 @@ ...@@ -69,13 +89,13 @@
</ng-container> </ng-container>
<ng-template #editTemplate> <ng-template #editTemplate>
<td nzWidth="100px" nzAlign="center">{{ i + 1 }}</td> <td nzWidth="100px" nzAlign="center">{{ i + 1 }}</td>
<td *ngIf="it.hotZoneType == '3'" nzWidth="200px" nzAlign="center"> <td *ngIf="it.hotZoneType == '3'" nzWidth="100px" nzAlign="center">
<label nz-checkbox [(ngModel)]="editCache[i].data.isCorrect"></label> <label nz-checkbox [(ngModel)]="editCache[i].data.isCorrect"></label>
</td> </td>
<td *ngIf="it.hotZoneType == '4'" nzWidth="200px" nzAlign="center"> <td *ngIf="it.hotZoneType == '4'" nzWidth="100px" nzAlign="center">
<label nz-checkbox [(ngModel)]="editCache[i].data.isCheck"></label> <label nz-checkbox [(ngModel)]="editCache[i].data.isCheck"></label>
</td> </td>
<td *ngIf="it.hotZoneType == '4'" nzWidth="200px"> <td *ngIf="it.hotZoneType == '4'" nzWidth="100px">
<input type="text" nz-input [(ngModel)]="editCache[i].data.score" /> <input type="text" nz-input [(ngModel)]="editCache[i].data.score" />
</td> </td>
<td *ngIf="it.hotZoneType == '0'"> <td *ngIf="it.hotZoneType == '0'">
...@@ -98,7 +118,7 @@ ...@@ -98,7 +118,7 @@
<td nzWidth="10%"> <td nzWidth="10%">
<a (click)="saveHotZoneConfigEdit(i, it)" class="save">保存</a> <a (click)="saveHotZoneConfigEdit(i, it)" class="save">保存</a>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<a nz-popconfirm nzPopconfirmTitle="Sure to cancel?" (nzOnConfirm)="cancelHotZoneConfigEdit(i, data)">取消</a> <a nz-popconfirm nzPopconfirmTitle="确定取消?" (nzOnConfirm)="cancelHotZoneConfigEdit(i, data)">取消</a>
</td> </td>
</ng-template> </ng-template>
</tr> </tr>
......
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