ViewAlerts.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /**
  2. * 通知信息详情
  3. * @邠心vbe on 2023/08/17
  4. */
  5. import React, { Component } from 'react';
  6. import { View, StyleSheet, ScrollView } from 'react-native';
  7. import apiNotification from '../../api/apiNotification';
  8. import Button, { ElevationObject } from '../../components/Button';
  9. import HeaderTitle from '../../components/HeaderTitle';
  10. import TextView from '../../components/TextView';
  11. import VbeSkeleton from '../../components/VbeSkeleton';
  12. import { PageList } from '../Router';
  13. export default class ViewAlerts extends Component {
  14. constructor(props) {
  15. super(props);
  16. this.state = {
  17. id: "",
  18. loading: true,
  19. messageInfo: {
  20. createTime: "",
  21. notificationText: "",
  22. notificationTitle: "",
  23. notificationType: ""
  24. }
  25. };
  26. }
  27. componentDidMount() {
  28. if (this.props.route?.params?.id) {
  29. this.setState({
  30. id: this.props.route?.params?.id
  31. }, () => {
  32. this.readMessage();
  33. })
  34. }
  35. }
  36. readMessage() {
  37. apiNotification.readMessage(this.state.id).then(res => {
  38. if (res.data) {
  39. this.setState({
  40. messageInfo: res.data
  41. }, () => {
  42. this.setPageTitle();
  43. });
  44. }
  45. }).catch(err => {
  46. toastShort(err);
  47. });
  48. }
  49. setPageTitle() {
  50. if (this.state.messageInfo.notificationTitle) {
  51. this.props.navigation.setOptions({
  52. headerTitle: () => (<HeaderTitle title={this.state.messageInfo.notificationTitle}/>)
  53. });
  54. setTimeout(() => {
  55. this.setState({
  56. loading: false
  57. });
  58. }, 300);
  59. }
  60. }
  61. submitFeedback() {
  62. startPage(PageList.feedback);
  63. }
  64. render() {
  65. return (
  66. <VbeSkeleton
  67. style={this.state.loading ? styles.loadingView : styles.container}
  68. viewStyle={styles.container}
  69. isLoading={this.state.loading}
  70. layout={[
  71. {width: '90%', height: 20},
  72. {width: '50%', height: 12, marginTop: 8},
  73. {width: '100%', height: 15, marginTop: 24},
  74. {width: '100%', height: 15, marginTop: 8},
  75. {width: '100%', height: 15, marginTop: 8},
  76. {width: '100%', height: 15, marginTop: 8},
  77. {width: '30%', height: 15, marginTop: 8},
  78. {width: '100%', height: 15, marginTop: 24},
  79. {width: '100%', height: 15, marginTop: 8},
  80. {width: '100%', height: 15, marginTop: 8},
  81. {width: '100%', height: 15, marginTop: 8},
  82. {width: '30%', height: 15, marginTop: 8},
  83. {width: '100%', height: 15, marginTop: 24},
  84. {width: '100%', height: 15, marginTop: 8},
  85. {width: '100%', height: 15, marginTop: 8},
  86. {width: '100%', height: 15, marginTop: 8},
  87. {width: '30%', height: 15, marginTop: 8}
  88. ]}
  89. animationDirection={"horizontalRight"}>
  90. <View style={styles.header}>
  91. <TextView
  92. style={styles.textTitle}>
  93. {this.state.messageInfo.notificationTitle}
  94. </TextView>
  95. <View style={ui.flexc}>
  96. <MaterialCommunityIcons
  97. name="clock-time-four-outline"
  98. color={textSecondary}
  99. size={12}/>
  100. <TextView
  101. style={styles.textDate}
  102. numberOfLines={1}>
  103. {this.state.messageInfo.createTime}
  104. </TextView>
  105. </View>
  106. </View>
  107. <View style={styles.divideView}></View>
  108. <ScrollView
  109. style={ui.flex1}>
  110. <TextView
  111. style={styles.textMessage}
  112. selectable={true}>
  113. {this.state.messageInfo.notificationText}
  114. </TextView>
  115. </ScrollView>
  116. { this.state.messageInfo.notificationType == "Review" &&
  117. <Button
  118. elevation={1}
  119. style={$margin(8, 16, 20)}
  120. text={$t("feedback.submitFeedback")}
  121. onClick={() => this.submitFeedback()}
  122. />
  123. }
  124. </VbeSkeleton>
  125. );
  126. }
  127. }
  128. const styles = StyleSheet.create({
  129. container: {
  130. flex: 1,
  131. backgroundColor: pageBackground
  132. },
  133. loadingView: {
  134. flex: 1,
  135. padding: 16,
  136. justifyContent: 'flex-start',
  137. backgroundColor: pageBackground
  138. },
  139. textTitle: {
  140. color: textPrimary,
  141. fontSize: 14,
  142. fontWeight: 'bold',
  143. paddingBottom: 2
  144. },
  145. textDate: {
  146. color: textSecondary,
  147. fontSize: 12,
  148. paddingLeft: 2
  149. },
  150. header: {
  151. padding: 16,
  152. //...ElevationObject(1),
  153. backgroundColor: pageBackground
  154. },
  155. divideView: {
  156. height: 1,
  157. marginLeft: 16,
  158. marginRight: 16,
  159. backgroundColor: colorPrimary
  160. },
  161. textMessage: {
  162. color: textPrimary,
  163. fontSize: 12,
  164. padding: 16
  165. }
  166. })