Commit 25c7050a authored by limingzhe's avatar limingzhe

fix: 结算界面卡住

parent ba29541b
...@@ -870,7 +870,8 @@ export class RichText extends Label { ...@@ -870,7 +870,8 @@ export class RichText extends Label {
getSubTextRect(subText, targetIndex=0) { getSubTextRect(subText, targetIndex=0) {
this.isShowWordBg = true;
this.update();
const tmpLabel = new RichText(); const tmpLabel = new RichText();
...@@ -881,18 +882,20 @@ export class RichText extends Label { ...@@ -881,18 +882,20 @@ export class RichText extends Label {
tmpLabel.fontWeight = this.fontWeight; tmpLabel.fontWeight = this.fontWeight;
tmpLabel.width = this.width; tmpLabel.width = this.width;
tmpLabel.height = this.height; tmpLabel.height = this.height;
console.log('subText: ', subText);
// console.log('subText: ', subText); console.log('this.text: ', this.text);
// const indexArr = searchSubStr(this.text, subText); // const indexArr = searchSubStr(this.text, subText);
// console.log('indexArr: ', indexArr); // console.log('indexArr: ', indexArr);
// const index = indexArr[targetIndex]; // const index = indexArr[targetIndex];
const index = this.text.indexOf(subText, targetIndex); const index = this.text.indexOf(subText, targetIndex);
console.log('index: ', index);
if (!index) { if (index == -1) {
return; return;
} }
console.log('this.wordBgData: ', this.wordBgData);
// const index = this.text.indexOf(subText); // const index = this.text.indexOf(subText);
// console.log('!!!index: ', index); // console.log('!!!index: ', index);
...@@ -2122,8 +2125,9 @@ export class ScrollView extends MySprite { ...@@ -2122,8 +2125,9 @@ export class ScrollView extends MySprite {
refreshContentSize() { refreshContentSize() {
const children = this.content.children; const children = this.content.children;
console.log('children: ', children); // console.log('children: ', children);
let maxW = 0; let maxW = 0;
let maxH = 0; let maxH = 0;
for (let i=0; i<children.length; i++) { for (let i=0; i<children.length; i++) {
...@@ -2131,11 +2135,11 @@ export class ScrollView extends MySprite { ...@@ -2131,11 +2135,11 @@ export class ScrollView extends MySprite {
continue; continue;
} }
const box = children[i].getBoundingBox(); const box = children[i].getBoundingBox();
console.log('box: ', box); // console.log('box: ', box);
const boxEdgeX = box.x + box.width; const boxEdgeX = box.x + box.width;
const boxEdgeY = box.y + box.height; const boxEdgeY = box.y + box.height;
console.log('boxEdgeY: ', boxEdgeY); // console.log('boxEdgeY: ', boxEdgeY);
if (boxEdgeX > maxW) { if (boxEdgeX > maxW) {
maxW = boxEdgeX; maxW = boxEdgeX;
} }
...@@ -2144,11 +2148,15 @@ export class ScrollView extends MySprite { ...@@ -2144,11 +2148,15 @@ export class ScrollView extends MySprite {
} }
} }
console.log('maxW: ', maxW); // console.log('maxW: ', maxW);
console.log('maxH: ', maxH); // console.log('maxH: ', maxH);
// console.log('this.y: ', this.y);
// console.log(this.getBoundingBox().height);
this.content.width = maxW; this.content.width = maxW;
this.content.height = maxH ; this.content.height = maxH ;
this.refreshScrollBar(); this.refreshScrollBar();
} }
...@@ -2159,6 +2167,7 @@ export class ScrollView extends MySprite { ...@@ -2159,6 +2167,7 @@ export class ScrollView extends MySprite {
setContentScale(s) { setContentScale(s) {
this.content.setScaleXY( 1 / s); this.content.setScaleXY( 1 / s);
this.refreshScrollBar();
} }
refreshScrollBar() { refreshScrollBar() {
...@@ -2166,15 +2175,21 @@ export class ScrollView extends MySprite { ...@@ -2166,15 +2175,21 @@ export class ScrollView extends MySprite {
if (!w) { if (!w) {
w = this.width / 50; w = this.width / 50;
} }
const rect1 = this.getBoundingBox();
const rect2 = this.content.getBoundingBox();
let rate = this.height * this.scaleY / this.content.height / this.content.scaleY; // let rate = rect1.height / rect2.height;
let rate = this.height / this.content.height;
// let rate = this.height * this.scaleY / this.content.height / this.content.scaleY;
if (rate >= 1) { if (rate >= 1) {
this._scrollBar.visible = false; this._scrollBar.visible = false;
rate = 1; rate = 1;
} else { } else {
this._scrollBar.visible = true; this._scrollBar.visible = true;
} }
const h = rate * this.height const h = rate * (this.height)
const r = w / 2; const r = w / 2;
this._scrollBar.setSize(w, h, r); this._scrollBar.setSize(w, h, r);
...@@ -2182,7 +2197,12 @@ export class ScrollView extends MySprite { ...@@ -2182,7 +2197,12 @@ export class ScrollView extends MySprite {
} }
refreshScrollBarPos() { refreshScrollBarPos() {
this._scrollBar.y = -this.content.y * ( this.height / this.content.height ); const rect1 = this.getBoundingBox();
const rect2 = this.content.getBoundingBox();
let rate = rect1.height / rect2.height;
this._scrollBar.y = -rect2.y * (rate );
} }
...@@ -2212,9 +2232,12 @@ export class ScrollView extends MySprite { ...@@ -2212,9 +2232,12 @@ export class ScrollView extends MySprite {
} }
onTouchMove(x, y) { onTouchMove(x, y) {
if (!this.touchStartPos) { if (!this.touchStartPos) {
return; return;
} }
if (!this.touchStartContentPos) { if (!this.touchStartContentPos) {
return; return;
} }
...@@ -2222,10 +2245,12 @@ export class ScrollView extends MySprite { ...@@ -2222,10 +2245,12 @@ export class ScrollView extends MySprite {
const offsetX = x - this.touchStartPos.x; const offsetX = x - this.touchStartPos.x;
const offsetY = y - this.touchStartPos.y; const offsetY = y - this.touchStartPos.y;
const rect = this.getBoundingBox();
if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) { if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) {
this.content.y = between(this.touchStartContentPos.y + offsetY, 0, this.getBoundingBox().height - this.content.height); this.content.y = between(this.touchStartContentPos.y + offsetY, 0, -rect.y + rect.height - this.content.height);
} else { } else {
this.content.x = between(this.touchStartContentPos.x + offsetX, 0, this.getBoundingBox().width - this.content.width); this.content.x = between(this.touchStartContentPos.x + offsetX, 0, -rect.x + rect.width - this.content.width);
} }
this.refreshScrollBarPos(); this.refreshScrollBarPos();
} }
...@@ -2239,10 +2264,12 @@ export class ScrollView extends MySprite { ...@@ -2239,10 +2264,12 @@ export class ScrollView extends MySprite {
if (!this._scrollBar.visible) { if (!this._scrollBar.visible) {
return; return;
} }
const rect = this.getBoundingBox();
if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) { if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) {
this.content.y = between(this.content.y + 40, 0, this.getBoundingBox().height - this.content.height); this.content.y = between(this.content.y + 40, 0, -rect.y + rect.height - this.content.height);
} else { } else {
this.content.x = between(this.content.x + 40, 0, this.getBoundingBox().width - this.content.width); this.content.x = between(this.content.x + 40, 0, -rect.x + rect.width - this.content.width);
} }
this.refreshScrollBarPos(); this.refreshScrollBarPos();
...@@ -2252,10 +2279,13 @@ export class ScrollView extends MySprite { ...@@ -2252,10 +2279,13 @@ export class ScrollView extends MySprite {
if (!this._scrollBar.visible) { if (!this._scrollBar.visible) {
return; return;
} }
const rect = this.getBoundingBox();
if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) { if (this.scrollSide == ScrollView.ScrollSideType.VERTICAL) {
this.content.y = between(this.content.y - 40, 0, this.getBoundingBox().height - this.content.height); this.content.y = between(this.content.y - 40, 0, -rect.y + rect.height - this.content.height);
} else { } else {
this.content.x = between(this.content.x - 40, 0, this.getBoundingBox().width - this.content.width); this.content.x = between(this.content.x - 40, 0, -rect.x + rect.width - this.content.width);
} }
this.refreshScrollBarPos(); this.refreshScrollBarPos();
......
...@@ -158,12 +158,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -158,12 +158,12 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initPageData(aspect); this.initPageData(aspect);
} }
if (data && typeof data == 'object') { // if (data && typeof data == 'object') {
this.data = { contentObj: data }; // this.data = { contentObj: data };
} else { // } else {
this.initDefaultData(); this.initDefaultData();
} // }
console.log('data:', data); console.log('data:', data);
if (!this.data) { if (!this.data) {
...@@ -230,7 +230,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -230,7 +230,7 @@ export class PlayComponent implements OnInit, OnDestroy {
initDefaultData() { initDefaultData() {
const data = {"sentenceArr":[{"text":"1. She was not only _ but also very musical.","answer":"starfish"},{"text":"2. A _ is a flat sea creature in the shape of a star with five arms.","answer":"sea horse"},{"text":"3. A _ is a small sea fish with a horse-like head.","answer":"stream"},{"text":"4. There was a small _ at the end of the garden.","answer":"intelligent"}],"templateArr":[{"formUrl":"https://staging-teach.cdn.ireadabc.com/h5template/JM_4-2/v11/index.html?type=form&key=1","template":{"id":740,"uuid":"b4279bef-f779-4ab7-be76-f1af96713a86","name":"JM_4-2","description":"JM04-02拼句子","interaction_type":"","recommend_type":"","cover":"https://staging-teach.cdn.ireadabc.com/d5baf57d-0175-4640-93a5-6baaff117867.png","type":1,"t_type":2,"form_url":"index.html?type=form","play_url":"index.html","developer_id":12,"git":"{\"id\":791,\"ssh\":\"git@vcs.ireadabc.com:template/JM_4-2.git\",\"http\":\"https://vcs.ireadabc.com/template/JM_4-2.git\"}","del":0,"publish":1,"last_version":11,"pub_date":null,"is_public":0,"created_date":"2021-07-26T10:01:26.000Z","updated_date":"2021-08-02T03:24:44.000Z"},"data":{"sentenceArr":[{"answer":"Sea horse","text":"1. _ is a small sea fish that swims in a vertical position and has a head that looks like the head of a horse. ","audio_url":"https://staging-teach.cdn.ireadabc.com/a9f91947f324c79d0d640aa4995cbcd2.mp3"},{"answer":"intelligent","text":"2. The dolphin is an _ animal. ","audio_url":"https://staging-teach.cdn.ireadabc.com/291f7ad56dd0999112256172c4331829.mp3"},{"answer":"stream","text":"3. A _ flowed gently down into the valley. ","audio_url":"https://staging-teach.cdn.ireadabc.com/9520380ba7ebf7fedb69b4ced3d53502.mp3"},{"answer":"starfishes","text":"4. In the oceans, you can find _ and sea horses. They are interesting and beautiful sea animals. ","audio_url":"https://staging-teach.cdn.ireadabc.com/41def023ed829fb5faf197b5de29b7cb.mp3"}],"templateArr":[],"title":"请同学们根据图示的主题自己通过朗读创作一篇文章"}},{"formUrl":"https://staging-teach.cdn.ireadabc.com/h5template/JM04-3/v10/index.html?type=form&key=2","template":{"id":733,"uuid":"3900b0f7-d041-490e-9b42-da8d3855633b","name":"JM04-3","description":"JM04-03拼单词","interaction_type":"","recommend_type":"","cover":"https://staging-teach.cdn.ireadabc.com/0455da10-c452-4cec-9f01-530536b886b3.png","type":1,"t_type":2,"form_url":"index.html?type=form","play_url":"index.html","developer_id":119,"git":"{\"id\":784,\"ssh\":\"git@vcs.ireadabc.com:template/JM04-3.git\",\"http\":\"https://vcs.ireadabc.com/template/JM04-3.git\"}","del":0,"publish":1,"last_version":10,"pub_date":null,"is_public":0,"created_date":"2021-07-20T06:18:52.000Z","updated_date":"2021-08-01T13:16:43.000Z"},"data":{"contentObj":{"version":"1.0","dataKey":"DataKey_JM04_3","title":{"NO":"C","mainText":"Solve the puzzle using the given clue","mainTextAudio_url":""},"size":{"wh":"12*12"},"dataArray":[{"image_url":"","audio_url":"","text":"smart and possessing sound knowledge","uuid":"9803c50c-3638-4a6a-a4f8-719bdeaacede","direction":"Across"},{"image_url":"","audio_url":"","direction":"Across","text":"running water flowing on the earth","uuid":"239d1dde-4fea-40a7-bc02-4fe681e6f20c"},{"image_url":"","audio_url":"","direction":"Across","text":"a fish whose head look like those of a horse","uuid":"5ae09383-2c3f-4c35-9ed8-f3f7c463dc3c"},{"image_url":"","audio_url":"","direction":"Down","text":"a star-shaped sea animal","uuid":"c9d5aeeb-e37a-41a7-8473-df34d28f1779"}],"grid":[[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"s"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[1],"text":"s"},{"index":[3],"text":"t"},{"index":[1],"text":"r"},{"index":[1],"text":"e"},{"index":[1],"text":"a"},{"index":[1],"text":"m"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[2],"text":"s"},{"index":[2],"text":"e"},{"index":[3],"text":"a"},{"index":[2],"text":"h"},{"index":[2],"text":"o"},{"index":[2],"text":"r"},{"index":[2],"text":"s"},{"index":[2],"text":"e"},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"r"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"f"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"i"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"s"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"h"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[0],"text":"i"},{"index":[0],"text":"n"},{"index":[0],"text":"t"},{"index":[3],"text":"e"},{"index":[0],"text":"l"},{"index":[0],"text":"l"},{"index":[0],"text":"i"},{"index":[0],"text":"g"},{"index":[0],"text":"e"},{"index":[0],"text":"n"},{"index":[0],"text":"t"}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[3],"text":"s"},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}],[{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""},{"index":[],"text":""}]]}}}],"title":"Vocabulary box","bg_url":"https://staging-teach.cdn.ireadabc.com/892d0db2075efa3fa7aea6911bf36a83.png"} const data = {"sentenceArr":[{"text":"1. She was not only _ but also very musical.","answer":"starfish"},{"text":"2. A _ is a flat sea creature in the shape of a star with five arms.","answer":"sea horse"},{"text":"3. A _ is a small sea fish with a horse-like head.","answer":"stream"},{"text":"4. There was a small _ at the end of the garden.","answer":"intelligent"}],"templateArr":[{"formUrl":"https://staging-teach.cdn.ireadabc.com/h5template/JM04-3/v14/index.html?type=form&key=1","template":{"id":733,"uuid":"3900b0f7-d041-490e-9b42-da8d3855633b","name":"JM04-3","description":"JM04-03拼单词","interaction_type":"","recommend_type":"","cover":"https://staging-teach.cdn.ireadabc.com/0455da10-c452-4cec-9f01-530536b886b3.png","type":1,"t_type":2,"form_url":"index.html?type=form","play_url":"index.html","developer_id":119,"git":"{\"id\":784,\"ssh\":\"git@vcs.ireadabc.com:template/JM04-3.git\",\"http\":\"https://vcs.ireadabc.com/template/JM04-3.git\"}","del":0,"publish":1,"last_version":14,"pub_date":null,"is_public":0,"created_date":"2021-07-20T06:18:52.000Z","updated_date":"2021-08-11T13:46:52.000Z"}},{"formUrl":"https://staging-teach.cdn.ireadabc.com/h5template/JM04-3/v14/index.html?type=form&key=2","template":{"id":733,"uuid":"3900b0f7-d041-490e-9b42-da8d3855633b","name":"JM04-3","description":"JM04-03拼单词","interaction_type":"","recommend_type":"","cover":"https://staging-teach.cdn.ireadabc.com/0455da10-c452-4cec-9f01-530536b886b3.png","type":1,"t_type":2,"form_url":"index.html?type=form","play_url":"index.html","developer_id":119,"git":"{\"id\":784,\"ssh\":\"git@vcs.ireadabc.com:template/JM04-3.git\",\"http\":\"https://vcs.ireadabc.com/template/JM04-3.git\"}","del":0,"publish":1,"last_version":14,"pub_date":null,"is_public":0,"created_date":"2021-07-20T06:18:52.000Z","updated_date":"2021-08-11T13:46:52.000Z"}}],"title":"Vocabulary box","bg_url":"https://staging-teach.cdn.ireadabc.com/892d0db2075efa3fa7aea6911bf36a83.png"}
this.data = { contentObj: data }; this.data = { contentObj: data };
...@@ -300,6 +300,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -300,6 +300,8 @@ export class PlayComponent implements OnInit, OnDestroy {
return; return;
} }
this.sentenceArr = JSON.parse(JSON.stringify(arr)); this.sentenceArr = JSON.parse(JSON.stringify(arr));
for (let i=0; i<this.sentenceArr.length; i++) { for (let i=0; i<this.sentenceArr.length; i++) {
const text = this.sentenceArr[i].text; const text = this.sentenceArr[i].text;
...@@ -797,7 +799,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -797,7 +799,7 @@ export class PlayComponent implements OnInit, OnDestroy {
resultSv.x = -this.resultPanel.width / 2; resultSv.x = -this.resultPanel.width / 2;
resultSv.y = -this.resultPanel.height / 2 + 120; resultSv.y = -this.resultPanel.height / 2 + 120;
resultSv.setScrollBarSize(20 * this.mapScale, 5); resultSv.setScrollBarSize(20 * this.mapScale, 5);
resultSv.setContentScale(this.mapScale); // resultSv.setContentScale(this.mapScale);
this.resultPanel.addChild(resultSv); this.resultPanel.addChild(resultSv);
this.resultSv = resultSv; this.resultSv = resultSv;
...@@ -819,16 +821,17 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -819,16 +821,17 @@ export class PlayComponent implements OnInit, OnDestroy {
resultSv.addItem(richText); resultSv.addItem(richText);
const rect = richText.getSubTextRect('____________________'); const rectData = richText.getSubTextRect('____________________');
const {rect} = rectData;
rect.width += 8; rect.width += 8;
rect.height += 16; rect.height += 16;
const colorRect = new ShapeRectNew(); const colorRect = new ShapeRectNew();
colorRect.setSize(rect.width, rect.height, 10); colorRect.setSize(rect.width, rect.height, 10);
colorRect.fillColor = '#007b3e' colorRect.fillColor = '#007b3e'
const offX = 9; const offX = 4;
colorRect.x = rect.x + offX; colorRect.x = rect.x + offX - rect.width;
colorRect.y = -rect.height / 2; colorRect.y = -rect.height / 2;
// colorRect.alpha = 0.5; // colorRect.alpha = 0.5;
richText.addChild(colorRect); richText.addChild(colorRect);
...@@ -841,7 +844,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -841,7 +844,7 @@ export class PlayComponent implements OnInit, OnDestroy {
const infoBg = new MySprite(); const infoBg = new MySprite();
infoBg.init(this.images.get("info_bg")); infoBg.init(this.images.get("info_bg"));
infoBg.y = baseY + 50; infoBg.y = baseY + 50;
infoBg.x = this.resultPanel.width / 2 * this.mapScale; infoBg.x = this.resultPanel.width / 2 //* this.mapScale;
resultSv.addItem(infoBg); resultSv.addItem(infoBg);
// this.resultPanel.addChild(infoBg); // this.resultPanel.addChild(infoBg);
baseY += 130; baseY += 130;
...@@ -2097,13 +2100,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2097,13 +2100,7 @@ export class PlayComponent implements OnInit, OnDestroy {
iframecont.contentWindow.postMessage({ action: 'getData', data: JSON.stringify(data) }, '*'); iframecont.contentWindow.postMessage({ action: 'getData', data: JSON.stringify(data) }, '*');
// const data2 = { msg: 'success', data: JSON.stringify({'isShowMore': false})};
// iframecont.contentWindow.postMessage({ action: 'is_show_more', data: JSON.stringify(data2) }, '*');
// setTimeout(() => {
// _this.frameLoaded = true;
// }, 300);
} }
if (msgData.action === "temp_send_result") { if (msgData.action === "temp_send_result") {
......
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