Commit ae5288ab authored by 邱旭's avatar 邱旭

1

parent 1fa2f64c
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<e:Image id="light1" x="376" y="317" anchorOffsetX="356" anchorOffsetY="296" source="scratchbg2_png"/> <e:Image id="light1" x="376" y="317" anchorOffsetX="356" anchorOffsetY="296" source="scratchbg2_png"/>
<e:Image y="259.33" source="scratch_bg_png" horizontalCenter="0"/> <e:Image y="259.33" source="scratch_bg_png" horizontalCenter="0"/>
<e:Group id="con" y="-67"/> <e:Group id="con" y="-67"/>
<e:Label text="共2位好友帮你刮了90.3%" y="381.33" textColor="0xF54500" size="28" horizontalCenter="0" fontFamily="Lucida Family" verticalAlign="middle" textAlign="center"/> <e:Label id="numLabel" text="共2位好友帮你刮了90.3%" y="381.33" textColor="0xF54500" size="28" horizontalCenter="0" fontFamily="Lucida Family" verticalAlign="middle" textAlign="center"/>
<e:Image id="prizeImg" y="439.33" horizontalCenter="0.5" source="" width="510" height="228"/> <e:Image id="prizeImg" y="439.33" horizontalCenter="0.5" source="" width="510" height="228"/>
<e:Button id="closeBtn" label="" x="605" y="219.33"> <e:Button id="closeBtn" label="" x="605" y="219.33">
<e:skinName> <e:skinName>
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
</e:Skin> </e:Skin>
</e:skinName> </e:skinName>
</e:Button> </e:Button>
<e:Label id="numLabel" text="仅差3人可获得" y="679.33" textColor="0xf54500" size="28" horizontalCenter="0" visible="false"/> <e:Label id="cutTimeLabel" text="将在23:43:21后失效" y="895.33" size="28" textColor="0xffffff" horizontalCenter="0.5"/>
<e:Label id="cutTimeLabel" text="将在23:43:21后失效" y="883.33" size="28" textColor="0xffffff" horizontalCenter="0"/> <e:Scroller width="487" height="90" y="783" anchorOffsetX="0" anchorOffsetY="0" horizontalCenter="32.5">
<e:Scroller width="487" height="90" y="775" anchorOffsetX="0" anchorOffsetY="0" horizontalCenter="32.5">
<e:Group anchorOffsetX="0" y="2"> <e:Group anchorOffsetX="0" y="2">
<e:List id="list" x="0" y="0" anchorOffsetX="0"> <e:List id="list" x="0" y="0" anchorOffsetX="0">
<e:layout> <e:layout>
...@@ -43,13 +42,13 @@ ...@@ -43,13 +42,13 @@
<e:Rect fillAlpha="0.7" left="0" top="0" right="0" bottom="0"/> <e:Rect fillAlpha="0.7" left="0" top="0" right="0" bottom="0"/>
<e:Image x="424" y="0" source="scratch_wx_tip_png"/> <e:Image x="424" y="0" source="scratch_wx_tip_png"/>
</e:Group> </e:Group>
<e:Group x="133" y="711" width="437" height="22"> <e:Group x="124" y="692" width="506" height="57" anchorOffsetX="0" anchorOffsetY="0">
<e:Image id="progressMask" source="scratch_progress_bg_png" anchorOffsetX="0" anchorOffsetY="0" horizontalCenter="0" verticalCenter="0"/> <e:Image id="progressMask" source="scratch_progress_bg_png" anchorOffsetX="0" anchorOffsetY="0" x="7" verticalCenter="0"/>
<e:Group id="progressGroup" horizontalCenter="0" verticalCenter="0"> <e:Group id="progressGroup" x="8" verticalCenter="0">
<e:Image id="progressBg" source="scratch_progress_bg_png" anchorOffsetX="0" anchorOffsetY="0" x="0" y="0" width="437" height="22"/> <e:Image id="progressBg" source="scratch_progress_bg_png" anchorOffsetX="0" anchorOffsetY="0" x="0" y="0" width="437" height="22"/>
<e:Rect id="progress" fillColor="0xeb1917" left="0" verticalCenter="0" width="99" height="22"/> <e:Rect id="progress" fillColor="0xeb1917" left="0" verticalCenter="0" width="0" top="0" bottom="0"/>
<e:Label text="仅剩90.7%" size="18" verticalCenter="0" horizontalCenter="0"/> <e:Label id="progressLabel" text="仅剩90.7%" size="18" verticalCenter="0" horizontalCenter="0"/>
</e:Group> </e:Group>
<e:Image id="hongbao" source="scratch_hongbao_png" scaleX="1" scaleY="1" verticalCenter="0" horizontalCenter="219"/>
</e:Group> </e:Group>
<e:Image id="hongbao" x="586" y="697" source="scratch_hongbao_png"/>
</e:Skin> </e:Skin>
\ No newline at end of file
...@@ -28,6 +28,22 @@ export default class Utils { ...@@ -28,6 +28,22 @@ export default class Utils {
return this.getRequest()[key]; return this.getRequest()[key];
} }
/**
* 时间戳转几时几分几秒
* @param time 时间戳
*/
public static convertTime(time: number) {
let hour = ~~(time / 3600000); // 小时
let min = ~~((time - hour * 3600000) / 60000); // 分
let sec = ~~((time - hour * 3600000 - min * 60000) / 1000); // 秒
return {
hour: Utils.prefixInteger(hour, 2),
min: Utils.prefixInteger(min, 2),
sec: Utils.prefixInteger(sec, 2)
}
}
/** /**
* 数字补0 * 数字补0
* @param num 数字 * @param num 数字
......
...@@ -70,7 +70,13 @@ export default class MapScene extends Scene { ...@@ -70,7 +70,13 @@ export default class MapScene extends Scene {
async start(data?) { async start(data?) {
// PanelCtrl.instance.show('scratch'); NetManager.ins.getInviteInfo((success, res)=>{
if(!success){
}
PanelCtrl.instance.show('scratch', res.data);
});
super.start(); super.start();
this.sendInvite(); this.sendInvite();
......
...@@ -7,22 +7,6 @@ import Utils from "../Utils"; ...@@ -7,22 +7,6 @@ import Utils from "../Utils";
import ScratchRulePanel from "./ScratchRulePanel"; import ScratchRulePanel from "./ScratchRulePanel";
export default class ScratchPanel extends Panel { export default class ScratchPanel extends Panel {
public light2:eui.Image;
public light1:eui.Image;
public con:eui.Group;
public prizeImg:eui.Image;
public closeBtn:eui.Button;
public helpBtn:eui.Button;
public numLabel:eui.Label;
public cutTimeLabel:eui.Label;
public list:eui.List;
public wxShareTip:eui.Group;
public progressMask:eui.Image;
public progressGroup:eui.Group;
public progressBg:eui.Image;
public progress:eui.Rect;
public hongbao:eui.Image;
private invite_img: egret.Texture; private invite_img: egret.Texture;
private timer: egret.Timer; private timer: egret.Timer;
private cutTime: number; private cutTime: number;
...@@ -51,8 +35,8 @@ export default class ScratchPanel extends Panel { ...@@ -51,8 +35,8 @@ export default class ScratchPanel extends Panel {
playBgAni() { playBgAni() {
this['light1'].visible = this['light2'].visible = true; this['light1'].visible = this['light2'].visible = true;
const time = 7000; const time = 7000;
egret.Tween.get(this['light1'], { loop: true }).to({ rotation: 360 }, time); egret.Tween.get(this['light1'], {loop: true}).to({rotation: 360}, time);
egret.Tween.get(this['light2'], { loop: true }).to({ rotation: -360 }, time); egret.Tween.get(this['light2'], {loop: true}).to({rotation: -360}, time);
} }
showlog() { showlog() {
...@@ -61,19 +45,25 @@ export default class ScratchPanel extends Panel { ...@@ -61,19 +45,25 @@ export default class ScratchPanel extends Panel {
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this); this["closeBtn"].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.helpBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapRule, this); this["helpBtn"].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapRule, this);
this["wxShareTip"].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this["wxShareTip"].visible = false;
}, this);
} }
onTouchTap_closeBtn() { onTouchTap_closeBtn() {
GDispatcher.dispatchEvent("getInviteInfo"); // GDispatcher.dispatchEvent("getInviteInfo");
super.onTouchTap_closeBtn(); super.onTouchTap_closeBtn();
} }
removeEvents() { removeEvents() {
super.removeEvents(); super.removeEvents();
this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this); this["closeBtn"].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap_closeBtn, this);
this.helpBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapRule, this); this["helpBtn"].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapRule, this);
this["wxShareTip"].removeEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this["wxShareTip"].visible = false;
}, this);
} }
onTapRule() { onTapRule() {
...@@ -88,97 +78,99 @@ export default class ScratchPanel extends Panel { ...@@ -88,97 +78,99 @@ export default class ScratchPanel extends Panel {
} }
initUI() { initUI() {
this.hongbaoEffect();
this.setWXShareTip(); this.setWXShareTip();
this.progressGroup.mask = this.progressMask; this["progressGroup"].mask = this["progressMask"];
this.setProgress(90.7); this.setProgress(90.3);
this['numLabel'] = `共${this.data.invitationUser.length}位好友帮你刮了${90.3}%`;
// this.prizeImg.source = this.data.prizeImg;
// if (!this.data.invitationUser) { this["prizeImg"].source = this.data.prizeImg;
// this.data.invitationUser = []; if (!this.data.invitationUser) {
// } this.data.invitationUser = [];
// let dNum = this.data.invitationCount - this.data.invitationUser.length; }
// this.numLabel.text = `仅差${dNum}人可获得`;
// let dNum = this.data.invitationCount - this.data.invitationUser.length;
// for (let i = 0; i < dNum; i++) { for (let i = 0; i < dNum; i++) {
// this.data.invitationUser.push({ this.data.invitationUser.push({
// nickname: "nickname", nickname: "nickname",
// avatar: this.invite_img, avatar: this.invite_img,
// }); });
// } }
// for (let i = 0; i < this.data.invitationUser.length; i++) { for (let i = 0; i < this.data.invitationUser.length; i++) {
// this.data.invitationUser[i]['callFun'] = () => { this.data.invitationUser[i]['callFun'] = () => {
// NetManager.ins.getShareCode((success, res) => { NetManager.ins.getShareCode((success, res) => {
// if (!success) { if (!success) {
// return; return;
// } }
// let shareCode = res.data; // 分享码 let shareCode = res.data; // 分享码
// CFG.wxShareLink = window['h5URL'] + "&shareCode=" + shareCode; // 分享链接 CFG.wxShareLink = window['h5URL'] + "&shareCode=" + shareCode; // 分享链接
// CFG.wxShareTitle = '狮狮连萌超好玩~我已经玩到第一了!'; CFG.wxShareTitle = '狮狮连萌超好玩~我已经玩到第一了!';
// CFG.wxShareDesc = '我在萌狮消消乐等你来挑战哦'; CFG.wxShareDesc = '我在萌狮消消乐等你来挑战哦';
// CFG.wxShareImg="http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg"; CFG.wxShareImg="http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg";
// if (iswx()) { //微信端 if (iswx()) { //微信端
// this.wxShareTip.visible = true; this["wxShareTip"].visible = true;
// window["invokeWX"](); window["invokeWX"]();
// } else {//端内 } else {//端内
// this.wxShareTip.visible = false; this["wxShareTip"].visible = false;
// window["inviteShare"](shareCode); window["inviteShare"](shareCode);
// } }
// }); });
// } }
// } }
// this.list.useVirtualLayout = false; this["list"].useVirtualLayout = false;
// this.list.itemRenderer = ScratchItem; this["list"].itemRenderer = ScratchItem;
// this.list.dataProvider = new eui.ArrayCollection(this.data.invitationUser); this["list"].dataProvider = new eui.ArrayCollection(this.data.invitationUser);
//
// this.cutTime = this.data.endTime - this.data.sysTime + 5000; this.cutTime = this.data.endTime - this.data.sysTime + 5000;
// if (this.timer) { if (this.timer) {
// this.timer.stop(); this.timer.stop();
// } }
// this.timer = new egret.Timer(1000, 0); this.timer = new egret.Timer(1000, 0);
// this.timer.addEventListener(egret.TimerEvent.TIMER, this.cutTimer, this); this.timer.addEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
// this.timer.start(); this.timer.start();
// this.cutTimer(); this.cutTimer();
} }
/**
* 设置进度条
* @param progress 进度 0 - 100
*/
private setProgress(progress) { private setProgress(progress) {
if(progress > 100) { if(progress > 100) {
progress = 100; progress = 100;
} else if(progress < 0) { } else if(progress < 0) {
progress = 0; progress = 0;
} }
this.progress.width = this.progressBg.width * progress / 100; this["progressLabel"].text = `仅剩${(100 - progress).toFixed(2)}%`; // 进度条文字
let _width = this["progressBg"].width * progress / 100; // 宽度
let dProgress = Math.abs(progress - this["progress"].width / this["progressBg"].width); // 比当前进度的差值的绝对值
let _duration = 2000 * dProgress / 100; // 算出变化的时间
egret.Tween.get(this["progress"]).to({width: _width}, _duration);
} }
private cutTimer() { private cutTimer() {
let timer = this.convertTime(this.cutTime -= 1000); let timer = Utils.convertTime(this.cutTime -= 1000);
if(timer.hour === "00" if(timer.hour === "00"
&& timer.min === "00" && timer.min === "00"
&& timer.sec === "00") { && timer.sec === "00") {
this.timer.stop(); this.timer.stop();
this.hidePanel(); this.hidePanel();
} }
this.cutTimeLabel.text = `将在${timer.hour}:${timer.min}:${timer.sec}后失效`; this["cutTimeLabel"].text = `将在${timer.hour}:${timer.min}:${timer.sec}后失效`;
} }
private convertTime(time: number) { private setWXShareTip() {
let hour = ~~(time / 3600000); // 小时 this["wxShareTip"].visible = false;
let min = ~~((time - hour * 3600000) / 60000); // 分 this["wxShareTip"].width = this.width / window.innerWidth * window.innerWidth;
let sec = ~~((time - hour * 3600000 - min * 60000) / 1000); // 秒 this["wxShareTip"].height = this.width / window.innerWidth * window.innerHeight;
return {
hour: Utils.prefixInteger(hour, 2),
min: Utils.prefixInteger(min, 2),
sec: Utils.prefixInteger(sec, 2)
}
} }
private setWXShareTip() { private hongbaoEffect(){
this.wxShareTip.visible = false; egret.Tween.get(this["hongbao"]).to({scaleX:0.8, scaleY:0.8}, 300, egret.Ease.quadInOut).call(()=>{
this.wxShareTip.width = this.width / window.innerWidth * window.innerWidth; egret.Tween.get(this["hongbao"]).to({scaleX:1, scaleY:1}, 200, egret.Ease.quadInOut).wait(1500).call(()=>{
this.wxShareTip.height = this.width / window.innerWidth * window.innerHeight; this.hongbaoEffect();
this.wxShareTip.addEventListener(egret.TouchEvent.TOUCH_TAP, () => { });
this.wxShareTip.visible = false; });
}, this);
} }
protected get closeBtns(): eui.Button[] { protected get closeBtns(): eui.Button[] {
......
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