Commit 3af50164 authored by Alan 张加强's avatar Alan 张加强

update

parent d3ed529c
/*
* @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
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