/**
* 我的会员列表页面
* @邠心vbe on 2023/07/14
*/
import React, { Component } from 'react';
import { View, Text, StyleSheet, Pressable } from 'react-native';
import apiMember from '../../api/apiMember';
import { ElevationObject } from '../../components/Button';
import TextView from '../../components/TextView';
import utils from '../../utils/utils';
export default class MembersList extends Component {
constructor(props) {
super(props);
this.state = {
memberList: []
};
}
componentDidMount() {
this.getMyMemberList();
this.props.navigation.addListener('focus', () => {
this.getMyMemberList();
})
}
getMyMemberList() {
apiMember.getMyMemberList().then(res => {
if (res.data) {
this.setState({
memberList: res.data
});
}
}).catch(err => {
this.setState({
memberList: []
});
toastShort(err)
});
}
getMembershipStatus(status) {
switch (status) {
case "Pending":
return $t("members.statusPending");
case "Approved":
return $t("members.statusApproved");
case "Pass":
return $t("members.statusApproved");
case "Rejected":
return $t("members.statusRejected");
default:
return $t("charging.statusUnavailable");
}
}
render() {
return (
this.state.memberList.length > 0
? this.state.memberList.map((item, index) => (
{
//startPage(PageList.editVehicle, {id: item.vehiclePk});
}}>
{ utils.isEmpty(item.groupType)
? {$t('members.membership')}:
: {item.groupType}
}
{item.membership}
{$t('members.membershipNo')}:
{item.membershipNo}
{$t('members.status')}:
{this.getMembershipStatus(item.membershipStatus)}
))
: {$t('members.noData')}
);
}
}
const styles = StyleSheet.create({
memberView: {
borderRadius: 8,
overflow: 'hidden',
...ElevationObject(5),
...$margin(16, 16, 0),
...$padding(16),
backgroundColor: colorLight
},
memberItem: {
paddingTop: 1,
paddingBottom: 1,
alignItems: 'center',
flexDirection: 'row'
},
textLabel: {
color: textPrimary,
fontSize: 14,
paddingRight: 6,
fontWeight: 'bold'
},
textValue: {
flex: 1,
color: textPrimary,
fontSize: 14
},
textLabel2: {
color: textPrimary,
fontSize: 16,
paddingRight: 5,
marginBottom: 2,
fontWeight: 'bold'
},
textValue2: {
flex: 1,
color: textPrimary,
fontSize: 16,
fontWeight: 'bold',
marginBottom: 2
},
textType: {
color: textLight,
fontSize: 10,
marginRight: 4,
borderRadius: 2,
...$padding(1, 4),
backgroundColor: colorAccent
},
itemBackground: {
right: 0,
bottom: 0,
opacity: 0.06,
position: 'absolute'
}
})