Commit 62d1e5ab authored by limingzhe's avatar limingzhe

fix: 填充资源后修改

parent 17bd1727
......@@ -5709,7 +5709,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2903,
"width": 100,
"height": 650
},
"_anchorPoint": {
......@@ -5756,7 +5756,7 @@
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 2903,
"width": 100,
"height": 650
},
"_resize": 1,
......@@ -5767,8 +5767,8 @@
"height": 40
},
"_N$startAxis": 0,
"_N$paddingLeft": 0,
"_N$paddingRight": 0,
"_N$paddingLeft": 100,
"_N$paddingRight": 100,
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 50,
......@@ -10866,7 +10866,7 @@
"_spriteFrame": {
"__uuid__": "e140535b-c948-46d6-99df-0f22ef4ba59a"
},
"_type": 0,
"_type": 2,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
......@@ -13767,7 +13767,7 @@
"_spriteFrame": {
"__uuid__": "e140535b-c948-46d6-99df-0f22ef4ba59a"
},
"_type": 0,
"_type": 2,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
......@@ -20853,7 +20853,7 @@
"_spriteFrame": {
"__uuid__": "e140535b-c948-46d6-99df-0f22ef4ba59a"
},
"_type": 0,
"_type": 2,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
......
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl, getSprNodeByUrl } from "./util";
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, playLocalAudio, playAudioByUrl, getSprNodeByUrl, asyncDelay } from "./util";
const {ccclass, property} = cc._decorator;
@ccclass
......@@ -95,7 +95,12 @@ export default class NewClass extends cc.Component {
const {rows} = await asyncCallNetworkApiGet('/api/kyxq/v1/user/jclist', {
jc_arr: userInfo.jc_arr,
});
this.SvContent.opacity = 0;
let loadEndCount = 0;
// rows.length = 2;
for(let i=0; i<rows.length; i++) {
const row = rows[i];
const ci = cc.instantiate(this.CourseItem);
cc.find(`progressText`, ci).getComponent(cc.Label).string = `学习进度:${row.process}`;
......@@ -109,8 +114,7 @@ export default class NewClass extends cc.Component {
}
getSpriteFrimeByUrl(row.cover, (spriteFrame) => {
getSpriteFrimeByUrl(row.cover, async (spriteFrame) => {
const coverNode = cc.find(`bg`, ci);
const spr = coverNode.getComponent(cc.Sprite);
......@@ -126,10 +130,33 @@ export default class NewClass extends cc.Component {
console.log('row: ', row);
this.handleClickCourseItem(ci[`syllabus_id`], row);
})
loadEndCount ++;
if (loadEndCount == rows.length) {
await asyncDelay(0.01);
this.SvContent.opacity = 255;
const contentW = this.SvContent.getContentSize().width;
const canvas = cc.find("Canvas");
if (contentW < canvas.width) {
// this.SvContent.x = 0;
this.SvContent.x = -contentW / 2;
} else {
this.SvContent.x = -canvas.width / 2;
}
this.loading.active = false;
}
});
this.SvContent.addChild(ci);
console.log("this.canvas.width: ", cc.find("Canvas").width)
}
this.loading.active = false;
// this.loading.active = false;
}
// onLoad () {}
......@@ -194,6 +221,8 @@ export default class NewClass extends cc.Component {
_canTouch = false;
async start () {
this.initBg();
await this.getCourseList();
await this.getUserInfo();
this.initTopUserPanel();
......@@ -201,7 +230,6 @@ export default class NewClass extends cc.Component {
this._canTouch = true;
this._inited = true;
this.initBg();
}
......@@ -212,8 +240,8 @@ export default class NewClass extends cc.Component {
this.initTopUserPanel();
if(this._inited) {
await this.getCourseList();
// await this.getUserInfo();
// await this.getCourseList();
this._canTouch = true;
}
}
......
......@@ -55,8 +55,12 @@ export default class NewClass extends cc.Component {
async onEnable() {
if (!this.m_isLoadData){
this.loading.active = true;
this.scrollView.opacity = 0;
await this.initData();
this.initView();
this.scrollView.opacity = 255;
this.loading.active = false;
}
}
......
......@@ -26,8 +26,12 @@ export default class NewClass extends cc.Component {
async start() {
this.loading.active = true;
this.scrollView.opacity = 0;
await this.initData();
await this.initView();
this.scrollView.opacity = 255;
this.loading.active = false;
}
......@@ -57,7 +61,6 @@ export default class NewClass extends cc.Component {
initListView() {
const svNode = this.scrollView;
const view = cc.find("view", svNode);
......@@ -69,6 +72,14 @@ export default class NewClass extends cc.Component {
const sv = svNode.getComponent(cc.ScrollView);
this.initScrollViewItem(sv, itemArr, 1);
const content = sv.content;
const canvas = cc.find("Canvas");
if (content.width > canvas.width) {
content.x = -canvas.width / 2;
} else {
content.x = -content.width / 2;
}
}
......
......@@ -7,7 +7,7 @@ import { BlendFactor } from './../../../creator.d';
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl } from "./util";
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncCallNetworkApiPost, getSpriteFrimeByUrl, asyncDelay } from "./util";
const { ccclass, property } = cc._decorator;
......@@ -49,9 +49,13 @@ export default class NewClass extends cc.Component {
async onEnable() {
this.loading.active = true;
this.scrollView.opacity = 0;
await this.initData();
await this.getAndStoreSyllabusStatus();
await this.initView();
this.scrollView.opacity = 255;
this.loading.active = false;
}
......@@ -84,15 +88,23 @@ export default class NewClass extends cc.Component {
}
initTitle() {
async initTitle() {
const titleLabelNode = cc.find("bg/bg_title/label", this.node);
const titleLabel = titleLabelNode.getComponent(cc.Label);
titleLabel.string = this.node['pData'].name;
if (titleLabelNode.width > titleLabelNode.parent.width * 0.9) {
titleLabelNode.scale = titleLabelNode.parent.width * 0.9 / titleLabelNode.width;
const bgTitle = titleLabelNode.parent;
if (!bgTitle['baseW']) {
bgTitle['baseW'] = bgTitle.width;
}
const baseW = bgTitle['baseW'];
await asyncDelay(0.01);
if (titleLabelNode.width * 1.2 > baseW) {
bgTitle.width = titleLabelNode.width * 1.2;
} else {
titleLabelNode.scale = 1;
bgTitle.width = baseW;
}
}
......@@ -111,9 +123,7 @@ export default class NewClass extends cc.Component {
view.width = svNode.width;
view.height = svNode.height;
const itemArr = this.getItemArr(this.data);
if (itemArr.length == 0) {
const sv = svNode.getComponent(cc.ScrollView);
const content = sv.content;
......@@ -121,10 +131,18 @@ export default class NewClass extends cc.Component {
return;
}
const sv = svNode.getComponent(cc.ScrollView);
this.initScrollViewItem(sv, itemArr, 1);
const content = sv.content;
const canvas = cc.find("Canvas");
if (content.width > canvas.width) {
content.x = -canvas.width / 2;
} else {
content.x = -content.width / 2;
}
}
......
......@@ -6,7 +6,7 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet } from "./util";
import { getSprNodeByUrl, setSprNodeMaxLen, asyncCallNetworkApiGet, asyncDelay } from "./util";
const {ccclass, property} = cc._decorator;
......@@ -62,15 +62,23 @@ export default class NewClass extends cc.Component {
}
initTitle() {
async initTitle() {
const titleLabelNode = cc.find("bg/bg_title/label", this.node);
const titleLabel = titleLabelNode.getComponent(cc.Label);
titleLabel.string = this.node['pData'].name;
if (titleLabelNode.width > titleLabelNode.parent.width * 0.9) {
titleLabelNode.scale = titleLabelNode.parent.width * 0.9 / titleLabelNode.width;
const bgTitle = titleLabelNode.parent;
if (!bgTitle['baseW']) {
bgTitle['baseW'] = bgTitle.width;
}
const baseW = bgTitle['baseW'];
await asyncDelay(0.01);
if (titleLabelNode.width * 1.2 > baseW) {
bgTitle.width = titleLabelNode.width * 1.2;
// titleLabelNode.scale = baswW * 0.9 / titleLabelNode.width;
} else {
titleLabelNode.scale = 1;
bgTitle.width = baseW;
}
}
......@@ -102,7 +110,8 @@ export default class NewClass extends cc.Component {
}
async initUnitListView() {
const svNode = this.unitScrollView;
svNode.opacity = 0;
const resData = await asyncCallNetworkApiGet(`/api/syllabus/v2/tree`, {pid: this.node['syllabus_pid'], deep: 2});
const rows = resData.rows;
......@@ -117,7 +126,7 @@ export default class NewClass extends cc.Component {
await this.getAndStoreSyllabusStatus(rows);
const svNode = this.unitScrollView;
// const svNode = this.unitScrollView;
const view = cc.find("view", svNode);
view.width = svNode.width;
......@@ -129,13 +138,23 @@ export default class NewClass extends cc.Component {
this.initScrollViewItem(sv, itemArr, 1);
const content = sv.content;
const canvas = cc.find("Canvas");
if (content.width > canvas.width) {
content.x = -canvas.width / 2;
} else {
content.x = -content.width / 2;
}
// console.log('content.width: ' + content.width);
svNode.opacity = 255;
}
listItem;
getUnitItemDataArr(dataArr) {
let listItem = this.listItem;
let subItem = cc.find("sub_item", listItem);
let listLabel = cc.find("label", listItem);
......@@ -211,6 +230,11 @@ export default class NewClass extends cc.Component {
// lockCover.active = false;
// }
const labelNode = cc.find("label", subNode);
const label = labelNode.getComponent(cc.Label);
label.string = subData.name;
subNode.addComponent(cc.Button);
subNode.on("click", () => {
......
......@@ -26,10 +26,10 @@
"height": 146,
"rawWidth": 604,
"rawHeight": 146,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"borderTop": 58,
"borderBottom": 62,
"borderLeft": 292,
"borderRight": 288,
"subMetas": {}
}
}
......
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