MembersList.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /**
  2. * 我的会员列表页面
  3. * @邠心vbe on 2023/07/14
  4. */
  5. import React, { Component } from 'react';
  6. import { View, Text, StyleSheet, Pressable, Image } from 'react-native';
  7. import apiMember from '../../api/apiMember';
  8. import { ElevationObject } from '../../components/Button';
  9. import TextView from '../../components/TextView';
  10. import utils from '../../utils/utils';
  11. export default class MembersList extends Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. memberList: []
  16. };
  17. }
  18. componentDidMount() {
  19. this.getMyMemberList();
  20. this.props.navigation.addListener('focus', () => {
  21. this.getMyMemberList();
  22. })
  23. }
  24. getMyMemberList() {
  25. apiMember.getMyMemberList().then(res => {
  26. if (res.data) {
  27. this.setState({
  28. memberList: res.data
  29. });
  30. }
  31. }).catch(err => {
  32. this.setState({
  33. memberList: []
  34. });
  35. toastShort(err)
  36. });
  37. }
  38. getMembershipStatus(status) {
  39. switch (status) {
  40. case "Pending":
  41. return $t("members.statusPending");
  42. case "Approved":
  43. return $t("members.statusApproved");
  44. case "Pass":
  45. return $t("members.statusApproved");
  46. case "Rejected":
  47. return $t("members.statusRejected");
  48. default:
  49. return $t("charging.statusUnavailable");
  50. }
  51. }
  52. render() {
  53. return (
  54. this.state.memberList.length > 0
  55. ? this.state.memberList.map((item, index) => (
  56. <Pressable
  57. key={index}
  58. style={styles.memberView}
  59. onPress={() => {
  60. //startPage(PageList.editVehicle, {id: item.vehiclePk});
  61. }}>
  62. <View style={styles.itemBackground}>
  63. { utils.isNotEmpty(item.groupLogo)
  64. ? <Image
  65. source={{uri: utils.getImageUrl(item.groupLogo)}}
  66. resizeMode="contain"
  67. style={styles.groupLogo}/>
  68. : <MaterialIcons
  69. name="card-membership"
  70. color={colorAccent}
  71. style={styles.groupIcon}
  72. size={52}/>
  73. }
  74. </View>
  75. <View style={styles.memberItem}>
  76. { utils.isEmpty(item.groupType)
  77. ? <TextView style={styles.textLabel2}>{$t('members.membership')}:</TextView>
  78. : <TextView style={styles.textType}>{item.groupType}</TextView>
  79. }
  80. <TextView
  81. style={styles.textValue2}
  82. numberOfLines={1}>{item.membership}</TextView>
  83. </View>
  84. <View style={styles.memberItem}>
  85. <TextView style={styles.textLabel}>{$t('members.membershipNo')}:</TextView>
  86. <TextView style={styles.textValue}>{item.membershipNo}</TextView>
  87. </View>
  88. <View style={styles.memberItem}>
  89. <TextView style={styles.textLabel}>{$t('members.status')}:</TextView>
  90. <TextView style={styles.textValue}>{this.getMembershipStatus(item.membershipStatus)}</TextView>
  91. </View>
  92. </Pressable>
  93. ))
  94. : <Text style={ui.noData}>{$t('members.noData')}</Text>
  95. );
  96. }
  97. }
  98. const styles = StyleSheet.create({
  99. memberView: {
  100. borderRadius: 8,
  101. overflow: 'hidden',
  102. ...ElevationObject(5),
  103. ...$margin(16, 16, 0),
  104. ...$padding(16),
  105. backgroundColor: colorLight
  106. },
  107. memberItem: {
  108. paddingTop: 1,
  109. paddingBottom: 1,
  110. alignItems: 'center',
  111. flexDirection: 'row'
  112. },
  113. textLabel: {
  114. color: textPrimary,
  115. fontSize: 14,
  116. paddingRight: 6,
  117. fontWeight: 'bold'
  118. },
  119. textValue: {
  120. flex: 1,
  121. color: textPrimary,
  122. fontSize: 14
  123. },
  124. textLabel2: {
  125. color: textPrimary,
  126. fontSize: 16,
  127. paddingRight: 5,
  128. marginBottom: 2,
  129. fontWeight: 'bold'
  130. },
  131. textValue2: {
  132. flex: 1,
  133. color: textPrimary,
  134. fontSize: 16,
  135. fontWeight: 'bold',
  136. marginBottom: 2
  137. },
  138. textType: {
  139. color: textLight,
  140. fontSize: 10,
  141. marginRight: 4,
  142. borderRadius: 2,
  143. ...$padding(1, 4),
  144. backgroundColor: colorAccent
  145. },
  146. itemBackground: {
  147. right: 0,
  148. bottom: 0,
  149. position: 'absolute'
  150. },
  151. groupIcon: {
  152. margin: 4,
  153. opacity: 0.08
  154. },
  155. groupLogo: {
  156. width: 48,
  157. height: 48,
  158. margin: 8,
  159. opacity: .8,
  160. borderRadius: 6
  161. }
  162. })