Message.js 2.5 KB

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