/** * 文章详情 * @邠心vbe on 2023/10/24 */ import React, { Component } from 'react'; import { View, StyleSheet, Image, ScrollView, Linking } from 'react-native'; import Swiper from 'react-native-swiper'; import apiArticle from '../../api/apiArticle'; import { ElevationObject } from '../../components/Button'; import HeaderTitle from '../../components/HeaderTitle'; import TextView from '../../components/TextView'; import utils from '../../utils/utils'; import { PagerView } from './ViewUtil'; export default class ViewArticle extends Component { constructor(props) { super(props); this.state = { id: "", messageInfo: { articleTypeName: "", articleTitle: "", articleContent: "" } }; } componentDidMount() { if (this.props.route?.params?.id) { this.setState({ id: this.props.route?.params?.id }, () => { this.readMessage(); }) } } readMessage() { Dialog.showProgressDialog(); apiArticle.readMessage(this.state.id).then(res => { if (res.data) { this.setState({ messageInfo: res.data }); this.setPageTitle(); } }).catch(err => { toastShort(err); }).finally(() => { Dialog.dismissLoading(); }) } setPageTitle() { if (this.state.messageInfo.articleTitle) { this.props.navigation.setOptions({ headerTitle: () => () }) } } accessLink(url) { Linking.openURL(utils.getImageUrl(url)) } render() { return ( { utils.isNotEmpty(this.state.messageInfo.articleImages) && } removeClippedSubviews={false}> { this.state.messageInfo.articleImages.map((item, index) => { return ( ); })} } {this.state.messageInfo.articleTitle} {this.state.messageInfo.createTime} {this.state.messageInfo.articleViews} {this.state.messageInfo.articleTypeName} {this.state.messageInfo.articleContent} { utils.isNotEmpty(this.state.messageInfo.articleLinks) && <> {$t("notification.labelLinks")} { this.state.messageInfo.articleLinks.map((item, index) => {index + 1}. this.accessLink(item.articleLink)}>{item.articleLinkName} )} } ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: pageBackground }, textTitle: { color: textPrimary, fontSize: 18, fontWeight: 'bold', paddingBottom: 2 }, textDate: { flex: 1, color: textSecondary, fontSize: 10, paddingLeft: 2 }, textView: { color: textSecondary, fontSize: 10, paddingLeft: 4 }, header: { padding: 16, ...ElevationObject(1), backgroundColor: pageBackground }, textMessage: { color: textPrimary, fontSize: 14, padding: 16 }, labelTypeText: { fontSize: 11, borderWidth: 1, borderRadius: 4, borderColor: colorPrimary, marginTop: 8, ...$padding(2, 6) }, textLinkTitle: { color: textPrimary, fontSize: 16, fontWeight: 'bold', padding: 16 }, itemLink: { ...$padding(0, 16, 8), flexDirection: 'row' }, linkIndex: { fontSize: 14, paddingRight: 2 }, linkHyper: { ...ui.link, fontSize: 14, textDecorationLine: 'underline' }, linkActive: { color: "#FF3B30" } })