/** * 文章详情 * @邠心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 HeaderTitle from '../../components/HeaderTitle'; import TextView from '../../components/TextView'; import VbeSkeleton from '../../components/VbeSkeleton'; import utils from '../../utils/utils'; import { PagerView } from './ViewUtil'; export default class ViewArticle extends Component { constructor(props) { super(props); this.state = { id: "", loading: true, messageInfo: { articleTypeName: "", articleTitle: "", articleContent: "" } }; } componentDidMount() { if (this.props.route?.params?.id) { this.setState({ id: this.props.route?.params?.id }, () => { this.readMessage(); }) } } readMessage() { apiArticle.readMessage(this.state.id).then(res => { if (res.data) { this.setState({ messageInfo: res.data }); this.setPageTitle(); } }).catch(err => { toastShort(err); }); } setPageTitle() { if (this.state.messageInfo.articleTitle) { this.props.navigation.setOptions({ headerTitle: () => () }); setTimeout(() => { this.setState({ loading: false }); }, 300); } } accessLink(url) { Linking.openURL(utils.getImageUrl(url)) } render() { if (this.state.loading) { return ( ) } else { 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 }, loadingView: { flex: 1, padding: 16, justifyContent: 'flex-start', backgroundColor: pageBackground }, textTitle: { color: textPrimary, fontSize: 14, fontWeight: 'bold', paddingBottom: 2 }, textDate: { flex: 1, color: textSecondary, fontSize: 12, paddingLeft: 2 }, textView: { color: textSecondary, fontSize: 14, padding: 4 }, header: { padding: 16, //...ElevationObject(1), backgroundColor: pageBackground }, textMessage: { color: textPrimary, fontSize: 12, paddingLeft: 16, paddingRight: 16 }, labelTypeText: { fontSize: 12, fontWeight: 'bold', borderWidth: 1, borderRadius: 4, borderColor: colorPrimary, marginTop: 8, ...$padding(2, 6) }, textLinkTitle: { color: textPrimary, fontSize: 14, fontWeight: 'bold', padding: 16 }, itemLink: { ...$padding(0, 16, 8), flexDirection: 'row' }, linkIndex: { fontSize: 12, paddingRight: 2 }, linkHyper: { ...ui.link, fontSize: 12, textDecorationLine: 'underline' }, linkActive: { color: "#FF3B30" } })