import { Checkbox, Image, ScrollView, View } from "@tarojs/components" import Popup from "@/components/popup" import classnames from "classnames"; import MCheckbox from "@/components/checkbox"; import styles from "./index.module.scss" import { useEffect, useState } from "react"; type param = { show?: true|false, onClose?: () => void } export default ({show = false, onClose}: param) => { const selectList = ['不限', '剪板', '散剪', '大货'] const [selectIndex, setSelectIndex] = useState(0) const selectProduct = (index:number) => { setSelectIndex(index) } const [list, setList] = useState([]) useEffect(() => { for(let i = 0; i < 20; i++) { setList((e) => [...e, { title:`${i}#薄荷绿`, subtitle: '0770# 21S单面平纹(食毛)', tag: '剪板', select: i%2?true: false }]) } }, []) const [showPopup, setShowPopup] = useState(false) useEffect(() => { setShowPopup(show) }, [show]) const selectAll = () => { console.log('123123') list.map(item => { item.select = true }) setList([...list]) } //checkbox选中回调 const selectCallBack = (item) => { item.select = true setList([...list]) } //checkbox关闭回调 const colseCallBack = (item) => { item.select = false setList([...list]) } //popup关闭 const closePopup = () => { onClose?.() setShowPopup(false) } return ( closePopup()}> 全选 删除勾选项 {selectList.map((item, index) => { return selectProduct(index)} className={classnames(styles.search_item, (selectIndex==index)&&styles.search_item_select)}>{item} })} {list.length > 0&& {list.map((item, index) => { return selectCallBack(item)} onClose={() => colseCallBack(item)}/> {item.title} 0770# 21S单面平纹(食毛) 剪板 40.5/kg ×12m })} || 暂未选择商品 去选购 } 200 预估金额 去结算 ) }