购物车完成
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
.checkbox_item{
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 1px solid #707070;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
}
|
||||
.checkbox_item_select{
|
||||
background-color: $color_main;
|
||||
border: 0;
|
||||
color: #fff;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
text-align: center;
|
||||
line-height: 44px;
|
||||
.miconfont{
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import classnames from "classnames";
|
||||
import { useEffect, useState } from "react";
|
||||
import styles from "./index.module.scss"
|
||||
|
||||
type params = {
|
||||
onSelect?: () => void,
|
||||
onClose?: () => void,
|
||||
status?: false|true
|
||||
}
|
||||
export default ({onSelect, onClose, status = false}: params) => {
|
||||
const [selected, SetSelected] = useState(false)
|
||||
const onSelectEven = () => {
|
||||
let res = !selected
|
||||
if(res) {
|
||||
onSelect?.()
|
||||
} else {
|
||||
onClose?.()
|
||||
}
|
||||
SetSelected(res)
|
||||
}
|
||||
useEffect(() => {
|
||||
SetSelected(status)
|
||||
}, [status])
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(styles.checkbox_item, selected&&styles.checkbox_item_select)} onClick={() => onSelectEven()}>
|
||||
{selected&&<View className={classnames('iconfont', 'icon-tick_gou', styles.miconfont)}></View>}
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user