Message.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * 通知信息详情
  3. * @邠心vbe on 2023/08/17
  4. */
  5. import React, { Component } from 'react';
  6. import { View, Text, StyleSheet, ScrollView } from 'react-native';
  7. import apiNotification from '../../api/apiNotification';
  8. import Button from '../../components/Button';
  9. import Dialog from '../../components/Dialog';
  10. import { PageList } from '../Router';
  11. export default class Message extends Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. id: "",
  16. messageInfo: {
  17. createTime: "",
  18. notificationText: "",
  19. notificationTitle: "",
  20. notificationType: ""
  21. }
  22. };
  23. }
  24. componentDidMount() {
  25. if (this.props.route?.params?.id) {
  26. this.setState({
  27. id: this.props.route?.params?.id
  28. }, () => {
  29. this.readMessage();
  30. })
  31. }
  32. }
  33. readMessage() {
  34. Dialog.showProgressDialog();
  35. apiNotification.readMessage(this.state.id).then(res => {
  36. if (res.data) {
  37. this.setState({
  38. messageInfo: res.data
  39. });
  40. }
  41. }).catch(err => {
  42. toastShort(err);
  43. }).finally(() => {
  44. Dialog.dismissLoading();
  45. })
  46. }
  47. submitFeedback() {
  48. startPage(PageList.feedback);
  49. }
  50. render() {
  51. return (
  52. <View style={styles.container}>
  53. <View style={styles.header}>
  54. <Text
  55. style={styles.textTitle}>
  56. {this.state.messageInfo.notificationTitle}
  57. </Text>
  58. <Text
  59. style={styles.textDate}
  60. numberOfLines={1}>
  61. {this.state.messageInfo.createTime}
  62. </Text>
  63. </View>
  64. <ScrollView
  65. style={ui.flex1}>
  66. <Text
  67. style={styles.textMessage}>
  68. {this.state.messageInfo.notificationText}
  69. </Text>
  70. </ScrollView>
  71. { this.state.messageInfo.notificationType == "Review" &&
  72. <Button
  73. elevation={1}
  74. style={$margin(8, 16, 20)}
  75. text={$t("feedback.submitFeedback")}
  76. onClick={() => this.submitFeedback()}
  77. />
  78. }
  79. </View>
  80. );
  81. }
  82. }
  83. const styles = StyleSheet.create({
  84. container: {
  85. flex: 1,
  86. backgroundColor: pageBackground
  87. },
  88. textTitle: {
  89. color: textPrimary,
  90. fontSize: 18,
  91. fontWeight: 'bold'
  92. },
  93. textDate: {
  94. color: textSecondary,
  95. fontSize: 10,
  96. paddingTop: 1
  97. },
  98. header: {
  99. padding: 16,
  100. backgroundColor: pageBackground
  101. },
  102. textMessage: {
  103. color: textPrimary,
  104. fontSize: 14,
  105. padding: 16
  106. }
  107. })