Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wfc13
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wildfirecode13
wfc13
Commits
7668c2c0
Commit
7668c2c0
authored
Aug 04, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
c4a1a1a0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
181 additions
and
12 deletions
+181
-12
index.do.json
project/mock/webNet/game/index.do.json
+3
-2
Main.ts
project/src/Main.ts
+11
-6
CarouselComponent.ts
project/src/common/CarouselComponent.ts
+156
-0
prize.ts
project/src/panels/prize.ts
+3
-1
NewbieScene.ts
project/src/template/NewbieScene.ts
+2
-3
ShareScene.ts
project/src/template/ShareScene.ts
+1
-0
updateShare.ts
project/src/updateShare.ts
+5
-0
No files found.
project/mock/webNet/game/index.do.json
View file @
7668c2c0
...
...
@@ -3,7 +3,8 @@
"message"
:
""
,
"code"
:
""
,
"data"
:
{
"shareCode"
:
"123"
,
"isNewbie"
:
true
"shareCode"
:
"d8kadf2"
,
"isNewbie"
:
true
,
"amount"
:
1000
}
}
\ No newline at end of file
project/src/Main.ts
View file @
7668c2c0
...
...
@@ -16,11 +16,12 @@ import { ShareFailPanel } from "./panels/share_fail";
import
{
ShareSuccessPanel
}
from
"./panels/share_success"
;
import
{
isFromShare
}
from
"duiba-utils"
;
import
getQueryParams
from
"./getQueryParams"
;
import
updateShare
from
"./updateShare"
;
const
isShare
=
()
=>
{
const
query
=
getQueryParams
();
console
.
log
(
'query'
,
query
);
return
query
&&
query
.
sxbankIsSharePage
==
1
;
console
.
log
(
'query'
,
query
);
return
query
&&
query
.
sxbankIsSharePage
==
1
;
};
/**
...
...
@@ -76,14 +77,18 @@ export class Main {
//显示场景
if
(
isShare
())
{
changeScene
(
ShareScene
);
changeScene
(
ShareScene
,{
query
:
getQueryParams
()}
);
}
else
{
const
indexResult
=
await
sendWebNet
(
WebNetName
.
index
)
if
(
indexResult
&&
indexResult
.
success
&&
indexResult
.
data
)
{
if
(
indexResult
.
data
.
isNewbie
)
changeScene
(
NewbieScene
)
else
if
(
indexResult
.
data
.
isNewbie
)
{
updateShare
(
'inNewbieScene'
,
indexResult
.
data
.
shareCode
,
0
,
0
);
changeScene
(
NewbieScene
,
{
shareCode
:
indexResult
.
data
.
shareCode
});
}
else
{
updateShare
(
'inIndexScene'
,
indexResult
.
data
.
shareCode
,
indexResult
.
data
.
amount1
,
indexResult
.
data
.
amount2
)
changeScene
(
IndexScene
)
}
}
else
{
//网络异常??
}
...
...
project/src/common/CarouselComponent.ts
0 → 100644
View file @
7668c2c0
export
class
CarouselComponent
extends
FYGE
.
Container
{
bgContainer
:
FYGE
.
Container
;
itemComponent
:
any
;
itemWidth
:
number
;
itemHeight
:
number
;
vertical
:
boolean
;
timer
:
any
;
listContainer1
:
any
;
listContainer2
:
any
;
listWidth
:
number
;
listHeight
:
number
;
bgmask
:
FYGE
.
Graphics
;
num
:
number
;
k
:
number
;
//缓动系数,系数越大移动越快。在0-1之间。
totalStep
:
number
;
//累计移动了多少距离
stopStep
:
number
;
//滑动多少距离之后暂停一下
/**
*
* @param itemComponent //item组件
* @param itemWidth //每一个item的宽度
* @param itemHeight //每一个item的高度
* @param vertical //是否是垂直的
* @param num //要显示的个数
* @param k ////缓动系数,系数越大移动越快。在0-1之间
*/
constructor
(
itemComponent
,
itemWidth
,
itemHeight
,
vertical
=
false
,
num
=
3
,
k
=
0.24
)
{
super
();
this
.
num
=
num
;
this
.
totalStep
=
0
;
this
.
bgContainer
=
new
FYGE
.
Container
();
this
.
itemComponent
=
itemComponent
;
this
.
itemHeight
=
itemHeight
;
this
.
itemWidth
=
itemWidth
;
this
.
vertical
=
vertical
;
this
.
k
=
k
;
if
(
this
.
vertical
)
{
this
.
stopStep
=
itemHeight
;
this
.
bgmask
=
new
FYGE
.
Graphics
();
this
.
bgmask
.
beginFill
();
this
.
bgmask
.
drawRect
(
0
,
0
,
itemWidth
,
num
*
itemHeight
)
this
.
bgmask
.
endFill
();
}
else
{
this
.
stopStep
=
itemWidth
;
this
.
bgmask
=
new
FYGE
.
Graphics
();
this
.
bgmask
.
beginFill
();
this
.
bgmask
.
drawRect
(
0
,
0
,
num
*
itemWidth
,
itemHeight
)
this
.
bgmask
.
endFill
();
}
}
//更新数据触发轮播
updateData
(
data
)
{
this
.
removeChildren
();
this
.
bgContainer
.
removeChildren
();
this
.
timer
&&
clearTimeout
(
this
.
timer
);
this
.
timer
=
null
;
this
.
addChild
(
this
.
bgmask
);
this
.
listContainer1
=
new
FYGE
.
Container
();
this
.
listContainer2
=
new
FYGE
.
Container
();
data
.
forEach
((
el
,
index
)
=>
{
let
picture1
=
new
this
.
itemComponent
(
el
);
let
picture2
=
new
this
.
itemComponent
(
el
);
if
(
!
this
.
vertical
)
{
picture1
.
position
.
set
(
index
*
this
.
itemWidth
,
0
);
picture2
.
position
.
set
(
index
*
this
.
itemWidth
,
0
);
}
else
{
picture1
.
position
.
set
(
0
,
index
*
this
.
itemHeight
);
picture2
.
position
.
set
(
0
,
index
*
this
.
itemHeight
);
}
this
.
listContainer1
.
addChild
(
picture1
);
this
.
listContainer2
.
addChild
(
picture2
);
})
if
(
!
this
.
vertical
)
{
this
.
listWidth
=
data
.
length
*
this
.
itemWidth
;
this
.
listContainer1
.
position
.
set
(
0
,
0
)
this
.
listContainer2
.
position
.
set
(
data
.
length
*
this
.
itemWidth
,
0
)
}
else
{
this
.
listHeight
=
data
.
length
*
this
.
itemHeight
;
this
.
listContainer1
.
position
.
set
(
0
,
0
)
this
.
listContainer2
.
position
.
set
(
0
,
data
.
length
*
this
.
itemHeight
)
}
this
.
bgContainer
.
addChild
(
this
.
listContainer1
);
this
.
bgContainer
.
addChild
(
this
.
listContainer2
);
this
.
addChild
(
this
.
bgContainer
);
this
.
bgContainer
.
mask
=
this
.
bgmask
;
setTimeout
(()
=>
{
this
.
loop
();
},
1000
)
}
loop
()
{
this
.
timer
&&
clearTimeout
(
this
.
timer
);
this
.
timer
=
null
;
var
step
=
(
this
.
stopStep
-
this
.
totalStep
)
*
this
.
k
;
step
=
parseInt
(
step
.
toFixed
(
0
))
step
=
step
?
step
:
1
;
var
sum
=
this
.
totalStep
+
step
;
if
(
sum
>
this
.
stopStep
)
{
step
=
this
.
stopStep
-
this
.
totalStep
;
}
// console.log(step)
if
(
!
this
.
vertical
)
{
let
x1
=
this
.
listContainer1
.
x
let
x2
=
this
.
listContainer2
.
x
if
(
x1
+
this
.
listWidth
<
0
)
{
x1
=
this
.
listWidth
+
(
x1
+
this
.
listWidth
);
}
if
(
x2
+
this
.
listWidth
<
0
)
{
x2
=
this
.
listWidth
+
(
x2
+
this
.
listWidth
);
}
this
.
listContainer1
.
position
.
set
(
x1
-
step
,
0
)
this
.
listContainer2
.
position
.
set
(
x2
-
step
,
0
)
}
else
{
let
y1
=
this
.
listContainer1
.
y
let
y2
=
this
.
listContainer2
.
y
if
(
y1
+
this
.
listHeight
<
0
)
{
y1
=
this
.
listHeight
+
(
y1
+
this
.
listHeight
);
}
if
(
y2
+
this
.
listHeight
<
0
)
{
y2
=
this
.
listHeight
+
(
y2
+
this
.
listHeight
);
}
this
.
listContainer1
.
position
.
set
(
0
,
y1
-
step
)
this
.
listContainer2
.
position
.
set
(
0
,
y2
-
step
)
}
this
.
totalStep
=
this
.
totalStep
+
step
if
(
Math
.
abs
(
this
.
stopStep
-
this
.
totalStep
)
<
0.1
)
{
this
.
setTimeoutSelf
(()
=>
{
this
.
timer
=
this
.
setTimeoutSelf
(()
=>
{
this
.
loop
()
},
50
)
},
1000
)
this
.
totalStep
=
0
;
}
else
{
this
.
timer
=
this
.
setTimeoutSelf
(()
=>
{
this
.
loop
()
},
50
)
}
}
setTimeoutSelf
(
cb
,
interval
)
{
// 实现setTimeout功能
let
now
=
Date
.
now
let
stime
=
now
()
let
etime
=
stime
let
loop
=
()
=>
{
var
timeoutTimer
=
requestAnimationFrame
(
loop
)
etime
=
now
()
if
(
etime
-
stime
>=
interval
)
{
cb
()
cancelAnimationFrame
(
timeoutTimer
)
}
}
loop
()
}
destroy
()
{
this
.
timer
&&
clearTimeout
(
this
.
timer
);
this
.
timer
=
null
;
}
}
\ No newline at end of file
project/src/panels/prize.ts
View file @
7668c2c0
...
...
@@ -4,6 +4,7 @@ import { Panel } from "../../module/views/Panel";
import
getObject
from
"../getObject"
;
import
{
IndexScene
}
from
"../template/IndexScene"
;
import
{
Tools
}
from
"../Tools"
;
import
updateShare
from
"../updateShare"
;
import
{
getWebData
,
sendWebNet
,
WebNetName
}
from
"../WebNet"
;
export
class
PrizePanel
extends
Panel
{
...
...
@@ -24,7 +25,8 @@ export class PrizePanel extends Panel {
async
start
(
data
)
{
super
.
start
();
const
indexResult
=
await
sendWebNet
(
WebNetName
.
index
)
updateShare
(
'inPrizePanel'
,
data
.
shareCode
,
indexResult
.
data
.
amount1
,
indexResult
.
data
.
amount2
)
}
hidePanel
(){
...
...
project/src/template/NewbieScene.ts
View file @
7668c2c0
import
{
showPanel
}
from
"../../module/ctrls"
;
import
{
Scene
}
from
"../../module/views/Scene"
;
import
getObject
from
"../getObject"
;
import
{
PrizePanel
}
from
"../panels/prize"
;
export
class
NewbieScene
extends
Scene
{
get
groupNames
()
{
return
[
"newbie"
]
}
...
...
@@ -12,10 +11,10 @@ export class NewbieScene extends Scene {
}
async
start
(
data
)
{
super
.
start
()
super
.
start
()
;
console
.
log
(
this
);
this
.
addEventListener
(
FYGE
.
MouseEvent
.
CLICK
,()
=>
{
showPanel
(
PrizePanel
);
showPanel
(
PrizePanel
,
data
);
},
this
);
}
...
...
project/src/template/ShareScene.ts
View file @
7668c2c0
...
...
@@ -13,6 +13,7 @@ export class ShareScene extends Scene {
async
start
(
data
)
{
super
.
start
();
console
.
log
(
'ShareScene query>>'
,
JSON
.
stringify
(
data
.
query
))
}
initEvents
()
{
...
...
project/src/updateShare.ts
0 → 100644
View file @
7668c2c0
const
updateShare
=
(
type
,
shareCode
,
amount1
,
amount2
)
=>
{
console
.
log
(
'updateShare'
,
'type='
,
type
,
'shareCode='
,
shareCode
,
'amount1='
,
amount1
,
'amount2='
,
amount2
)
}
export
default
updateShare
\ No newline at end of file
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