Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaole
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
xiaoxiaole
Commits
ae5288ab
Commit
ae5288ab
authored
Oct 24, 2019
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
1fa2f64c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
103 deletions
+116
-103
ScratchSkin.exml
egret/resource/skins/ScratchSkin.exml
+9
-10
Utils.ts
egret/src/Utils.ts
+16
-0
MapScene.ts
egret/src/mapScene/MapScene.ts
+7
-1
ScratchPanel.ts
egret/src/panels/ScratchPanel.ts
+84
-92
No files found.
egret/resource/skins/ScratchSkin.exml
View file @
ae5288ab
...
...
@@ -6,7 +6,7 @@
<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: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:Button
id=
"closeBtn"
label=
""
x=
"605"
y=
"219.33"
>
<e:skinName>
...
...
@@ -25,9 +25,8 @@
</e:Skin>
</e:skinName>
</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=
"883.33"
size=
"28"
textColor=
"0xffffff"
horizontalCenter=
"0"
/>
<e:Scroller
width=
"487"
height=
"90"
y=
"775"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
horizontalCenter=
"32.5"
>
<e:Label
id=
"cutTimeLabel"
text=
"将在23:43:21后失效"
y=
"895.33"
size=
"28"
textColor=
"0xffffff"
horizontalCenter=
"0.5"
/>
<e:Scroller
width=
"487"
height=
"90"
y=
"783"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
horizontalCenter=
"32.5"
>
<e:Group
anchorOffsetX=
"0"
y=
"2"
>
<e:List
id=
"list"
x=
"0"
y=
"0"
anchorOffsetX=
"0"
>
<e:layout>
...
...
@@ -43,13 +42,13 @@
<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:Group>
<e:Group
x=
"1
33"
y=
"711"
width=
"437"
height=
"22
"
>
<e:Image
id=
"progressMask"
source=
"scratch_progress_bg_png"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
horizontalCenter=
"0
"
verticalCenter=
"0"
/>
<e:Group
id=
"progressGroup"
horizontalCenter=
"0
"
verticalCenter=
"0"
>
<e:Group
x=
"1
24"
y=
"692"
width=
"506"
height=
"57"
anchorOffsetX=
"0"
anchorOffsetY=
"0
"
>
<e:Image
id=
"progressMask"
source=
"scratch_progress_bg_png"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
x=
"7
"
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:Rect
id=
"progress"
fillColor=
"0xeb1917"
left=
"0"
verticalCenter=
"0"
width=
"
99"
height=
"22
"
/>
<e:Label
text=
"仅剩90.7%"
size=
"18"
verticalCenter=
"0"
horizontalCenter=
"0"
/>
<e:Rect
id=
"progress"
fillColor=
"0xeb1917"
left=
"0"
verticalCenter=
"0"
width=
"
0"
top=
"0"
bottom=
"0
"
/>
<e:Label
id=
"progressLabel"
text=
"仅剩90.7%"
size=
"18"
verticalCenter=
"0"
horizontalCenter=
"0"
/>
</e:Group>
<e:Image
id=
"hongbao"
source=
"scratch_hongbao_png"
scaleX=
"1"
scaleY=
"1"
verticalCenter=
"0"
horizontalCenter=
"219"
/>
</e:Group>
<e:Image
id=
"hongbao"
x=
"586"
y=
"697"
source=
"scratch_hongbao_png"
/>
</e:Skin>
\ No newline at end of file
egret/src/Utils.ts
View file @
ae5288ab
...
...
@@ -28,6 +28,22 @@ export default class Utils {
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
* @param num 数字
...
...
egret/src/mapScene/MapScene.ts
View file @
ae5288ab
...
...
@@ -70,7 +70,13 @@ export default class MapScene extends Scene {
async
start
(
data
?)
{
// PanelCtrl.instance.show('scratch');
NetManager
.
ins
.
getInviteInfo
((
success
,
res
)
=>
{
if
(
!
success
){
}
PanelCtrl
.
instance
.
show
(
'scratch'
,
res
.
data
);
});
super
.
start
();
this
.
sendInvite
();
...
...
egret/src/panels/ScratchPanel.ts
View file @
ae5288ab
...
...
@@ -7,22 +7,6 @@ import Utils from "../Utils";
import
ScratchRulePanel
from
"./ScratchRulePanel"
;
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
timer
:
egret
.
Timer
;
private
cutTime
:
number
;
...
...
@@ -51,8 +35,8 @@ export default class ScratchPanel extends Panel {
playBgAni
()
{
this
[
'light1'
].
visible
=
this
[
'light2'
].
visible
=
true
;
const
time
=
7000
;
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
[
'light1'
],
{
loop
:
true
}).
to
({
rotation
:
360
},
time
);
egret
.
Tween
.
get
(
this
[
'light2'
],
{
loop
:
true
}).
to
({
rotation
:
-
360
},
time
);
}
showlog
()
{
...
...
@@ -61,19 +45,25 @@ export default class ScratchPanel extends Panel {
initEvents
()
{
super
.
initEvents
();
this
.
closeBtn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTouchTap_closeBtn
,
this
);
this
.
helpBtn
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTapRule
,
this
);
this
[
"closeBtn"
].
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTouchTap_closeBtn
,
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
()
{
GDispatcher
.
dispatchEvent
(
"getInviteInfo"
);
//
GDispatcher.dispatchEvent("getInviteInfo");
super
.
onTouchTap_closeBtn
();
}
removeEvents
()
{
super
.
removeEvents
();
this
.
closeBtn
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTouchTap_closeBtn
,
this
);
this
.
helpBtn
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTapRule
,
this
);
this
[
"closeBtn"
].
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTouchTap_closeBtn
,
this
);
this
[
"helpBtn"
].
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
onTapRule
,
this
);
this
[
"wxShareTip"
].
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
()
=>
{
this
[
"wxShareTip"
].
visible
=
false
;
},
this
);
}
onTapRule
()
{
...
...
@@ -88,97 +78,99 @@ export default class ScratchPanel extends Panel {
}
initUI
()
{
this
.
hongbaoEffect
();
this
.
setWXShareTip
();
this
.
progressGroup
.
mask
=
this
.
progressMask
;
this
.
setProgress
(
90.
7
);
// this.prizeImg.source = this.data.prizeImg;
// if (!this.data.invitationUser) {
// this.data.invitationUser = [];
// }
// let dNum = this.data.invitationCount - this.data.invitationUser.length;
// this.numLabel.text = `仅差${dNum}人可获得`;
//
//
for (let i = 0; i < dNum; i++) {
//
this.data.invitationUser.push({
//
nickname: "nickname",
//
avatar: this.invite_img,
//
});
//
}
//
for (let i = 0; i < this.data.invitationUser.length; i++) {
//
this.data.invitationUser[i]['callFun'] = () => {
//
NetManager.ins.getShareCode((success, res) => {
//
if (!success) {
//
return;
//
}
//
let shareCode = res.data; // 分享码
//
CFG.wxShareLink = window['h5URL'] + "&shareCode=" + shareCode; // 分享链接
//
CFG.wxShareTitle = '狮狮连萌超好玩~我已经玩到第一了!';
//
CFG.wxShareDesc = '我在萌狮消消乐等你来挑战哦';
//
CFG.wxShareImg="http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg";
//
if (iswx()) { //微信端
// this.wxShareTip
.visible = true;
//
window["invokeWX"]();
//
} else {//端内
// this.wxShareTip
.visible = false;
//
window["inviteShare"](shareCode);
//
}
//
});
//
}
//
}
// this.list
.useVirtualLayout = false;
// this.list
.itemRenderer = ScratchItem;
// this.list
.dataProvider = new eui.ArrayCollection(this.data.invitationUser);
//
//
this.cutTime = this.data.endTime - this.data.sysTime + 5000;
//
if (this.timer) {
//
this.timer.stop();
//
}
//
this.timer = new egret.Timer(1000, 0);
//
this.timer.addEventListener(egret.TimerEvent.TIMER, this.cutTimer, this);
//
this.timer.start();
//
this.cutTimer();
this
[
"progressGroup"
].
mask
=
this
[
"progressMask"
]
;
this
.
setProgress
(
90.
3
);
this
[
'numLabel'
]
=
`共
${
this
.
data
.
invitationUser
.
length
}
位好友帮你刮了
${
90.3
}
%`
;
this
[
"prizeImg"
].
source
=
this
.
data
.
prizeImg
;
if
(
!
this
.
data
.
invitationUser
)
{
this
.
data
.
invitationUser
=
[];
}
let
dNum
=
this
.
data
.
invitationCount
-
this
.
data
.
invitationUser
.
length
;
for
(
let
i
=
0
;
i
<
dNum
;
i
++
)
{
this
.
data
.
invitationUser
.
push
({
nickname
:
"nickname"
,
avatar
:
this
.
invite_img
,
});
}
for
(
let
i
=
0
;
i
<
this
.
data
.
invitationUser
.
length
;
i
++
)
{
this
.
data
.
invitationUser
[
i
][
'callFun'
]
=
()
=>
{
NetManager
.
ins
.
getShareCode
((
success
,
res
)
=>
{
if
(
!
success
)
{
return
;
}
let
shareCode
=
res
.
data
;
// 分享码
CFG
.
wxShareLink
=
window
[
'h5URL'
]
+
"&shareCode="
+
shareCode
;
// 分享链接
CFG
.
wxShareTitle
=
'狮狮连萌超好玩~我已经玩到第一了!'
;
CFG
.
wxShareDesc
=
'我在萌狮消消乐等你来挑战哦'
;
CFG
.
wxShareImg
=
"http://yun.duiba.com.cn/db_games/xiaoxiaole2.jpg"
;
if
(
iswx
())
{
//微信端
this
[
"wxShareTip"
]
.
visible
=
true
;
window
[
"invokeWX"
]();
}
else
{
//端内
this
[
"wxShareTip"
]
.
visible
=
false
;
window
[
"inviteShare"
](
shareCode
);
}
});
}
}
this
[
"list"
]
.
useVirtualLayout
=
false
;
this
[
"list"
]
.
itemRenderer
=
ScratchItem
;
this
[
"list"
]
.
dataProvider
=
new
eui
.
ArrayCollection
(
this
.
data
.
invitationUser
);
this
.
cutTime
=
this
.
data
.
endTime
-
this
.
data
.
sysTime
+
5000
;
if
(
this
.
timer
)
{
this
.
timer
.
stop
();
}
this
.
timer
=
new
egret
.
Timer
(
1000
,
0
);
this
.
timer
.
addEventListener
(
egret
.
TimerEvent
.
TIMER
,
this
.
cutTimer
,
this
);
this
.
timer
.
start
();
this
.
cutTimer
();
}
/**
* 设置进度条
* @param progress 进度 0 - 100
*/
private
setProgress
(
progress
)
{
if
(
progress
>
100
)
{
progress
=
100
;
}
else
if
(
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
()
{
let
timer
=
thi
s
.
convertTime
(
this
.
cutTime
-=
1000
);
let
timer
=
Util
s
.
convertTime
(
this
.
cutTime
-=
1000
);
if
(
timer
.
hour
===
"00"
&&
timer
.
min
===
"00"
&&
timer
.
sec
===
"00"
)
{
this
.
timer
.
stop
();
this
.
hidePanel
();
}
this
.
cutTimeLabel
.
text
=
`将在
${
timer
.
hour
}
:
${
timer
.
min
}
:
${
timer
.
sec
}
后失效`
;
this
[
"cutTimeLabel"
]
.
text
=
`将在
${
timer
.
hour
}
:
${
timer
.
min
}
:
${
timer
.
sec
}
后失效`
;
}
private
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
)
}
private
setWXShareTip
()
{
this
[
"wxShareTip"
].
visible
=
false
;
this
[
"wxShareTip"
].
width
=
this
.
width
/
window
.
innerWidth
*
window
.
innerWidth
;
this
[
"wxShareTip"
].
height
=
this
.
width
/
window
.
innerWidth
*
window
.
innerHeight
;
}
private
setWXShareTip
()
{
this
.
wxShareTip
.
visible
=
false
;
this
.
wxShareTip
.
width
=
this
.
width
/
window
.
innerWidth
*
window
.
innerWidth
;
this
.
wxShareTip
.
height
=
this
.
width
/
window
.
innerWidth
*
window
.
innerHeight
;
this
.
wxShareTip
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
()
=>
{
this
.
wxShareTip
.
visible
=
false
;
},
this
);
private
hongbaoEffect
(){
egret
.
Tween
.
get
(
this
[
"hongbao"
]).
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
300
,
egret
.
Ease
.
quadInOut
).
call
(()
=>
{
egret
.
Tween
.
get
(
this
[
"hongbao"
]).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
,
egret
.
Ease
.
quadInOut
).
wait
(
1500
).
call
(()
=>
{
this
.
hongbaoEffect
();
});
});
}
protected
get
closeBtns
():
eui
.
Button
[]
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment