Commit 62d1e5ab authored by limingzhe's avatar limingzhe

fix: 填充资源后修改

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