Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dva-JingZi-Game
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Point 郑海洋
dva-JingZi-Game
Commits
3af50164
Commit
3af50164
authored
Jun 19, 2020
by
Alan 张加强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
d3ed529c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
39 deletions
+54
-39
box.js
src/component/box.js
+54
-39
No files found.
src/component/box.js
View file @
3af50164
/*
* @Author: your name
* @Date: 2020-06-19 16:41:51
* @LastEditTime: 2020-06-19 16:42:20
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \dva-jingzi-game\src\component\box.js
*/
import
styled
from
'
styled-components
'
;
import
WinImg
from
'
./winImg
'
;
const
Box
=
styled
.
div
`
...
...
@@ -14,49 +22,56 @@ const Box = styled.div `
`
function
BoxMaster
(
props
)
{
const
handelClick
=
(
value
)
=>
{
// 判断游戏是否有胜利者
if
(
props
.
winner
)
return
// 判断是否重复点击
if
(
!
reClick
(
value
))
{
// 更新整体
props
.
dispatch
({
type
:
'
main/updateObjFn
'
,
id
:
value
.
value
,
flag
:
value
.
nowFliage
,
})
// 保存每一步操作
props
.
dispatch
({
type
:
'
main/saveActionFn
'
,
id
:
value
.
value
,
flag
:
value
.
nowFliage
,
})
const
handelClick
=
(
value
)
=>
{
// 判断游戏是否有胜利者
if
(
props
.
winner
)
return
// 判断是否重复点击
if
(
!
reClick
(
value
))
{
// 更新整体
props
.
dispatch
({
type
:
'
main/updateObjFn
'
,
id
:
value
.
value
,
flag
:
value
.
nowFliage
,
})
// 保存每一步操作
console
.
log
(
"
11
"
);
props
.
dispatch
({
type
:
'
main/saveActionFn
'
,
id
:
value
.
value
,
flag
:
value
.
nowFliage
,
})
}
}
}
// 是否重复点击
function
reClick
(
value
)
{
let
tempObj
=
value
.
datasource
.
find
((
item
,
index
)
=>
{
return
item
.
value
===
value
.
value
})
if
(
tempObj
&&
tempObj
.
flag
)
{
return
true
}
else
{
return
false
// 是否重复点击
function
reClick
(
value
)
{
let
tempObj
=
value
.
datasource
.
find
((
item
,
index
)
=>
{
return
item
.
value
===
value
.
value
})
if
(
tempObj
&&
tempObj
.
flag
)
{
return
true
}
else
{
return
false
}
}
}
return
(
<
Box
onClick
=
{
()
=>
handelClick
(
props
)}
style
=
{{
background
:
props
.
winner
&&
props
.
value
===
props
.
winner
.
value
?
""
:
props
.
color
}}
>
{
props
.
winner
&&
props
.
value
===
props
.
winner
.
value
?
(
<
WinImg
flag
=
{
props
.
flag
}
/
>
)
:
(
<
span
>
{
props
.
flag
}
<
/span>
)
return
(
<
Box
onClick
=
{
()
=>
handelClick
(
props
)
}
style
=
{
{
background
:
props
.
winner
&&
props
.
value
===
props
.
winner
.
value
?
""
:
props
.
color
}
}
>
{
props
.
winner
&&
props
.
value
===
props
.
winner
.
value
?
(
<
WinImg
flag
=
{
props
.
flag
}
/
>
)
:
(
<
span
>
{
props
.
flag
}
<
/span>
)
}
<
/Box
>
)
}
}
<
/Box
>
)
}
export
default
BoxMaster
export
default
BoxMaster
\ 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