Commit ecde648a authored by 唐鑫's avatar 唐鑫

初始化

parent ce304201
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
"cli": {
"analytics": "f1a365a2-efef-4072-b5fc-c280aaa591eb"
}
} }
\ No newline at end of file
@import '../style/common_mixin.css'; @import '../style/common_mixin.css';
.model-content { .model-content {
width: 100%; width: 100%;
height: 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 { .pic-sound-box {
float: left; width: 50%;
margin: 3px; display: flex;
border-style: dashed; flex-direction: column;
border-color: #000; }
border-width: 1px;
.add-btn-box {
display: flex;
align-items: center;
justify-content: center;
height: 20vw;
padding: 10px;
padding-top: 5vw;
} }
.border { .border {
width: 450px;
height: 450px;
border-radius: 20px; border-radius: 20px;
border-style: dashed; border-style: dashed;
padding: 20px; text-align: center;
margin: 20px; float: left;
/*width: 500px; */ margin-left: 10px;
/*//border-radius: 20px;*/ margin-bottom: 10px;
/*//border-width: 2px;*/
/*//border-color: #000000;*/
} }
.group-title {
.border-lite { width: 100%;
border: 2px dashed #ddd; }
border-radius: 0.5rem; .group-item {
width: 100%;
display: flex;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
padding: 10px; padding: 10px;
margin: 10px; }
.box-testlet-0 {
border: 1px solid gray;
width: 100%;
text-align: center;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border-bottom: 0px;
}
.box-testlet-1 {
border: 1px solid gray;
width: 100%;
text-align: left;
border-bottom-left-radius: 25px;
border-bottom-right-radius: 25px;
}
.box-testlet-2 {
margin-left: 25%;
width: 50%;
height: 100px;
text-align: center;
}
.box-group-0 {
border: 1px solid gray;
width: 100%;
text-align: center;
border-left: 0px;
border-right: 0px;
}
.box-group-1 {
border: 1px 0px 0px 0px solid gray;
width: 100%;
text-align: left;
}
.box-group-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
This diff is collapsed.
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core'; import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef } from '@angular/core';
import { JsonPipe } from '@angular/common';
@Component({ @Component({
...@@ -9,102 +8,255 @@ import { JsonPipe } from '@angular/common'; ...@@ -9,102 +8,255 @@ import { JsonPipe } from '@angular/common';
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 picArr = [];
saveKey = "test_001"; _item: any;
// 储存对象 KEY = 'hw_006';
item; errs = [];
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { // @Input()
set item(item) {
this._item = item;
// this.init();
} }
get item() {
createShell() { return this._item;
this.item.wordList.push({
word: '',
audio: '',
backWord: '',
backWordAudio: '',
});
this.save();
} }
removeShell(idx) { @Output()
this.item.wordList.splice(idx, 1); update = new EventEmitter();
this.save();
constructor(private appRef: ApplicationRef) {
} }
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {};
this.item.contentObj = {};
// 获取存储的数据 const getData = (<any>window).courseware.getData;
(<any>window).courseware.getData((data) => { getData((data) => {
if (data) { if (data) {
this.item = data; this.item = data;
} else {
this.item = {};
}
if (!this.item.contentObj) {
this.item.contentObj = {};
} }
console.log('~data:', data);
this.init(); this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
}, this.saveKey); }, this.KEY);
}
// this.initData();
}
ngOnChanges() { ngOnChanges() {
} }
ngOnDestroy() { ngOnDestroy() {
} }
init() { 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);
// this.picArr = this.getDefaultPicArr();
// this.item.contentObj.picArr = this.picArr;
// console.log('this.item:;', this.picArr);
}
cardItemData() {
return {
cardId: "",
left: {
title: "",
pic_url: "",
audio_url: ""
},
right: {
title: "",
pic_url: "",
audio_url: ""
}
};
}
getDefaultPicArr() {
let arr = [];
arr[0] = [];
arr[0][0] = [];
//在卡片组之上需要增加 两个组 0根->picArr 1题组->testlet 2页面->page 3卡片对->itemData
//默认 题组1 页面1 卡片对2个
for (let i = 0; i < 2; i++) {
let item = this.cardItemData();
arr[0][0].push(item);
} }
// for (let index = 0; index < 4; index++) {
// let item = this.cardItemData();
// arr.push(item);
// }
return arr;
}
/** initData() {
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
}
onImageUploadSuccessByItem(e, item) {
item.pic_url = e.url;
this.save(); this.save();
} }
/** onAudioUploadSuccessByItem(e, item) {
* 储存音频数据 item.audio_url = e.url;
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
this.save(); this.save();
} }
onWordAudioUploadSuccess(e, idx) { //添加一对
this.item.wordList[idx].audio = e.url; addItem(m, n) {
//最多5对
if (this.picArr[m][n].length < 5) {
let item = this.cardItemData();
this.picArr[m][n].push(item);
this.saveItem();
}
}
deleteItem(index, m, n) {
if (index !== -1) {
this.picArr[m][n].splice(index, 1);
}
if (this.picArr[m][n].length == 0) {
this.picArr[m].splice(n, 1)
}
if (this.picArr[m].length == 0) {
this.picArr.splice(m, 1)
}
this.save();
}
//添加一页
addPage(m) {
let arr = [];
for (let i = 0; i < 2; i++) {
let item = this.cardItemData();
arr.push(item);
}
this.picArr[m].push(arr);
this.save(); this.save();
} }
deletePage(m, n) {
console.log("删除页," + m + "|" + n);
this.picArr[m].splice(n, 1)
if (this.picArr[m].length == 0) {
this.picArr.splice(m, 1)
}
this.save();
}
//添加题组
addTestlet() {
let arr = [[]];
for (let i = 0; i < 2; i++) {
let item = this.cardItemData();
arr[0].push(item);
}
this.picArr.push(arr);
this.save();
}
deleteTestlet(m) {
this.picArr.splice(m, 1)
this.save();
}
radioClick(it, radioValue) {
it.radioValue = radioValue;
this.saveItem();
}
clickCheckBox() {
console.log(' in clickCheckBox');
this.saveItem();
}
onBackWordAudioUploadSuccess(e, idx) { saveItem() {
this.item.wordList[idx].backWordAudio = e.url;
console.log(' in saveItem');
// this.update.emit(this.item);
this.save(); this.save();
} }
/** check() {
* 储存数据 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() { 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)); console.log('this.item = ' + JSON.stringify(this.item));
this.refresh();
} }
/**
* 刷新 渲染页面
*/
refresh() { refresh() {
setTimeout(() => { setTimeout(() => {
this.appRef.tick(); this.appRef.tick();
...@@ -112,3 +264,4 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -112,3 +264,4 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
} }
This diff is collapsed.
{
"ver": "1.1.2",
"uuid": "c86579f8-93d0-4fd4-b735-4e5e87f46bf8",
"isBundle": true,
"bundleName": "resources",
"priority": 8,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "a3f6fefb-abb7-418b-9726-ebea06068962",
"downloadMode": 0,
"duration": 1.776327,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "88e389ad-cdd7-4d2b-8900-19bbb61c340a",
"downloadMode": 0,
"duration": 0.173333,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "665e544c-fe92-4f24-bdcc-9475a763ff0c",
"downloadMode": 0,
"duration": 0.264,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "342d6b41-d606-43d5-9676-7b67f03d236f",
"downloadMode": 0,
"duration": 0.653061,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "16a0bc5d-fd4e-443e-aeb0-80139b29574d",
"downloadMode": 0,
"duration": 4.04898,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "e3803979-40c9-4b6c-9f51-39781cec1d1b",
"downloadMode": 0,
"duration": 2.115917,
"subMetas": {}
}
\ No newline at end of file
class Ani {
//抖动效果
static shake(item) {
// alert("抖动效果");
let tween = cc.tween(item);
tween.to(0.06, { angle: 10 })
.to(0.06, { angle: 0 })
.to(0.06, { angle: -10 })
.to(0.06, { angle: 0 });
tween.repeat(4);
tween.start();
}
static scaleOut(item) {
return new Promise((resolve) => {
let tween = cc.tween(item);
tween.to(0.2, { scaleX: 0, scaleY: 0 })
.call(() => { resolve() });
tween.start();
})
}
static scaleIn(item) {
return new Promise((resolve) => {
item.scaleX = 0;
item.scaleY = 0;
let tween = cc.tween(item);
tween.to(0.2, { scaleX: 1, scaleY: 1 })
.call(() => { resolve() });
tween.start();
})
}
}
export default Ani;
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "b15f80f1-6507-44eb-af5b-07bfb945bf0c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
class Card {
constructor(picItem, cardId, doubuleId) {
//单个具体内容 一对的内容 一组的内容
this.cardId = cardId;
this.cardDid = doubuleId;
this.type = CardManager.TYPE_NULL;
if (picItem.radioValue == "A") {
if (picItem.title) {
this.txt = picItem.title;
this.type = CardManager.TYPE_TXT;
}
} else if (picItem.radioValue == "B") {
if (picItem.pic_url) {
this.img = picItem.pic_url;
this.type = CardManager.TYPE_IMG;
}
} else if (picItem.radioValue == "C") {
if (picItem.audio_url) {
this.audio = picItem.audio_url;
this.type = CardManager.TYPE_MP3;
}
}
// this.type = CardManager.TYPE_MP3;
}
// 具体去怎么分配 按照不同的分配逻辑去走
}
//最大的星星 一二三星 卡片组 卡片对 卡片 卡片内数据
class CardManager {
static TYPE_NULL = 0;
static TYPE_TXT = 1;
static TYPE_IMG = 2;
static TYPE_MP3 = 3;
static instance;
static getIns() {
if (!CardManager.instance) CardManager.instance = new CardManager();
return CardManager.instance;
}
_cardArray;//所有卡片的组
testletId;//组id
pageId;//页id
constructor() {
this._cardArray = [];//组 页
this.testletId = 0;
this.pageId = 0;
}
initCards(obj) {
console.log(obj);
let picArr = obj.contentObj.picArr;
this._cardArray = [];
let doubuleId = 0;
let cardId = 0;
for (let m = 0; m < picArr.length; m++) {
let testlet = [];
for (let n = 0; n < picArr[m].length; n++) {
let page = [];
for (let i = 0; i < picArr[m][n].length; i++) {
doubuleId++;
let pic = picArr[m][n][i];
let left = pic.left;
let right = pic.right;
cardId++;
let card1 = new Card(left, cardId, doubuleId);
cardId++;
let card2 = new Card(right, cardId, doubuleId);
if (card1.type == CardManager.TYPE_NULL || card2.type == CardManager.TYPE_NULL) {
doubuleId--;
continue;
}
page.push(card1, card2);
}
testlet.push(page);
}
this._cardArray.push(testlet);
}
}
getTestlet() {
return this._cardArray.length - 1;
}
getPage() {
if (this._cardArray[this.testletId] && this._cardArray[this.testletId][this.pageId]) {
return this._cardArray[this.testletId][this.pageId];
} else {
return null;
}
}
addPageNum() {
this.pageId++;
if (!this.getPage()) {
this.pageId = 0;
this.testletId++;
if (!this.getPage()) {
return 2;//游戏结束
}
return 1;//组结束
} else {
return 0;//页结束
}
}
resetPageNum() {
this.testletId = 0;
this.pageId = 0;
}
randomPageCards() {
//页面内部数字要打乱 0 1 2 3 4 5 6 7 8 每次动态取出一个值 然后动态处理
let radArray = [];
for (let m = 0; m < this._cardArray.length; m++) {
for (let n = 0; n < this._cardArray[m].length; n++) {
let arr = [];
while (this._cardArray[m][n].length > 0) {
let rand = Math.floor(Math.random() * this._cardArray[m][n].length);
arr.push(this._cardArray[m][n][rand]);
this._cardArray[m][n].splice(rand, 1);
}
this._cardArray[m][n] = arr;
}
}
}
}
export default CardManager;
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "11f21116-6718-42e0-bd5e-a369c8a95b33",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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"}]]]}}
return item;
}
export const itemData = retData();
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "4e93bb38-2b8e-4524-a0cf-ee046467baf5",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
class HYLoader {
getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
this.getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(node);
}
})
}
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}
}
}
export const hyLoader = new HYLoader();
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "2bc1b858-63dd-4bec-bb40-e6703d306bbc",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "24305734-8e44-4e40-b9cf-802b2ae89e08",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
class CalculativeResize {
static resizeInfo() {
//0.设计尺寸
let baseSize = cc.size(1920, 1080);
//1.获取屏幕尺寸
let canvasSize = cc.view.getCanvasSize();
//2.将屏幕宽高 以高度对齐的方式 换算出场景 宽度
let sumSize = cc.size(canvasSize.width * baseSize.height / canvasSize.height, baseSize.height)
//3.计算场景宽度与设计宽度比率
let scaleX = sumSize.width / baseSize.width;
let posX = sumSize.width - baseSize.width;
//高屏幕适配
if (scaleX <= 1) {
let sumSize = cc.size(baseSize.width, canvasSize.height * baseSize.width / canvasSize.width)
let scaleY = sumSize.height / baseSize.height;
let posY = sumSize.height - baseSize.height;
// let posY = sumSize.height * (1 - 1 / scaleX);
return { scaleX: 1, scaleY: scaleY, posX: 0, orgX: 0, posY: posY, orgY: - posY / 2 }
}
//需要拓展的宽度缩放比
return { scaleX: scaleX, scaleY: 1, posX: posX, orgX: - posX / 2, posY: 0, orgY: 0 };
}
}
//关于齐刘海的适配方案。
//1.需要获取对应的手机型号
//2.需要写上安全间距标记(主要是中间部分)
//3.不同的手机安全间距可能不同。(主要适配iPhone X)
cc.Class({
extends: cc.Component,
properties: {
r_width: 1,
r_height: 1,
r_top: 0,
r_bottom: 0,
p_left: 0,
p_right: 0,
p_top: 0,
p_bottom: 0,
black: 0,//用于不能直接缩放的图片(如引导),两边补齐黑边
noHead: 0,
debug: 0,
},
// LIFE-CYCLE CALLBACKS:
onLoad() {
let { scaleX, posX, scaleY, posY } = CalculativeResize.resizeInfo();
this.resizeScaleX = scaleX;
this.resizeScaleY = scaleY;
this.posX = posX;
this.posY = posY;
let { width, height, x, y } = this.node;
this.nodeWidth = width;
this.nodeHeight = height;
this.nodeX = x;
this.nodeY = y;
//增加一个resize的监听,当屏幕出现宽高比变化的时候,进行一次重新适配。
//主要用于刘海屏的重置,以及动态屏幕变化的控制(虚拟按键屏)。
},
start() {
this.resize();
},
update(dt) {
},
onDestroy() {
if (this.black1)
pg.view.removChildren(this.black1);
if (this.black2)
pg.view.removChildren(this.black2);
this.black1 = null;
this.black2 = null;
},
resize() {
if (!this.resizeScaleX && !this.nodeWidth) {
console.warn("手动调用此方法时,不能再onLoad中使用");
return;
}
this.resizeHeight();
this.resizeWidth();
},
//高屏幕适配
resizeHeight() {
if (this.resizeScaleY <= 1.05) return;
let scaleY = this.resizeScaleY;
let posY = this.posY;
let nodeWidth = this.nodeWidth;
let nodeHeight = this.nodeHeight;
let nodeX = this.nodeX;
let nodeY = this.nodeY;
if (this.debug == 1) {
console.log("断点调试点");
}
//宽度拉伸
if (this.r_width == 1) {
this.node.width = nodeWidth * scaleY;
}
//高度拉升
if (this.r_height == 1) {
this.node.height = nodeHeight * scaleY;
// //高度拉伸后,图片顶部齐边【坐标下移】 y坐标下移
// if (this.r_top == 1) {
// this.node.y = nodeY - nodeHeight * (scaleY - 1) / 2;
// }
// //高度拉伸后,图片底部齐边【坐标上移】 y坐标上移
// if (this.r_bottom == 1) {
// this.node.y = nodeY + nodeHeight * (scaleY - 1) / 2;
// }
}
// //如果是刘海屏,减去对应的刘海屏的宽度
// let lhpSize = { top: 0, bottom: 0 };
// //动态左移
// if (this.p_left == 1) {
// this.node.x = nodeX - posX / 2 + lhpSize.top;
// }
// //动态右移
// if (this.p_right == 1) {
// this.node.x = nodeX + posX / 2 - lhpSize.bottom;
// }
//动态上移
if (this.p_top == 1) {
this.node.y = nodeY + posY / 2 *0.75
}
//动态下移
if (this.p_bottom == 1) {
this.node.y = nodeY - posY / 2 *0.75
}
},
//长屏幕适配
resizeWidth() {
if (this.resizeScaleX <= 1.05) return;
let resizeScaleX = this.resizeScaleX;
let posX = this.posX;
let nodeWidth = this.nodeWidth;
let nodeHeight = this.nodeHeight;
let nodeX = this.nodeX;
let nodeY = this.nodeY;
if (this.debug == 1) {
console.log("断点调试点");
}
//宽度拉伸
if (this.r_width == 1) {
this.node.width = nodeWidth * resizeScaleX;
}
//高度拉升
if (this.r_height == 1) {
this.node.height = nodeHeight * resizeScaleX;
//高度拉伸后,图片顶部齐边【坐标下移】 y坐标下移
if (this.r_top == 1) {
this.node.y = nodeY - nodeHeight * (resizeScaleX - 1) / 2;
}
//高度拉伸后,图片底部齐边【坐标上移】 y坐标上移
if (this.r_bottom == 1) {
this.node.y = nodeY + nodeHeight * (resizeScaleX - 1) / 2;
}
}
if (this.black == 1) {
let baseSize = cc.size(1280, 720);
this.black1 = this.createBalck();
this.black2 = this.createBalck();
let curWidth = nodeWidth * resizeScaleX;
let curHeight = nodeHeight * resizeScaleX;
let blackWidth = (curWidth - baseSize.width) / 2;
let blackHeight = curHeight;
this.black1.width = blackWidth;
this.black1.height = blackHeight;
this.black2.width = blackWidth;
this.black2.height = blackHeight;
this.black1.x = - baseSize.width / 2 - this.black1.width / 2;
this.black2.x = baseSize.width / 2 + this.black1.width / 2;
this.black1.y = this.black2.y = nodeY;
pg.view.addChild(this.node, this.black1);
pg.view.addChild(this.node, this.black2);
this.black1.active = false;
this.black2.active = false;
if (this.node.nodeData && (this.node.nodeData.bg != "" && this.node.nodeData.bg != "rect")) {
this.black1.active = true;
this.black2.active = true;
}
}
//如果是刘海屏,减去对应的刘海屏的宽度
let lhpSize = { top: 0, bottom: 0 };
if (!this.noHead && posX != 0) lhpSize = { top: 44 * 1.5, bottom: 34 * 1.5 };
//动态左移
if (this.p_left == 1) {
this.node.x = nodeX - posX / 2 + lhpSize.top;
}
//动态右移
if (this.p_right == 1) {
this.node.x = nodeX + posX / 2 - lhpSize.bottom;
}
},
//屏幕适配--end
createBalck() {
let black = cc.instantiate(cc.find('Canvas/blackBg'));
return black;
},
setBlackActive(val) {
if (this.black1)
this.black1.active = val;
if (this.black2)
this.black2.active = val;
}
});
{
"ver": "1.0.8",
"uuid": "85b1fa7a-77a0-4811-8b62-826a7ca77c7e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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