|
@@ -15,6 +15,7 @@ import {
|
|
|
} from 'react-native';
|
|
} from 'react-native';
|
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
|
|
|
|
|
|
|
|
+import { RegionPicker } from '@/components/RegionPicker';
|
|
|
import { Images } from '@/constants/images';
|
|
import { Images } from '@/constants/images';
|
|
|
import { addAddress, Address, getAddressList, updateAddress } from '@/services/address';
|
|
import { addAddress, Address, getAddressList, updateAddress } from '@/services/address';
|
|
|
|
|
|
|
@@ -33,6 +34,13 @@ export default function AddressEditScreen() {
|
|
|
const [district, setDistrict] = useState('');
|
|
const [district, setDistrict] = useState('');
|
|
|
const [address, setAddress] = useState('');
|
|
const [address, setAddress] = useState('');
|
|
|
const [isDefault, setIsDefault] = useState(false);
|
|
const [isDefault, setIsDefault] = useState(false);
|
|
|
|
|
+ const [regionVisible, setRegionVisible] = useState(false);
|
|
|
|
|
+
|
|
|
|
|
+ const handleRegionSelect = (p: string, c: string, d: string) => {
|
|
|
|
|
+ setProvince(p);
|
|
|
|
|
+ setCity(c);
|
|
|
|
|
+ setDistrict(d);
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const loadData = useCallback(async () => {
|
|
const loadData = useCallback(async () => {
|
|
|
if (!id) return;
|
|
if (!id) return;
|
|
@@ -168,36 +176,15 @@ export default function AddressEditScreen() {
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
<View style={styles.formItem}>
|
|
<View style={styles.formItem}>
|
|
|
- <Text style={styles.label}>省份</Text>
|
|
|
|
|
- <TextInput
|
|
|
|
|
- style={styles.input}
|
|
|
|
|
- value={province}
|
|
|
|
|
- onChangeText={setProvince}
|
|
|
|
|
- placeholder="请输入省份"
|
|
|
|
|
- placeholderTextColor="#999"
|
|
|
|
|
- />
|
|
|
|
|
- </View>
|
|
|
|
|
-
|
|
|
|
|
- <View style={styles.formItem}>
|
|
|
|
|
- <Text style={styles.label}>城市</Text>
|
|
|
|
|
- <TextInput
|
|
|
|
|
- style={styles.input}
|
|
|
|
|
- value={city}
|
|
|
|
|
- onChangeText={setCity}
|
|
|
|
|
- placeholder="请输入城市"
|
|
|
|
|
- placeholderTextColor="#999"
|
|
|
|
|
- />
|
|
|
|
|
- </View>
|
|
|
|
|
-
|
|
|
|
|
- <View style={styles.formItem}>
|
|
|
|
|
- <Text style={styles.label}>区/县</Text>
|
|
|
|
|
- <TextInput
|
|
|
|
|
- style={styles.input}
|
|
|
|
|
- value={district}
|
|
|
|
|
- onChangeText={setDistrict}
|
|
|
|
|
- placeholder="请输入区/县(选填)"
|
|
|
|
|
- placeholderTextColor="#999"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <Text style={styles.label}>所在地区</Text>
|
|
|
|
|
+ <TouchableOpacity
|
|
|
|
|
+ style={styles.selector}
|
|
|
|
|
+ onPress={() => setRegionVisible(true)}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Text style={[styles.selectorText, !province && styles.placeholderText]}>
|
|
|
|
|
+ {province ? `${province} ${city} ${district}` : '请选择省/市/区'}
|
|
|
|
|
+ </Text>
|
|
|
|
|
+ </TouchableOpacity>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
<View style={styles.formItem}>
|
|
<View style={styles.formItem}>
|
|
@@ -240,6 +227,11 @@ export default function AddressEditScreen() {
|
|
|
</TouchableOpacity>
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
</View>
|
|
|
</ImageBackground>
|
|
</ImageBackground>
|
|
|
|
|
+ <RegionPicker
|
|
|
|
|
+ visible={regionVisible}
|
|
|
|
|
+ onClose={() => setRegionVisible(false)}
|
|
|
|
|
+ onSelect={handleRegionSelect}
|
|
|
|
|
+ />
|
|
|
</View>
|
|
</View>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -309,6 +301,19 @@ const styles = StyleSheet.create({
|
|
|
color: '#333',
|
|
color: '#333',
|
|
|
fontSize: 14,
|
|
fontSize: 14,
|
|
|
},
|
|
},
|
|
|
|
|
+ selector: {
|
|
|
|
|
+ backgroundColor: 'rgba(255,255,255,0.8)',
|
|
|
|
|
+ borderRadius: 8,
|
|
|
|
|
+ paddingHorizontal: 12,
|
|
|
|
|
+ paddingVertical: 12,
|
|
|
|
|
+ },
|
|
|
|
|
+ selectorText: {
|
|
|
|
|
+ fontSize: 14,
|
|
|
|
|
+ color: '#333',
|
|
|
|
|
+ },
|
|
|
|
|
+ placeholderText: {
|
|
|
|
|
+ color: '#999',
|
|
|
|
|
+ },
|
|
|
textArea: {
|
|
textArea: {
|
|
|
height: 80,
|
|
height: 80,
|
|
|
textAlignVertical: 'top',
|
|
textAlignVertical: 'top',
|