|
@@ -2,13 +2,15 @@ import { PickerView, PickerViewColumn, View, Text } from "@tarojs/components";
|
|
|
import './PickerViews.scss'
|
|
import './PickerViews.scss'
|
|
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
+import { rpxToPx } from "@/utils/tools";
|
|
|
|
|
|
|
|
// export default function Component(props: { value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function, }) {
|
|
// export default function Component(props: { value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function, }) {
|
|
|
|
|
|
|
|
let detailValue
|
|
let detailValue
|
|
|
const Component = forwardRef((props: {
|
|
const Component = forwardRef((props: {
|
|
|
value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function,
|
|
value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function,
|
|
|
- themeColor?: string, title?: string
|
|
|
|
|
|
|
+ themeColor?: string, title?: string,
|
|
|
|
|
+ hideTitle?: boolean
|
|
|
}, ref) => {
|
|
}, ref) => {
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const [v, setV] = useState(props.value)
|
|
const [v, setV] = useState(props.value)
|
|
@@ -48,8 +50,11 @@ const Component = forwardRef((props: {
|
|
|
getConfirmData: confirm
|
|
getConfirmData: confirm
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
- return <View className='modal_content' catchMove>
|
|
|
|
|
- <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text>
|
|
|
|
|
|
|
+ return <View className='modal_content' style={{paddingBottom:props.showBtns?rpxToPx(120):0}} catchMove>
|
|
|
|
|
+ {
|
|
|
|
|
+ !props.hideTitle && <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text>
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
<PickerView value={v}
|
|
<PickerView value={v}
|
|
|
// color='#fff'
|
|
// color='#fff'
|
|
|
itemStyle={{ color: '#fff' }}
|
|
itemStyle={{ color: '#fff' }}
|
|
@@ -61,11 +66,11 @@ const Component = forwardRef((props: {
|
|
|
maskClass="picker-mask"
|
|
maskClass="picker-mask"
|
|
|
>
|
|
>
|
|
|
{
|
|
{
|
|
|
- props.items.map(item => {
|
|
|
|
|
- return <PickerViewColumn style={{ color: 'red' }} >
|
|
|
|
|
- {item.map(obj => {
|
|
|
|
|
|
|
+ props.items.map((item, index) => {
|
|
|
|
|
+ return <PickerViewColumn style={{ color: 'red' }} key={index}>
|
|
|
|
|
+ {item.map((obj, j) => {
|
|
|
return (
|
|
return (
|
|
|
- <Text style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{obj}</Text>
|
|
|
|
|
|
|
+ <Text key={j} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>{obj}</Text>
|
|
|
);
|
|
);
|
|
|
})}
|
|
})}
|
|
|
</PickerViewColumn>
|
|
</PickerViewColumn>
|
|
@@ -73,21 +78,24 @@ const Component = forwardRef((props: {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
</PickerView >
|
|
</PickerView >
|
|
|
- <View className='modal_operate'>
|
|
|
|
|
- <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={(e) => {
|
|
|
|
|
- if (process.env.TARO_ENV == 'weapp') {
|
|
|
|
|
- e.stopPropagation()
|
|
|
|
|
- }; props.onCancel!()
|
|
|
|
|
- }}>
|
|
|
|
|
- <Text className='modal_cancel_text' style={{ color: color, fontWeight: 'bold' }}>{t('feature.common.picker_cancel_btn')}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- <View className='btn_space' />
|
|
|
|
|
- <View className='modal_btn' style={{ backgroundColor: color }} onClick={confirm}>
|
|
|
|
|
- <Text className='modal_confirm_text' style={{ color: '#000', fontWeight: 'bold' }}>{t('feature.common.picker_confirm_btn')}</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ props.showBtns && <View className='modal_operate'>
|
|
|
|
|
+ <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={(e) => {
|
|
|
|
|
+ if (process.env.TARO_ENV == 'weapp') {
|
|
|
|
|
+ e.stopPropagation()
|
|
|
|
|
+ }; props.onCancel!()
|
|
|
|
|
+ }}>
|
|
|
|
|
+ <Text className='modal_cancel_text' style={{ color: color, fontWeight: 'bold' }}>{t('feature.common.picker_cancel_btn')}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ <View className='btn_space' />
|
|
|
|
|
+ <View className='modal_btn' style={{ backgroundColor: color }} onClick={confirm}>
|
|
|
|
|
+ <Text className='modal_confirm_text' style={{ color: '#000', fontWeight: 'bold' }}>{t('feature.common.picker_confirm_btn')}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
|
|
|
|
|
|
|
|
- </View>
|
|
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
</View>
|
|
</View>
|
|
|
})
|
|
})
|
|
|
|
|
|