feat: 切换城市

This commit is contained in:
2025-10-15 20:34:08 +08:00
parent f63295db13
commit fcd9cc7d4c
13 changed files with 472 additions and 118 deletions

View File

@@ -0,0 +1,72 @@
import React, { useState } from "react";
import CommonPopup from "@/components/CommonPopup";
import Picker from "./Picker";
interface PickerOption {
text: string | number;
value: string | number;
}
interface PickerProps {
visible: boolean;
setvisible: (visible: boolean) => void;
options?: PickerOption[][] | PickerOption[];
value?: (string | number)[];
type?: "month" | "day" | "hour" | "ntrp" | null;
img?: string;
onConfirm?: (options: PickerOption[], values: (string | number)[]) => void;
onChange?: (value: (string | number)[]) => void;
style?: React.CSSProperties;
}
const PopupPicker = ({
visible,
setvisible,
value = [],
onConfirm,
onChange,
options = [],
style,
}: PickerProps) => {
const [defaultValue, setDefaultValue] = useState<(string | number)[]>(value);
const changePicker = (_options: any[], values: any, _columnIndex: number) => {
setDefaultValue(values);
};
const handleConfirm = () => {
console.log(defaultValue, "defaultValue");
onChange?.(defaultValue);
setvisible(false);
};
const dialogClose = () => {
setvisible(false);
};
return (
<>
<CommonPopup
visible={visible}
onClose={dialogClose}
showHeader={false}
title={null}
hideFooter={false}
cancelText="取消"
confirmText="完成"
onConfirm={handleConfirm}
position="bottom"
round
zIndex={1000}
style={style}
>
<Picker
visible={visible}
options={options}
defaultValue={defaultValue}
onChange={changePicker}
/>
</CommonPopup>
</>
);
};
export default PopupPicker;