/**
* 充电评价页面
* @邠心vbe on 2021/04/30
*/
import React from 'react';
import { Image, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native';
import apiUser from '../../api/apiUser';
import Button from '../../components/Button';
import Dialog from '../../components/Dialog';
import { PageList } from '../Router';
export default class Rating extends React.Component {
constructor(props) {
super(props);
this.state = {
amenitiesNearby: 0,
chargingExperience: 0,
locationOfStation: 0,
other: '',
sitePk: 0,
stationInfo: this.props.route.params
}
}
componentDidMount() {
if (this.state.stationInfo.id) {
this.setState({
sitePk: this.state.stationInfo.id
});
}
}
submit() {
//console.log(this.state);
if (this.state.locationOfStation == 0) {
toastShort('Please rate \'Location of Station\'');
return;
}
if (this.state.amenitiesNearby == 0) {
toastShort('Please rate \'Amenities Nearby\'');
return;
}
if (this.state.chargingExperience == 0) {
toastShort('Please rate \'Charging Experience\'');
return;
}
this.rating();
}
rating() {
Dialog.showProgressDialog();
apiUser.rateCharge(this.state).then(res => {
Dialog.dismissLoading();
startPage(PageList.home)
}).catch((err) => {
Dialog.dismissLoading();
toastShort(err);
});
}
render() {
return (
{this.state.stationInfo?.name}
{this.state.stationInfo?.address}
Location of Station
{
this.setState({
locationOfStation: value
});
}}
/>
Amenities Nearby
{
this.setState({
amenitiesNearby: value
});
}}
/>
Charging Experience
{
this.setState({
chargingExperience: value
});
}}
/>
Others
{
this.setState({
other: t
});
}}
/>
);
}
}
const StarView = ({rating, onChange}) => {
const arr = [1,2,3,4,5];
return (
{ arr.map((item, index) => {
return (
= item ? colorAccent : '#eee'}
onPress={() => {
onChange(item);
}}/>
);
})
}
);
}
const styles = StyleSheet.create({
container: {
flex: 1
},
stationInfoView: {
padding: 16,
alignItems: 'center',
flexDirection: 'row',
backgroundColor: colorLight
},
stationIcon: {
width: 40,
height: 40
},
stationInfo: {
flex: 1,
paddingLeft: 16
},
stationName: {
color: '#000',
fontSize: 16
},
stationAddress: {
color: '#999',
fontSize: 12
},
ratingView: {
padding: 16,
marginTop: 16,
backgroundColor: colorLight
},
ratingTitle: {
color: '#000',
fontSize: 14
},
starGroupView: {
paddingTop: 16,
paddingBottom: 20,
alignItems: 'center',
flexDirection: 'row'
},
starView: {
marginRight: 10
},
otherText: {
color: textPrimary,
minHeight: 120,
marginTop: 16,
borderWidth: 1,
borderColor: '#999',
borderRadius: 6,
paddingLeft: 10,
paddingRight: 10,
backgroundColor: '#F5F5F5'
},
button: {
elevation: 1.5,
marginTop: 32,
marginLeft: 16,
marginRight: 16,
marginBottom: 32
}
});