30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import Popup from "@/components/popup";
|
|
import { ScrollView, Text, View } from "@tarojs/components";
|
|
import { memo, useMemo } from "react";
|
|
import classnames from "classnames";
|
|
import styles from './index.module.scss'
|
|
|
|
//原因选择
|
|
type ReasonInfoParam = {
|
|
show?: boolean, //显示
|
|
onClose?: () => void, //关闭
|
|
title?: string, //标题
|
|
list?: {id:number, name:string, typle?:number}[], //数据列表
|
|
onSelect?: (val: object) => void, //选择
|
|
defaultValue?: number, //默认选中
|
|
}
|
|
export default memo(({show = false, onClose, title = '', list= [], onSelect, defaultValue}: ReasonInfoParam) => {
|
|
|
|
return (
|
|
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
|
|
<View className={styles.reason_return_con}>
|
|
<View className={styles.reason_title}><Text>{title}</Text></View>
|
|
<ScrollView scrollY className={styles.reason_scroll}>
|
|
<View className={styles.reason_list}>
|
|
{list.map(item => <View onClick={() => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name}</View> )}
|
|
</View>
|
|
</ScrollView>
|
|
</View>
|
|
</Popup>
|
|
)
|
|
}) |