Commit 80f932c2 authored by liujiangnan's avatar liujiangnan

fix: 默认数据展示逻辑

parent 726d7e43
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ElementRef, ViewChild} from '@angular/core'; import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ElementRef, ViewChild } from '@angular/core';
import { defaultData } from '../../assets/default/formData/defaultData_ym413.js' import { defaultData } from '../../assets/default/formData/defaultData_ym413.js'
@Component({ @Component({
...@@ -37,7 +37,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -37,7 +37,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
longAudio_url; longAudio_url;
bgImages: Object = {leftTop:"", middleTop:"", rightTop:"", leftMiddle:"", rightMiddle:"", leftBottom:"", middleBottom:"", rightBottom:""}; bgImages: Object = { leftTop: "", middleTop: "", rightTop: "", leftMiddle: "", rightMiddle: "", leftBottom: "", middleBottom: "", rightBottom: "" };
KEY = 'DataKey_YM4-13'; KEY = 'DataKey_YM4-13';
dataLoaded = false; dataLoaded = false;
...@@ -51,9 +51,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -51,9 +51,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
@Output() @Output()
update = new EventEmitter(); update = new EventEmitter();
@ViewChild('hotZooLeftEL', {static: false }) hotZooLeftEL; @ViewChild('hotZooLeftEL', { static: false }) hotZooLeftEL;
@ViewChild('hotZooMiddleEL', {static: false }) hotZooMiddleEL; @ViewChild('hotZooMiddleEL', { static: false }) hotZooMiddleEL;
@ViewChild('hotZooRightEL', {static: false }) hotZooRightEL; @ViewChild('hotZooRightEL', { static: false }) hotZooRightEL;
constructor(private appRef: ApplicationRef) { constructor(private appRef: ApplicationRef) {
...@@ -62,23 +62,25 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -62,23 +62,25 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {};
this.item.contentObj = {}; this.item.contentObj = {};
const getData = (<any> window).courseware.getData; const getData = (<any>window).courseware.getData;
getData((data) => { getData((data) => {
console.log("读取数据", data) console.log("读取数据1", data);
if (data) { if (data) {
this.item = data; if (data.contentObj && data.contentObj.data) {
this.item = data.contentObj.data;
} else {
this.item = data;
}
} else { } else {
this.item = {}; this.item = {};
} }
if ( !this.item.contentObj ) {
this.item.contentObj = {};
}
this.init(); this.init();
this.refresh(); this.refresh();
this.dataLoaded = true; this.dataLoaded = true;
}, this.KEY); }, this.KEY);
} }
ngOnChanges() { ngOnChanges() {
} }
...@@ -88,11 +90,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -88,11 +90,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
addHotZoo(pos) { addHotZoo(pos) {
if(pos==1) { if (pos == 1) {
this.hotZooLeftEL.addHotZoo() this.hotZooLeftEL.addHotZoo()
} else if(pos==2) { } else if (pos == 2) {
this.hotZooMiddleEL.addHotZoo() this.hotZooMiddleEL.addHotZoo()
} else if(pos==3) { } else if (pos == 3) {
this.hotZooRightEL.addHotZoo() this.hotZooRightEL.addHotZoo()
} }
} }
...@@ -109,60 +111,60 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -109,60 +111,60 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
deleteHotZoo(pos, index) { deleteHotZoo(pos, index) {
if(pos == 1) { if (pos == 1) {
this.hotZooLeftEL.deleteHotZoo(index) this.hotZooLeftEL.deleteHotZoo(index)
} else if(pos == 2) { } else if (pos == 2) {
this.hotZooMiddleEL.deleteHotZoo(index) this.hotZooMiddleEL.deleteHotZoo(index)
} else if(pos == 3) { } else if (pos == 3) {
this.hotZooRightEL.deleteHotZoo(index) this.hotZooRightEL.deleteHotZoo(index)
} }
} }
getQuestionWord(pos, combin) { getQuestionWord(pos, combin) {
let str = "" let str = ""
if(pos == 1) { if (pos == 1) {
combin.forEach(element => { combin.forEach(element => {
if(element == -1) { if (element == -1) {
str += this.wordLeft_text str += this.wordLeft_text
} else { } else {
str += this.hotZoneItemArrLeft[element] && this.hotZoneItemArrLeft[element]["media"] && this.hotZoneItemArrLeft[element]["media"]["text"]?this.hotZoneItemArrLeft[element]["media"]["text"]:""; str += this.hotZoneItemArrLeft[element] && this.hotZoneItemArrLeft[element]["media"] && this.hotZoneItemArrLeft[element]["media"]["text"] ? this.hotZoneItemArrLeft[element]["media"]["text"] : "";
} }
}); });
} else if(pos == 2) { } else if (pos == 2) {
combin.forEach(element => { combin.forEach(element => {
if(element == -1) { if (element == -1) {
str += this.wordMiddle_text str += this.wordMiddle_text
} else { } else {
str += this.hotZoneItemArrMiddle[element] && this.hotZoneItemArrMiddle[element]["media"] && this.hotZoneItemArrMiddle[element]["media"]["text"]?this.hotZoneItemArrMiddle[element]["media"]["text"]:""; str += this.hotZoneItemArrMiddle[element] && this.hotZoneItemArrMiddle[element]["media"] && this.hotZoneItemArrMiddle[element]["media"]["text"] ? this.hotZoneItemArrMiddle[element]["media"]["text"] : "";
} }
}); });
} else if(pos == 3) { } else if (pos == 3) {
combin.forEach(element => { combin.forEach(element => {
if(element == -1) { if (element == -1) {
str += this.wordRight_text str += this.wordRight_text
} else { } else {
str += this.hotZoneItemArrRight[element] && this.hotZoneItemArrRight[element]["media"] && this.hotZoneItemArrRight[element]["media"]["text"]?this.hotZoneItemArrRight[element]["media"]["text"]:""; str += this.hotZoneItemArrRight[element] && this.hotZoneItemArrRight[element]["media"] && this.hotZoneItemArrRight[element]["media"]["text"] ? this.hotZoneItemArrRight[element]["media"]["text"] : "";
} }
}); });
} }
return str return str
} }
saveData(e, pos){ saveData(e, pos) {
if(pos == 1) { if (pos == 1) {
this.bgItemLeft = e.bgItem; this.bgItemLeft = e.bgItem;
this.hotZoneItemArrLeft.length = 0; this.hotZoneItemArrLeft.length = 0;
e.hotZoneItemArr.forEach(item => { e.hotZoneItemArr.forEach(item => {
this.hotZoneItemArrLeft.push(item) this.hotZoneItemArrLeft.push(item)
}); });
} else if(pos == 2) { } else if (pos == 2) {
this.bgItemMiddle = e.bgItem; this.bgItemMiddle = e.bgItem;
this.hotZoneItemArrMiddle.length = 0; this.hotZoneItemArrMiddle.length = 0;
e.hotZoneItemArr.forEach(item => { e.hotZoneItemArr.forEach(item => {
this.hotZoneItemArrMiddle.push(item) this.hotZoneItemArrMiddle.push(item)
}); });
} else if(pos == 3) { } else if (pos == 3) {
this.bgItemRight = e.bgItem; this.bgItemRight = e.bgItem;
this.hotZoneItemArrRight.length = 0; this.hotZoneItemArrRight.length = 0;
e.hotZoneItemArr.forEach(item => { e.hotZoneItemArr.forEach(item => {
...@@ -173,79 +175,75 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -173,79 +175,75 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
init() { init() {
const fields = ["hotZoneItemArrLeft", "questionsLeft", "bgItemLeft", "hotZoneItemArrMiddle", "questionsMiddle", "bgItemMiddle", "hotZoneItemArrRight", "questionsRight", "bgItemRight", "bgImages", "title", "wordLeft_text", "wordLeft_audio_url", "wordMiddle_text", "wordMiddle_audio_url", "wordRight_text", "wordRight_audio_url","longAudio_url"] const fields = ["hotZoneItemArrLeft", "questionsLeft", "bgItemLeft", "hotZoneItemArrMiddle", "questionsMiddle", "bgItemMiddle", "hotZoneItemArrRight", "questionsRight", "bgItemRight", "bgImages", "title", "wordLeft_text", "wordLeft_audio_url", "wordMiddle_text", "wordMiddle_audio_url", "wordRight_text", "wordRight_audio_url", "longAudio_url"]
if(typeof(this.item.contentObj.hotZoneItemArrLeft) == undefined || typeof(this.item.contentObj.hotZoneItemArrRight) == undefined || typeof(this.item.contentObj.bgItem) == undefined || typeof(this.item.contentObj.bgImages) == undefined || this.item.contentObj.version != defaultData.version) { if(!this.item.contentObj){
console.log("Init defalue data") this.item.contentObj = defaultData;
this.item.contentObj = defaultData
this.copyFieldsValue(fields, defaultData, this)
} else {
console.log("Data loaded")
this.copyFieldsValue(fields, this.item.contentObj, this)
} }
this.copyFieldsValue(fields, this.item.contentObj, this)
} }
addQustion(pos) { addQustion(pos) {
if(pos == 1) { if (pos == 1) {
this.questionsLeft.push({ this.questionsLeft.push({
number: 2, number: 2,
combin: [0, 0], combin: [0, 0],
_combin: [0, 0] _combin: [0, 0]
}) })
} else if(pos == 2) { } else if (pos == 2) {
this.questionsMiddle.push({ this.questionsMiddle.push({
number: 2, number: 2,
combin: [0, 0], combin: [0, 0],
_combin: [0, 0] _combin: [0, 0]
}) })
} else if(pos == 3) { } else if (pos == 3) {
this.questionsRight.push({ this.questionsRight.push({
number: 2, number: 2,
combin: [0, 0], combin: [0, 0],
_combin: [0, 0] _combin: [0, 0]
}) })
} }
this.save() this.save()
} }
handleMoveItemUp(pos, index) { handleMoveItemUp(pos, index) {
if(pos==1) { if (pos == 1) {
if (index != 0) { if (index != 0) {
this.questionsLeft[index] = this.questionsLeft.splice(index - 1, 1, this.questionsLeft[index])[0]; this.questionsLeft[index] = this.questionsLeft.splice(index - 1, 1, this.questionsLeft[index])[0];
} else { } else {
this.questionsLeft.push(this.questionsLeft.shift()); this.questionsLeft.push(this.questionsLeft.shift());
} }
} else if(pos==2) { } else if (pos == 2) {
if (index != 0) { if (index != 0) {
this.questionsMiddle[index] = this.questionsMiddle.splice(index - 1, 1, this.questionsMiddle[index])[0]; this.questionsMiddle[index] = this.questionsMiddle.splice(index - 1, 1, this.questionsMiddle[index])[0];
} else { } else {
this.questionsMiddle.push(this.questionsMiddle.shift()); this.questionsMiddle.push(this.questionsMiddle.shift());
} }
} else if(pos==3) { } else if (pos == 3) {
if (index != 0) { if (index != 0) {
this.questionsRight[index] = this.questionsRight.splice(index - 1, 1, this.questionsRight[index])[0]; this.questionsRight[index] = this.questionsRight.splice(index - 1, 1, this.questionsRight[index])[0];
} else { } else {
this.questionsRight.push(this.questionsRight.shift()); this.questionsRight.push(this.questionsRight.shift());
} }
} }
this.save() this.save()
} }
handleMoveItemDown(pos, index) { handleMoveItemDown(pos, index) {
if(pos == 1) { if (pos == 1) {
if (index != this.questionsLeft.length - 1) { if (index != this.questionsLeft.length - 1) {
this.questionsLeft[index] = this.questionsLeft.splice(index + 1, 1, this.questionsLeft[index])[0]; this.questionsLeft[index] = this.questionsLeft.splice(index + 1, 1, this.questionsLeft[index])[0];
} else { } else {
this.questionsLeft.unshift(this.questionsLeft.splice(index, 1)[0]); this.questionsLeft.unshift(this.questionsLeft.splice(index, 1)[0]);
} }
} else if(pos == 2) { } else if (pos == 2) {
if (index != this.questionsMiddle.length - 1) { if (index != this.questionsMiddle.length - 1) {
this.questionsMiddle[index] = this.questionsMiddle.splice(index + 1, 1, this.questionsMiddle[index])[0]; this.questionsMiddle[index] = this.questionsMiddle.splice(index + 1, 1, this.questionsMiddle[index])[0];
} else { } else {
this.questionsMiddle.unshift(this.questionsMiddle.splice(index, 1)[0]); this.questionsMiddle.unshift(this.questionsMiddle.splice(index, 1)[0]);
} }
} else if(pos == 3) { } else if (pos == 3) {
if (index != this.questionsRight.length - 1) { if (index != this.questionsRight.length - 1) {
this.questionsRight[index] = this.questionsRight.splice(index + 1, 1, this.questionsRight[index])[0]; this.questionsRight[index] = this.questionsRight.splice(index + 1, 1, this.questionsRight[index])[0];
} else { } else {
...@@ -256,13 +254,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -256,13 +254,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
handleCombinLength(item) { handleCombinLength(item) {
if(Number(item.number)>5){ if (Number(item.number) > 5) {
return return
} }
if( Number(item.number) > item.combin.length ) { if (Number(item.number) > item.combin.length) {
let num = Number(item.number) - item.combin.length let num = Number(item.number) - item.combin.length
for(var index=0; index<num; index++) { for (var index = 0; index < num; index++) {
item.combin.push(0) item.combin.push(0)
} }
} else { } else {
...@@ -272,68 +270,68 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -272,68 +270,68 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
deleteQuestionItem(pos, i) { deleteQuestionItem(pos, i) {
if(pos == 1) { if (pos == 1) {
this.questionsLeft.splice(i, 1); this.questionsLeft.splice(i, 1);
} else if(pos == 2) { } else if (pos == 2) {
this.questionsMiddle.splice(i, 1); this.questionsMiddle.splice(i, 1);
} else if(pos == 3) { } else if (pos == 3) {
this.questionsRight.splice(i, 1); this.questionsRight.splice(i, 1);
} }
this.save() this.save()
} }
handlePartChange(e, pos, QI, index) { handlePartChange(e, pos, QI, index) {
if(pos == 1) { if (pos == 1) {
let a = JSON.parse(JSON.stringify(this.questionsLeft[QI].combin)) let a = JSON.parse(JSON.stringify(this.questionsLeft[QI].combin))
a[index] = Number(e) a[index] = Number(e)
this.questionsLeft[QI].combin = a this.questionsLeft[QI].combin = a
} else if(pos == 2) { } else if (pos == 2) {
let a = JSON.parse(JSON.stringify(this.questionsMiddle[QI].combin)) let a = JSON.parse(JSON.stringify(this.questionsMiddle[QI].combin))
a[index] = Number(e) a[index] = Number(e)
this.questionsMiddle[QI].combin = a this.questionsMiddle[QI].combin = a
} else if(pos == 3) { } else if (pos == 3) {
let a = JSON.parse(JSON.stringify(this.questionsRight[QI].combin)) let a = JSON.parse(JSON.stringify(this.questionsRight[QI].combin))
a[index] = Number(e) a[index] = Number(e)
this.questionsRight[QI].combin = a this.questionsRight[QI].combin = a
} }
this.save() this.save()
} }
onImageUploadSuccess(e, key, item?) { onImageUploadSuccess(e, key, item?) {
if(item) { if (item) {
item[key] = e.url; item[key] = e.url;
} else { } else {
this[key] = e.url; this[key] = e.url;
} }
this.save(); this.save();
} }
onAudioUploadSuccess(e, key, item?, uid?) { onAudioUploadSuccess(e, key, item?, uid?) {
if(item) { if (item) {
item[key] = e.url; item[key] = e.url;
if(uid) { if (uid) {
this.hotZooLeftEL.setAudioByUID(e.url, uid) this.hotZooLeftEL.setAudioByUID(e.url, uid)
this.hotZooMiddleEL.setAudioByUID(e.url, uid) this.hotZooMiddleEL.setAudioByUID(e.url, uid)
this.hotZooRightEL.setAudioByUID(e.url, uid) this.hotZooRightEL.setAudioByUID(e.url, uid)
} }
} else { } else {
this[key] = e.url; this[key] = e.url;
} }
this.save(); this.save();
} }
copyFieldsValue(fields: Array<String>, from: Object, to: Object) { copyFieldsValue(fields: Array<String>, from: Object, to: Object) {
fields.forEach((name: any)=>{ fields.forEach((name: any) => {
to[name] = from[name] to[name] = from[name]
}) })
} }
save() { save() {
(<any> window).courseware.setData(this.item, null, this.KEY); (<any>window).courseware.setData(this.item, null, this.KEY);
this.refresh(); this.refresh();
console.log("保存", this.item) console.log("保存", this.item)
} }
......
...@@ -247,7 +247,7 @@ export class waterWave extends MySprite { ...@@ -247,7 +247,7 @@ export class waterWave extends MySprite {
count = 80; count = 80;
speedY = 0; speedY = 0;
speedX = 0; speedX = 0;
height = this.bottole_r height = this.bottole_r;
water_color = "red" water_color = "red"
per = 1.5 per = 1.5
_runTimeCtl = new Date().getTime() _runTimeCtl = new Date().getTime()
......
...@@ -83,7 +83,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -83,7 +83,6 @@ export class PlayComponent implements OnInit, OnDestroy {
g_data; // 数据 g_data; // 数据
g_formData; // 核心表单数据 g_formData; // 核心表单数据
g_teacherFlag = false; // 默认角色 g_teacherFlag = false; // 默认角色
g_currentUser;
g_firstTouch = true; g_firstTouch = true;
g_partTitle_x = null; g_partTitle_x = null;
g_mainTitle_x = null; g_mainTitle_x = null;
...@@ -1197,15 +1196,15 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1197,15 +1196,15 @@ export class PlayComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
const getData = (<any>window).courseware.getData; const getData = (<any>window).courseware.getData;
getData(data => { getData(data => {
if (window['air'].airClassInfo.user.classRole == 'tea') {
if(!this.g_ForceChangeDefaultRole){
this.g_teacherFlag = true;
}
}
this.g_currentUser = window['air'].airClassInfo.user;
if (data && typeof data == "object") { if (data && typeof data == "object") {
this.g_data = data; if(data.data){
this.g_formData = data.contentObj; this.g_data = data.data;
this.g_formData = data.data.contentObj;
}else{
this.g_data = data;
this.g_formData = data.contentObj;
}
} else { } else {
this.g_data = {}; this.g_data = {};
} }
......
import os
import json
def file_name(file_dir):
fileList =["bg_kuang", "bg_kuang2", "bg_light"]
f = open('filename.txt', 'w');
blank = False
for root, dirs, files in os.walk(file_dir):
for fileName in files:
if root.split("\\")[-1]=="frame" or root.split("\\")[-1]=="sound" or root.split("\\")[-1]=="play" or (root.split("\\")[-1] in fileList):
blank = True
if root.split("\\")[-1] != "play":
f.write("'" + fileName.split(".")[0] + "': 'assets/play/" + root.split("\\")[-1] + "/" + fileName + "',\n")
else:
f.write("'" + fileName.split(".")[0] + "': 'assets/" + root.split("\\")[-1] + "/" + fileName + "',\n")
if blank:
f.write("\n")
blank = False
f.close()
fileList = file_name(os.path.abspath('.'))
'bg_70_40': 'assets/play/bg_70_40.png',
'creatJsonProfile': 'assets/play/creatJsonProfile.py',
'filename': 'assets/play/filename.txt',
'line': 'assets/play/line.png',
'num-1': 'assets/play/num-1.png',
'num-2': 'assets/play/num-2.png',
'num-3': 'assets/play/num-3.png',
'num-4': 'assets/play/num-4.png',
'num-5': 'assets/play/num-5.png',
'num-6': 'assets/play/num-6.png',
'num-7': 'assets/play/num-7.png',
'num-8': 'assets/play/num-8.png',
'oval-copy': 'assets/play/oval-copy.png',
'question-bg': 'assets/play/question-bg.png',
'resizeImg': 'assets/play/resizeImg.py',
'1': 'assets/play/sound/1.mp3',
'2': 'assets/play/sound/2.mp3',
'3': 'assets/play/sound/3.mp3',
'check': 'assets/play/sound/check.mp3',
'fanye': 'assets/play/sound/fanye.mp3',
'jifen': 'assets/play/sound/jifen.mp3',
'kulian': 'assets/play/sound/kulian.mp3',
'putong': 'assets/play/sound/putong.mp3',
'start': 'assets/play/sound/start.mp3',
'xianshi': 'assets/play/sound/xianshi.mp3',
'xiaolian': 'assets/play/sound/xiaolian.mp3',
'xingxing': 'assets/play/sound/xingxing.mp3',
import os
import json
def file_name(file_dir):
fileList =["bg_kuang", "bg_kuang2", "bg_light"]
f = open('filename.txt', 'w');
blank = False
for root, dirs, files in os.walk(file_dir):
for fileName in files:
print(root.split("\\")[-1])
f.write("'" + fileName.split(".")[0] + "': 'assets/hotZooCard/" + root.split("\\")[-1] + "/" + fileName + "',\n")
f.close()
fileList = file_name(os.path.abspath('.'))
'bg_70_40_1': 'assets/hotZooCard/hotZooCard/bg_70_40_1.png',
'bg_70_40_10': 'assets/hotZooCard/hotZooCard/bg_70_40_10.png',
'bg_70_40_11': 'assets/hotZooCard/hotZooCard/bg_70_40_11.png',
'bg_70_40_12': 'assets/hotZooCard/hotZooCard/bg_70_40_12.png',
'bg_70_40_13': 'assets/hotZooCard/hotZooCard/bg_70_40_13.png',
'bg_70_40_14': 'assets/hotZooCard/hotZooCard/bg_70_40_14.png',
'bg_70_40_15': 'assets/hotZooCard/hotZooCard/bg_70_40_15.png',
'bg_70_40_16': 'assets/hotZooCard/hotZooCard/bg_70_40_16.png',
'bg_70_40_17': 'assets/hotZooCard/hotZooCard/bg_70_40_17.png',
'bg_70_40_18': 'assets/hotZooCard/hotZooCard/bg_70_40_18.png',
'bg_70_40_19': 'assets/hotZooCard/hotZooCard/bg_70_40_19.png',
'bg_70_40_2': 'assets/hotZooCard/hotZooCard/bg_70_40_2.png',
'bg_70_40_20': 'assets/hotZooCard/hotZooCard/bg_70_40_20.png',
'bg_70_40_21': 'assets/hotZooCard/hotZooCard/bg_70_40_21.png',
'bg_70_40_22': 'assets/hotZooCard/hotZooCard/bg_70_40_22.png',
'bg_70_40_23': 'assets/hotZooCard/hotZooCard/bg_70_40_23.png',
'bg_70_40_24': 'assets/hotZooCard/hotZooCard/bg_70_40_24.png',
'bg_70_40_25': 'assets/hotZooCard/hotZooCard/bg_70_40_25.png',
'bg_70_40_3': 'assets/hotZooCard/hotZooCard/bg_70_40_3.png',
'bg_70_40_4': 'assets/hotZooCard/hotZooCard/bg_70_40_4.png',
'bg_70_40_5': 'assets/hotZooCard/hotZooCard/bg_70_40_5.png',
'bg_70_40_6': 'assets/hotZooCard/hotZooCard/bg_70_40_6.png',
'bg_70_40_7': 'assets/hotZooCard/hotZooCard/bg_70_40_7.png',
'bg_70_40_8': 'assets/hotZooCard/hotZooCard/bg_70_40_8.png',
'bg_70_40_9': 'assets/hotZooCard/hotZooCard/bg_70_40_9.png',
'creatJsonProfile': 'assets/hotZooCard/hotZooCard/creatJsonProfile.py',
'filename': 'assets/hotZooCard/hotZooCard/filename.txt',
import os
import shutil
from PIL import Image
fileName = os.listdir('./')
withBorder = False
border_left = ""
border_right = ""
imageName = input("图片名:")
if input("是否包含边框? (y/n):")=="y":
withBorder = True
if withBorder:
border_left = input("左边框文件名:")
border_right = input("右边框文件名:")
number = int(input("数量:"))
if os.path.exists('./' + imageName + '/'):
shutil.rmtree('./' + imageName + '/')
os.mkdir('./' + imageName + '/')
pic = Image.open('./' + imageName + '.PNG')
width = pic.width
height = pic.height
f = open('./' + imageName + '/' + imageName + '_map.txt', 'w')
if withBorder:
borderImg_left, borderImg_right = Image.open('./' + border_left + '.PNG'), Image.open('./' + border_right + '.PNG')
for index in range(1, number):
newpic = pic.resize((width*index, height),Image.ANTIALIAS)
loc1, loc2, loc3 = (0, 0), (borderImg_left.width, 0), (borderImg_left.width +newpic.width, 0)
join_pic = Image.new('RGBA', (borderImg_left.width + newpic.width + borderImg_right.width, newpic.height))
join_pic.paste(borderImg_left, loc1)
join_pic.paste(newpic, loc2)
join_pic.paste(borderImg_right, loc3)
join_pic.save('./' + imageName + '/' + imageName + '_' + str(index) + 'x.PNG')
f.write('"' + str(width*index) + '": "' + imageName + '_' + str(index) + 'x",\n')
f.close()
else:
for index in range(1, number):
newpic = pic.resize((width*index, height),Image.ANTIALIAS)
newpic.save('./' + imageName + '/' + imageName + '_' + str(index) + 'x.PNG')
f.write('"' + str(width*index) + '": "' + imageName + '_' + str(index) + 'x",\n')
f.close()
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" /> <link rel="icon" type="image/x-icon" href="favicon.ico" />
<!-- <script type="text/javascript" src="http://teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js" ></script> --> <!-- <script type="text/javascript" src="http://teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js" ></script> -->
<script type="text/javascript" src="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air_online.js"></script> <script type="text/javascript" src="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
......
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