transferVideoDetail.js 87.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245
/**
 * Created by xiniu on 2018/11/20.
 */
import React, {Component} from 'react';
import {
    ActivityIndicator,
    DeviceEventEmitter,
    Dimensions,
    findNodeHandle,
    Image,
    Keyboard,
    Modal,
    NetInfo,
    Platform,
    ScrollView,
    StatusBar,
    StyleSheet,
    Text,
    TouchableOpacity,
    TouchableWithoutFeedback,
    View,
    FlatList,
    InteractionManager
} from 'react-native';
import Video from 'react-native-video';
import Orientation from 'react-native-orientation';
import Slider from 'react-native-slider';
import {observer} from 'mobx-react';
import {UIManager} from 'NativeModules';

import transferVideoDetailLogic from './transferVideoDetailLogic';
import {zoomH, zoomW,height,width} from '../../utils/getSize';
import CommentInput from '../detail/CommentInput';
import CommentMore from '../detail/CommentMore';
import CommentReward from '../detail/CommentReward';
import ItemHeaderInfo from "../component/ItemHeaderInfo";
import DetailTab from '../detail/DetailTab';
import { NoDoublePress, xnToast, getHeaderHeight, isIphoneX, getHeaderPadding,getHomeColor, dateToMsgTime } from '../../utils/utils';
import AppService from "../../service/AppService";
import RichText from "../../widget/RichText";

const defaultIcon = require('../../img/defaultIcon.png');
const vIcon = require('../../img/v.png');
const prise = require('../../img/dz.png');
const prised = require('../../img/prised.png');
const writeIcon = require('../../img/writeIcon.png');
const emj = require('../../img/emj.png');
const forwarding = require('../../img/zf.png');
const reward = require('../../img/reward.png');
const close = require('../../img/close.png');
const pageSize = 20;
let offSet = 0;
let isFirst = true;

const screenWidth = Dimensions.get('window').width;
const screenHeight = Platform.OS === 'ios' ? Dimensions.get('window').height : Dimensions.get('window').height - StatusBar.currentHeight;

function formatTime(second) {
    let i = 0, s = Math.round(second);
    if (s > 60) {
        i = parseInt(s / 60);
        s = parseInt(s % 60);
    }
    // 补零
    let zero = function (v) {
        return (v >> 0) < 10 ? "0" + v : v;
    };
    return [zero(i), zero(s)].join(":");
}

@observer
export default class TransferVideoDetail extends Component {
    static navigationOptions = ({ navigation, screenProps }) => ({
        header: null
    });

    logic = new transferVideoDetailLogic();

    constructor(props){
        super(props);
        this.reGetThreadDetailInfo = null;
        this.toCommentPosition = null;
        this._gestureHandlers = {
            onStartShouldSetResponder: () => false,
            // 对触摸进行响应
            onMoveShouldSetResponder: () => {
                Keyboard.dismiss();
                return false;
            },
        };
        this.state = {
            detailInfo :{},
            loading:false,
            showInput:false,//是否显示底部弹出框
            operatorLoading:false,//局部操作框
            toCommentPosition:false,
            currentTabIndex:1,
            commentList:[],//评论列表
            forwardingList:[],//转发列表
            RewardList:[],//打赏列表
            praiseList:[],//赞列表
            threadStatistics:'',//统计信息
            loadMore :false,
            showFooter:false,

            id: this.props.navigation.state.params.id || null,
            firstIn: false,
            videoWidth: 345 / zoomW,
            videoHeight: 213.5,
            showVideoControl: false, // 是否显示视频控制组件
            duration: 0,               // 视频的总时长
            isFullScreen: false,     // 当前是否全屏显示
            playFromBeginning: false, // 是否从头开始播放
            mobileConnect: false,
            isBuffer: false,
            attentionID: null,
            isShowCommentInput:false // 是否显示CommentInput输入框组件
        };
    };

    componentWillMount(){
        const _this = this;

        global.pauseTransferVideo = this.pauseVideo;
        global.recoverTransferVideo = this.recoverVideo;

        if (global.isConnected) {
            this.setState({
                firstIn: true
            });
            AppService.forumActionHistory({forumId:global.forumId,actionTargetId:_this.state.id,actionType:30,actionTargetType:0,actionTargetThreadId:_this.state.id}).then((data)=>{});

            const process1 = new Promise((resolve, reject) => {
                // 获取帖子详情
                AppService.getDetailById({ id: _this.state.id,sourceFrom:'APP' }).then((res) => {
                    resolve(res);
                    if (res.message) {
                        _this.setState({
                            firstIn: false
                        }, () => {
                            xnToast(res.message);
                        });
                        return;
                    }
                    if (!!res.errors === true && !!res.errors.length > 0) {
                        if (!!data.hasBeenDeleted){
                            xnToast("帖子信息不存在或已被删除");
                            this.props.navigation.goBack();
                            return
                        }
                        _this.setState({
                            firstIn: false
                        }, () => {
                            xnToast(res.errors[0].message);
                        });
                    } else {

                    }
                }).catch((error) => {
                    _this.setState({
                        firstIn: false
                    }, () => {
                        xnToast(error.message);
                    });
                })
            });
            const process2 = new Promise((resolve, reject) => {
                // 读帖子
                AppService.ThreadReadRequest({ id: _this.state.id }).then((res) => {
                    resolve(res);
                    if (res.message) {
                        _this.setState({
                            firstIn: false
                        }, () => {
                            xnToast(res.message);
                        });
                        return;
                    }
                    if (!!res.errors === true && !!res.errors.length > 0) {
                        _this.setState({
                            firstIn: false
                        }, () => {
                            xnToast(res.errors[0].message);
                        });
                    } else {
                        // 已读成功统一发送已读通知
                        DeviceEventEmitter.emit('readNoti',_this.state.id);
                    }
                }).catch((error) => {
                    _this.setState({
                        firstIn: false
                    }, () => {
                        xnToast(error.message);
                    });
                })
            });
            // 同时执行process1和process2和process3,并在它们都完成后执行then:
            Promise.all([process1, process2]).then(function (results) {
                console.log(results, '--------------');
                let videoUrl = '';
                let videoCover = '';
                let videoSize = 0;
                let attentionID = null;
                let threadExtend = results[0].threadExtend || {};
                let originThread = threadExtend.originThread || {};
                let attachmentList = originThread.attachmentList || [];
                let hasFollowed = false;
                if(!!attachmentList && attachmentList.length > 0) {
                    let attributes = JSON.parse(attachmentList[0].attributes || '{}');
                    videoUrl = !!attachmentList[0].filePath ? attachmentList[0].filePath : '';
                    videoCover = !!attributes.videoCover ? attributes.videoCover : '';
                    videoSize = !!attributes.videoSize ? attributes.videoSize : 0;
                }
                if(!!threadExtend.user && !!threadExtend.user.attention && !!threadExtend.user.attention.isActive) {
                    hasFollowed = true;
                    attentionID = threadExtend.user.attention.id || null;
                }
                threadExtend.videoUrl = videoUrl;
                threadExtend.videoCover = videoCover;
                threadExtend.videoSize = videoSize;
                threadExtend.hasFollowed = hasFollowed;
                _this.props.navigation.setParams({
                    headerInfo: threadExtend
                });
                _this.setState({
                    detailInfo: threadExtend,
                    attentionID: attentionID,
                    firstIn: false
                }, () => {
                    _this.getReplyList();
                    _this.getThreadStatic();
                    // 获取网络状态
                    NetInfo.fetch().done((reach) => {
                        if(reach.toLowerCase() === 'wifi') {
                            _this.setState({
                                isBuffer: true
                            });
                            _this.logic.switchPlay(true);
                            _this.logic.tempSwitchPlay(true);
                        } else {
                            _this.setState({
                                mobileConnect: true
                            });
                        }
                        console.log(reach);
                    });
                });
            });
        } else {
            xnToast('暂无网络连接,请稍后重试!')
        }
    }

    componentDidMount(){
        let _this = this;

        //重新获取详情信息
        this.reGetThreadDetailInfo = DeviceEventEmitter.addListener('reGetThreadDetailInfo',function(){
            console.log("reGetThreadDetailInfo");
            _this.getThreadDetailInfo();
        });

        this.toCommentPosition = DeviceEventEmitter.addListener('toCommentPosition',function(){
            console.log("toCommentPosition");
            _this.setState({
                toCommentPosition: true,
            });
        });

        //刷新回复列表
        this.refreshReplyList = DeviceEventEmitter.addListener('refreshReplyList',function(){
            _this.setState({
                commentList: [],
                loadMore: false,
            },function(){
                _this.getReplyList();
                _this.getThreadStatic();
            })
        });

        //刷新赞列表
        this.refreshPriseList = DeviceEventEmitter.addListener('refreshPriseList',function(){
            _this.setState({
                praiseList:[],
                loadMore :false,
            },function(){
                _this.getPriseList();
                _this.getThreadStatic();
            })
        });

        //刷新转发数
        this.refreshForward = DeviceEventEmitter.addListener('refreshForward',function(){
            _this.setState({
                forwardingList:[],
                loadMore :false,
            },function(){
                _this.getForwardList();
                _this.getThreadStatic();
            })
        });

        // 关闭CommentInput输入框组件的通知
        this.closeCommentInputIos = DeviceEventEmitter.addListener('closeCommentInputIos',function(){
            console.log("closeCommentInputIos");
            _this.setState({
                isShowCommentInput:false,
            })
        });
    };

    componentWillUnmount() {
        Orientation.lockToPortrait();

        global.pauseTransferVideo = null;
        global.recoverTransferVideo = null;

        if (this.reGetThreadDetailInfo !== null) {
            this.reGetThreadDetailInfo.remove();
        }
        if (this.toCommentPosition !== null) {
            this.toCommentPosition.remove();
        }

        isFirst = true;
        if(this.refreshReplyList){
            this.refreshReplyList.remove();
        }
        if(this.refreshPriseList){
            this.refreshPriseList.remove();
        }
        if(this.refreshForward){
            this.refreshForward.remove();
        }
        if (this.closeCommentInputIos != null) {
            this.closeCommentInputIos.remove();
        }
    }

    //点赞
    _commentStarClick (isLike,data){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }

        let _this = this;
        //点赞
        if (isLike){
            let params = {
                forumId:data.forumId,//社区id
                boardId:data.boardId,//版块ID
                targetType: 1,//点赞类型: 点赞对象的类型 0:帖子点赞 2:回复点赞 1:评论点赞 3:转发点赞
                targetId:data.id,//点赞对象ID
                likeUserId:global.userId,//点赞用户ID
                likeUserName: global.userName,//点赞用户名字
            };
            console.log(params);

            AppService.like(params).then((data) => {
                console.log(data);
                if (data.message) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    xnToast('点赞成功');
                    _this.setState({
                        commentList:[],
                        loadMore :false,
                    },function () {
                        _this.getReplyList();

                    })
                }
            }).catch((error) => {
                xnToast(error)
            })
        }else {//取消点赞
            let params = {
                id: data.threadLike.id//点赞id
            };
            console.log(params);
            AppService.cancelLike(params).then((data) => {
                console.log(data);
                if (data.message) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    xnToast('已取消点赞');
                    _this.setState({
                        commentList:[],
                        loadMore :false,
                    },function () {
                        _this.getReplyList();

                    })
                }
            }).catch((error) => {
                xnToast(error)
            })
        }
    };

    //删除评论
    deleteComment(item){

        let _this = this;

        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }

        let params = {
            id:item.id,
            sourceFrom:'APP'
        };

        console.log(params);

        AppService.deleteCommentAndReplyById(params).then((data) => {
            console.log(data);
            if (data.message) {
                xnToast(data.message);
                return;
            }
            if (data.errors.length > 0) {
                xnToast(data.errors[0].message);
            } else {
                xnToast('删除成功');
                // todo 通知列表刷新(列表刷新难点,分页的时候怎么刷?)
                this.setState({
                    commentList:[],
                    loadMore :false,
                },function () {
                    _this.getReplyList();
                    _this.getThreadStatic();
                    DeviceEventEmitter.emit('refreshHomeList');
                })
            }
        }).catch((error) => {
            xnToast(error)
        })
    }

    onLayout = (event)=>{
        offSet = event.nativeEvent.layout.height;
    }

    onLayoutFlatList = (event)=>{
        let a = event.nativeEvent.layout.height;
        console.log('1111----',a,height);
    }

    //获取回复列表
    getReplyList(){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        let _this = this;
        let length = this.state.commentList.length;
        if (length % pageSize == 0 && !this.state.loadMore) {
            let data = this.state.detailInfo;
            let params = {
                tenantId:data.tenantId,//承租人ID
                forumId:data.forumId,//社区id
                boardId:data.boardId,//板块id
                threadId:data.id,//帖子id
                isActive:true,
                isComment:true,
                pageNumber:length/pageSize+1,
                pageSize : pageSize,
            };

            this.setState({
                loadMore: true,
            });
            AppService.queryCommentAndReply(params).then((data) => {
                console.log('5555',data);
                this.setState({
                    loadMore: false,
                },function () {
                    //todo 添加判断条件'
                    if(isFirst &&( _this.props.navigation.state.params.from == 'comment')){
                        if (data.result.length < pageSize){//只有一页的数据
                            this.setState({
                                showFooter:true,
                            });
                        }
                        this.refs.flatList.scrollToOffset({animated: true, offset: offSet});
                        isFirst = false;
                    }

                });
                if (data.message) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    if (length + data.result.length > data.totalCount) {
                        return;
                    }
                    this.setState({
                        commentList:this.state.commentList.concat(data.result),
                    })
                }
            }).catch((error) => {
                xnToast(error)
            })
        }

    };

    //获取转发列表
    getForwardList(){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        let length =  this.state.forwardingList.length;
        if (length % pageSize == 0 && !this.state.loadMore) {
            let  data = this.state.detailInfo;
            let params = {
                tenantId:global.tenantId,//承租人ID
                forumId:data.forumId,//社区id
                boardId:data.boardId,//板块id
                threadId:data.id,//帖子id
                isActive:true,
                pageNumber:length/pageSize+1,
                pageSize : pageSize,
            };
            this.setState({
                loadMore: true,
            });

            AppService.queryForward(params).then((data) => {
                this.setState({
                    loadMore: false,
                });
                if (data.message) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    if (length + data.result.length > data.totalCount) {
                        return;
                    }
                    this.setState({
                        forwardingList:this.state.forwardingList.concat(data.result),
                    })
                }
            }).catch((error) => {
                this.setState({
                    loadMore: false,
                });
                xnToast(error)
            })
        }

    };

    //获取打赏列表
    getRewardList(){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        };

        let length =  this.state.RewardList.length;
        if (length % pageSize == 0 && !this.state.loadMore) {
            let  data = this.state.detailInfo;
            let params = {
                tenantId:global.tenantId,//承租人ID
                forumId:data.forumId,//社区id
                boardId:data.boardId,//板块id
                threadId:data.id,//帖子id
                isActive:true,
            };

            this.setState({
                loadMore: true,
            });

            AppService.queryCommentAndReply(params).then((data) => {
                if (data.message) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    if (length + data.result.length > data.totalCount) {
                        return;
                    }
                    this.setState({
                        RewardList:this.state.RewardList.concat(data.result),
                    })
                }
            }).catch((error) => {
                xnToast(error)
            })
        }

    };

    //获取赞列表
    getPriseList(){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        let length =  this.state.praiseList.length;
        if (length % pageSize == 0 && !this.state.loadMore) {
            let  data = this.state.detailInfo;
            let params = {
                tenantId:global.tenantId,//承租人ID
                forumId:data.forumId,//社区id
                boardId:data.boardId,//板块id
                threadId:data.id,//帖子id
                targetType: 0,//点赞类型0:帖子点赞 1:评论点赞 2:回复点赞  3:转发点赞
                targetId:data.id,//点赞对象ID
                likeUserId:data.userId,//点赞用户ID
                likeUserName:data.userName,//点赞用户名字
                isActive:true,
                pageNumber:length/pageSize+1,
                pageSize : pageSize,
            };

            this.setState({
                loadMore: true,
            });
            AppService.queryLike(params).then((data) => {
                this.setState({
                    loadMore: false,
                });
                if (data.message) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    if (length + data.result.length > data.totalCount) {
                        return;
                    }
                    this.setState({
                        praiseList:this.state.praiseList.concat(data.result),
                    })
                }
            }).catch((error) => {
                this.setState({
                    loadMore: false,
                });
                xnToast(error)
            })
        }

    };

    //获取帖子统计信息
    getThreadStatic(){
        AppService.queryThreadStatistic({ id: this.state.detailInfo.id }).then((data) => {
            if (data.message) {
                xnToast(data.message);
                return;
            }
            if (data.errors.length > 0) {
                xnToast(data.errors[0].message);
            } else {
                this.setState({
                    threadStatistics:data.threadStatistics,
                })
            }
        }).catch((error) => {
            xnToast(error);
        })
    }

    //列表数据源
    _data = (index) =>{
        let data ;
        if(index == 0 ){//转发
            data = this.state.forwardingList;
        }else if (index == 1){//评论
            data = this.state.commentList;
        }else if (index == 2){//打赏
//            data = this.state.RewardList;
        } else if (index == 3){//赞
            data = this.state.praiseList;
        }

        return data;
    }

    //无数据时的展示
    _emptyView(index){
        let  msg;
        if(index == 0 ){//转发
            msg = "暂无转发"
        }else if (index == 1){//评论
            msg = "暂无评论"
        }else if (index == 2){//打赏
//            msg = "暂无打赏"
        } else if (index == 3){//赞
            msg = "暂无赞"
        }
        return(
            !this.state.isFullScreen && <View style = {{width:'100%',paddingTop:60/zoomH,paddingBottom:60/zoomH,backgroundColor:'#fff',alignItems:'center'}}>
                <Text style = {{fontSize:14,color:'rgba(0,0,0,0.45)'}}> {msg}</Text>
            </View>

        );
    };

    //获取点赞、转发等tab栏上的显示的文字
    getTypeName(type){

        let data = this.state.detailInfo;

        let title = '';
        switch (type) {
            case 0:
                title = !!this.state.threadStatistics && this.state.threadStatistics.forwardNum >0?
                    '转发 '+this.state.threadStatistics.forwardNum:'转发';
                break;
            case 1:
                title = !!this.state.threadStatistics && this.state.threadStatistics.commentNum >0 ?
                    '评论 '+this.state.threadStatistics.commentNum:'评论';
                break;
            case 2:
//                title = !!data.threadStatistics && data.threadStatistics.rewardNum >0 ?
//                    '打赏 '+data.threadStatistics.rewardNum:'打赏';
                break;
            case 3:
                title = !!this.state.threadStatistics && this.state.threadStatistics.likeNum >0 ?
                    '赞 '+this.state.threadStatistics.likeNum:'赞';
                break;
            default:
                break;
        }

        return title;

    }

    //切换评论等tab栏
    changeTab(index) {
        let _this = this;
        this.setState({
            currentTabIndex:index,
            loadMore:false,
        },function () {
            switch (_this.state.currentTabIndex){
                case  0 :
                    _this.getForwardList();
                    break;
                case 1:
                    _this.getReplyList();
                    break;
                case 2:
                    // _this.getRewardList();
                    break;
                case 3:
                    _this.getPriseList();
                    break;
                default:
                    break;
            }
        });


    };

    //加载更多
    _loadMore(index){
        console.log('----_loadMore------');
        let _this = this;
        switch (index){
            case 0:
                _this.getForwardList();
                break;
            case 1:
                _this.getReplyList();
                break;
            case 2:
//                _this.getRewardList();
                break;
                _this.getPriseList();
            case 3:
                break;
            default:
                break;
        }
    }

    toCommentReply(id){
        NoDoublePress.onPress(() => {
            this.props.navigation.navigate("CommentReply", { id: id });
        })
    }

    //跳到个人中心页面
    toPersonal(id){
        NoDoublePress.onPress(() => {
            if (id == global.userId){
                //自己
                this.props.navigation.navigate("MyPage",{id:id});
                return;
            }
            this.props.navigation.navigate('PersonalHomePage',{'userId':id});
        })
    }

    //是否显示位置信息
    showLocation(){
        if (!!this.state.detailInfo.city && this.state.detailInfo.threadType == 0) {
            return true;
        }
        return false;
    }

    renderListHeader(){
        let _this = this;
        let detail = this.state.detailInfo;
        let originThread = detail.originThread || {};
        let rotateDeg = detail.threadVideoDirection || originThread.threadVideoDirection || 0;
        return(
            <View style = {{ flex: 1, backgroundColor: '#fff' }}>
                <View onLayout = {(event) => _this.onLayout(event)}>
                    {/*个人信息*/}
                    {!this.state.isFullScreen && <ItemHeaderInfo  itemList = {this.state.detailInfo} nav = {this.props.navigation}/>}
                    {/*转发*/}
                    {!!this.state.detailInfo.isForward && !this.state.isFullScreen &&
                    <View style={{ width: "100%", paddingLeft: 15 / zoomW,paddingRight:15/zoomW,marginTop:8/zoomH,marginBottom:8/zoomH }}>
                        <RichText
                            item={this.state.detailInfo.threadDetail.richContent}
                            nav={this.props.navigation}
                            clearNumberOfLine={true}
                        />
                    </View>}
                    {!this.state.isFullScreen &&
                    <View style={{ paddingLeft: 15 / zoomW, paddingRight: 15 / zoomW }}>
                        <TouchableOpacity style={styles.forwardingBg} onPress={() => NoDoublePress.onPress(() => this._detailClick())}>
                            {/*富文本*/}
                            <View style={styles.contentForwarding}>
                                <RichText
                                    item={this.getRichContent()}
                                    nav={this.props.navigation}
                                    clearNumberOfLine={true}
                                />
                            </View>
                        </TouchableOpacity>
                    </View>}
                    {/*视频*/}
                    <View style={[styles.centerWrap, { height: this.state.videoHeight }]}>
                        <View style={[styles.videoWrap, {
                            width: this.state.videoWidth,
                            height: this.state.videoHeight
                        }]}>
                            {!!detail.videoUrl && <View style={{ width: '100%', height: '100%' }}>
                                <Video
                                    ref={(ref) => this.videoPlayer = ref}
                                    source={{uri: detail.videoUrl}}
                                    rate={1.0}
                                    volume={1.0}
                                    muted={false}
                                    paused={!this.logic.isPlaying}
                                    resizeMode={'contain'}
                                    playWhenInactive={false}
                                    playInBackground={false}
                                    ignoreSilentSwitch={'ignore'}
                                    progressUpdateInterval={250.0}
                                    onLoadStart={this._onLoadStart}
                                    onLoad={this._onLoaded}
                                    onProgress={this._onProgressChanged}
                                    onSeek={this._onSeek}
                                    onEnd={this._onPlayEnd}
                                    onError={this._onPlayError}
                                    onBuffer={this._onBuffering}
                                    style={{width: '100%', height: '100%'}}
                                />
                                {
                                    this.state.isBuffer &&
                                    <View style={{
                                        position:'absolute',
                                        top: 0,
                                        left: 0,
                                        width: '100%',
                                        height: '100%'
                                    }}>
                                        {!!detail.videoCover && <Image style={{ width: '100%', height: '100%' }} resizeMode="contain" source={{ uri: detail.videoCover.indexOf("?x-oss-process=")!=-1? detail.videoCover :detail.videoCover + '?x-oss-process=image/resize,w_375/rotate,' + rotateDeg }} />}
                                        <View style={[styles.maskWrap, { backgroundColor: 'transparent' }]}>
                                            <ActivityIndicator size="large" color="#fff"/>
                                            <Text style={{ fontSize: 14, color: '#fff', marginTop: 8 }}>视频缓冲中…</Text>
                                        </View>
                                    </View>
                                }
                                <TouchableWithoutFeedback onPress={() => !this.state.isBuffer ? this.hideControl() : null}>
                                    <View
                                        style={{
                                            width: '100%',
                                            height: '100%',
                                            backgroundColor: this.logic.isPlaying ? 'transparent' : 'rgba(0, 0, 0, 0.2)',
                                            position: 'absolute',
                                            top: 0,
                                            left: 0,
                                            alignItems:'center',
                                            justifyContent:'center'
                                        }}>
                                        {this.state.showVideoControl && <TouchableWithoutFeedback onPress={() => this.controlPlay()}>
                                            <Image
                                                style={{ width: 50 / zoomW, height: 50 / zoomW }}
                                                source={this.logic.isPlaying ? require('../../img/zt.png') : require('../../img/bf.png')}
                                                resizeMode={'contain'}
                                            />
                                        </TouchableWithoutFeedback>}
                                    </View>
                                </TouchableWithoutFeedback>
                            </View>}
                            {!!detail.videoUrl && this.state.showVideoControl && <View style={styles.control}>
                                <TouchableOpacity style={{ width: 45 / zoomW, height: '100%', justifyContent: 'center', paddingLeft: 23 / zoomW }} onPress={() => this.controlPlay()}>
                                    <Image
                                        style={styles.playControl}
                                        source={this.logic.isPlaying ? require('../../img/icon_control_pause.png') : require('../../img/icon_control_play.png')}
                                        resizeMode={'contain'}
                                    />
                                </TouchableOpacity>
                                <Text style={styles.vTime}>{formatTime(this.logic.currentTime)}</Text>
                                <Slider
                                    style={{ flex: 1 }}
                                    minimumTrackTintColor={global.homeColor}
                                    maximumTrackTintColor={'rgba(255,255,255,0.3)'}
                                    thumbStyle={{
                                        backgroundColor: 'transparent',
                                        justifyContent: 'center'
                                    }}
                                    thumbImage={require('../../img/icon_control_slider.png')}
                                    value={this.logic.currentTime}
                                    minimumValue={0}
                                    maximumValue={Math.round(this.state.duration)}
                                    onValueChange={(currentTime) => { this.onSliderValueChanged(currentTime) }}
                                    onSlidingComplete={value => { console.log(value); this.videoPlayer.seek(value, '0') }}
                                />
                                <Text style={[styles.vTime, { marginLeft: 12.5 / zoomW, marginRight: 0 }]}>{formatTime(this.state.duration)}</Text>
                                <TouchableOpacity style={{ width: 45 / zoomW, height: '100%', justifyContent: 'center', paddingLeft: 7 / zoomW }} onPress={() => this.onControlShrinkPress()}>
                                    <Image
                                        style={styles.shrinkControl}
                                        source={this.state.isFullScreen ? require('../../img/icon_control_shrink_screen.png') : require('../../img/icon_control_full_screen.png')}
                                        resizeMode={'contain'}
                                    />
                                </TouchableOpacity>
                            </View>}
                            {this.state.mobileConnect && <View style={styles.maskWrap}>
                                <Text style={{ fontSize: 14, color: '#fff' }}>播放将消耗{ Math.ceil(detail.videoSize) || 0 }MB流量</Text>
                                <TouchableOpacity activeOpacity={0.8} style={styles.continueBtn} onPress={() => { this.setState({ mobileConnect: false, isBuffer: true }); this.logic.switchPlay(true); this.logic.tempSwitchPlay(true);}}>
                                    <Text style={{ fontSize: 14, color: '#fff' }}>继续播放</Text>
                                </TouchableOpacity>
                            </View>}
                        </View>
                    </View>
                    {/*阅读量*/}
                    {!this.state.isFullScreen && <Text style = {styles.reading}>{!!this.state.detailInfo.threadStatistics?(this.state.detailInfo.threadStatistics.readNum)+"  阅读":'0  阅读'}  </Text>}
                </View>

                {!this.state.isFullScreen && <View style = {{ backgroundColor: '#F3F5F6', height: 8 / zoomH }} ref={(c) => { this.dividerView = c }} />}

                {!this.state.isFullScreen && <View style={styles.tabWrap}>
                    <View style = {styles.itemTabWrapBg}>
                        <TouchableOpacity style={styles.tabBtn} onPress={() => this.changeTab(0)}>
                            <Text style={ this.state.currentTabIndex ==0 ?styles.tabMenuActiveWord :styles.tabMenuWord}>
                                {this.getTypeName(0)}
                            </Text>
                            {this.state.currentTabIndex == 0 && <View style={[styles.lineStyle,{backgroundColor: global.homeColor}]} />}
                        </TouchableOpacity>
                        <TouchableOpacity style={styles.tabBtn} onPress={() => this.changeTab(1)}>
                            <Text style={this.state.currentTabIndex ==1 ?styles.tabMenuActiveWord :styles.tabMenuWord}>
                                {this.getTypeName(1)}
                            </Text>
                            { this.state.currentTabIndex == 1 &&<View style={[styles.lineStyle,{backgroundColor: global.homeColor}]} />}
                        </TouchableOpacity>
                    </View>
                    <View style = {styles.itemTabWrapBg}>
                        {/*
                         <TouchableOpacity style={styles.tabBtn} onPress={() => this.changeTab(2)}>
                         <Text style={this.state.currentTabIndex ==2 ?styles.tabMenuActiveWord :styles.tabMenuWord}>
                         {this.getTypeName(2)}
                         </Text>
                         {this.state.currentTabIndex == 2 && <View style={styles.lineStyle} />}
                         </TouchableOpacity>
                         */}
                        <TouchableOpacity style={styles.tabBtn} onPress={() => this.changeTab(3)}>
                            <Text style={this.state.currentTabIndex ==3 ?styles.tabMenuActiveWord :styles.tabMenuWord}>
                                {this.getTypeName(3)}
                            </Text>
                            {this.state.currentTabIndex == 3 && <View style={[styles.lineStyle,{backgroundColor: global.homeColor}]} />}
                        </TouchableOpacity>
                    </View>
                </View>}

                {!this.state.isFullScreen && <View style={{ height: StyleSheet.hairlineWidth, backgroundColor: '#ddd' }} />}
            </View>
        )
    }

    //渲染item
    keyExtractor = (item,index) => index;
    renderItem({item,index}){
        switch (this.state.currentTabIndex){
            case 0://转发
                return (
                    !this.state.isFullScreen && <View style={styles.itemBackground} key={index}>
                        <TouchableOpacity style={styles.commonAvatar}  onPress = {()=>{this.toPersonal(item.userExtend.id)}}>
                            <Image  style={styles.commonAvatar}
                                    source={!!item.userExtend && !!item.userExtend.avatar?{uri: item.userExtend.avatar +'?x-oss-process=image/resize,w_500'} :defaultIcon}
                                    resizeMode="cover" />
                            {!!item.userExtend && !!item.userExtend.isAuthented &&<Image  style={styles.commonAvatarV} source={vIcon} resizeMode="cover" />}
                        </TouchableOpacity>
                        <View style = {{marginLeft:8/zoomW,flex:1,marginTop:2}}>
                            <Text style = {styles.userNameBlue}>{item.forwardUserName}</Text>
                            <View style = {{marginTop:8/zoomH}}>
                                <RichText
                                    item={!!item.threadDetail?item.threadDetail.richContent || '':''}
                                    nav={this.props.navigation}
                                    clearNumberOfLine  ={true}
                                />
                            </View>
                            <Text style = {[styles.time,{marginTop:8/zoomH}]}>{dateToMsgTime(item.creationTime)}</Text>
                        </View>
                    </View>
                );
                break;
            case 1://评论
                return (
                    !this.state.isFullScreen && <TouchableOpacity style={styles.itemBackground} activeOpacity={1} onPress = {()=>{this.toCommentReply(item.id)}} key={index}>
                        <TouchableOpacity style={styles.commonAvatar} onPress = {()=>{this.toPersonal(item.userExtend.id)}}>
                            <Image  style={styles.commonAvatar}
                                    source={!!item.userExtend && !!item.userExtend.avatar?{uri: item.userExtend.avatar +'?x-oss-process=image/resize,w_500'} :defaultIcon}
                                    resizeMode="cover" />
                            {!!item.userExtend && !!item.userExtend.isAuthented &&<Image  style={styles.commonAvatarV} source={vIcon} resizeMode="cover" />}
                        </TouchableOpacity>
                        <View style = {{marginLeft:8/zoomW,flex:1}} >
                            <View style = {{flex:1,flexDirection:'row',justifyContent:'space-between'}}>
                                <Text style = {styles.userNameBlue}>{item.userName}</Text>
                                <TouchableOpacity style = {{flexDirection:'row',alignItems:'center'}}
                                                  activeOpacity={1}
                                                  onPress = {() =>{this._commentStarClick(!!item.threadLike && item.threadLike.isActive?false:true,item)}}>
                                    <Image style={{width:14/zoomH,height:14/zoomH}} source={!!item.threadLike && item.threadLike.isActive? prised:prise} resizeMode="cover"  ></Image>
                                    {!! item.threadCommentReplyStatistics && item.threadCommentReplyStatistics.likeNum > 0
                                    && <Text style = {!!item.threadLike && item.threadLike.isActive?styles.textPrised:styles.textPrise}>{item.threadCommentReplyStatistics.likeNum}</Text>}

                                </TouchableOpacity>
                            </View>
                            {!!item.userExtend && !!item.userExtend.identity && <Text style = {styles.userIdentity}>{!!item.userExtend && !!item.userExtend.identity?item.userExtend.identity:''}</Text>}
                            <View style = {{marginTop:8/zoomH}}>
                                <RichText
                                    item={item.richContent}
                                    nav={this.props.navigation}
                                    clearNumberOfLine  ={true}
                                />
                            </View>

                            {!! item.attachmentList && item.attachmentList.length>0 &&
                            <TouchableOpacity style={{width:'55%',height:100,marginTop:2/zoomH,justifyContent:'center'}} activeOpacity={1}
                                              onPress = {()=>{ NativeModules.system.showPhotoWithUrl(item.attachmentList[0].filePath)}}>
                                <Image style={{width:'55%',height:100,marginTop:10/zoomH,justifyContent:'center'}}
                                       source={{uri:item.attachmentList[0].filePath }}></Image>
                            </TouchableOpacity>
                            }
                            <View style = {{flex:1,flexDirection:'row',justifyContent:'space-between',alignItems:'center',marginTop:8/zoomH}}>
                                <View style = {{flexDirection:'row',alignItems:'center'}}>
                                    <Text style = {styles.time}>{dateToMsgTime(item.creationTime)} </Text>
                                    <View style = {{backgroundColor:'rgba(0,0,0,0.45)',height:2,width:2,marginLeft:3,marginRight:5}}></View>
                                    {(item.threadCommentReplyStatistics.replyNum||'')!=''?
                                        <View style = {styles.reply}>
                                            <Text style = {styles.time}>{(item.threadCommentReplyStatistics.replyNum||'') + '回复'}</Text>
                                        </View> :
                                        <Text style = {styles.time}>回复</Text>}
                                </View>

                                {item.userId == global.userId &&
                                <TouchableOpacity onPress = {()=>{this.deleteComment(item)}}>
                                    <Text style = {styles.time}>删除</Text>
                                </TouchableOpacity>}


                            </View>


                        </View>
                    </TouchableOpacity>
                );
                break;
            case 2://打赏
                return null;
//                (
//                    !this.state.isFullScreen && <View style={styles.itemBackground} key={index}>
//                        <TouchableOpacity style={styles.commonAvatar}   onPress = {()=>{this.toPersonal(item.userExtend.id)}}>
//                            <Image  style={styles.commonAvatar} source={pic} resizeMode="cover" />
//                            <Image  style={styles.commonAvatarV} source={vIcon} resizeMode="cover" />
//                        </TouchableOpacity>
//                        <View style = {{marginLeft:10/zoomW,marginRight:10/zoomW,flexDirection:'row',alignItems:'center',justifyContent:'space-between',flex:1}}>
//                            <View>
//                                <Text style = {styles.userNameBlue}>犀牛网络</Text>
//                                <Text style = {styles.userIdentity}>android开发</Text>
//                            </View>
//                            <Text style = {{fontSize:14,color:'#000000'}}> ¥1</Text>
//
//                        </View>
//                    </View>
//                );
                break;
            case 3://赞
                return (
                !this.state.isFullScreen && <View style={[styles.itemBackground,{alignItems:'center'}]} key={index}>
                        <TouchableOpacity style={styles.commonAvatar}  onPress = {()=>{this.toPersonal(item.userExtend.id)}}>
                            <Image  style={styles.commonAvatar}  source={!!item.userExtend && !!item.userExtend.avatar?{uri: item.userExtend.avatar +'?x-oss-process=image/resize,w_500'} :defaultIcon} resizeMode="cover" />
                            {!!item.userExtend && !!item.userExtend.isAuthented &&<Image  style={styles.commonAvatarV} source={vIcon} resizeMode="cover" />}
                        </TouchableOpacity>
                        <View style = {{marginLeft:10/zoomW,marginRight:10/zoomW}}>
                            <Text style = {styles.userNameBlue}>{item.likeUserName}</Text>
                            {!!item.userExtend .agentName&& !!item.userExtend.agentName!='' &&<Text style = {styles.userIdentity}>{!!item.userExtend?item.userExtend.agentName:''}</Text> }
                        </View>
                    </View>);
                break;
            default:
                break;
        }
    }

    renderLoading(){
        return(
            <TouchableOpacity style={styles.loadingBg} onPress = {()=>{}}>
                <View style={styles.loadingBox}>
                    <ActivityIndicator size="large" color="#fff" />
                    <Text
                        style={{ fontSize: 16, color: "#fff", marginTop: 6 / zoomH }}
                    >
                        加载中...
                    </Text>
                </View>
            </TouchableOpacity>
        )
    }

    footerView(){
        let h = height;
        if (this.state.currentTabIndex ==0){//转发列表
            h = this.state.forwardingList.length < pageSize ? height:0;
        }
        if (this.state.currentTabIndex == 1){//评论
            h = this.state.commentList.length < pageSize ? height:0;
        }
        if (this.state.currentTabIndex == 3){//赞
            h = this.state.praiseList.length < pageSize ? height:0;
        }
        return(
            !this.state.isFullScreen && <View style = {{height:h,backgroundColor:'#fff',width:'100%'}}></View>
        )
    }

    // 跳转到个人中心
    goToPersonCenter() {
        if (this.state.detailInfo.threadUserId == global.userId) {
            //自己
            this.props.navigation.navigate('MyPage', { id: this.state.detailInfo.threadUserId });
            return;
        }
        this.props.navigation.navigate('PersonalHomePage', { userId: this.state.detailInfo.threadUserId });
    }

    // 关注、取消关注
    followClick() {
        const _this = this;
        if (global.isConnected){
            this.setState({
                loading: true
            });
            const data = JSON.parse(JSON.stringify(this.state.detailInfo));
            if(data.hasFollowed) {
                let params = {
                    id: this.state.attentionID
                };
                AppService.cancleAttention(params).then((data) => {
                    _this.setState({
                        loading: false
                    });
                    if (data.message) {
                        xnToast(data.message);
                        return;
                    }
                    if (!!data.errors === true && !!data.errors.length > 0) {
                        xnToast(data.errors[0].message);
                    } else {
                        xnToast('取消关注');
                        _this.getThreadDetailInfo();
                        DeviceEventEmitter.emit('refreshHomeHistory');
                        DeviceEventEmitter.emit('refreshCollectList');
                        DeviceEventEmitter.emit('refreshAttention');
                        DeviceEventEmitter.emit('refreshHomeList');
                        DeviceEventEmitter.emit("refreshAllList");
                        DeviceEventEmitter.emit('reGetThreadDetailInfo');
                    }
                }).catch((error) => {
                    _this.setState({
                        loading: false
                    }, () => {
                        xnToast(error);
                    });
                })
            } else {
                const params = {
                    forumId: data.forumId,//社区id
                    targetType: 1,//关注对象类型,目前固定1:社区用户
                    targetUserId: data.threadUserId,//被关注者用户ID
                    targetUserName: data.threadUserName,//被关注者用户名称
                    attentionUserId: global.userId,//自己的id
                    attentionUserName: global.userName,//自己的名字
                };
                console.log(params);
                AppService.attention(params).then((data) => {
                    this.setState({
                        loading: false
                    });
                    if (data.message) {
                        xnToast(data.message);
                        return;
                    }
                    if (!!data.errors === true && !!data.errors.length > 0) {
                        xnToast(data.errors[0].message);
                    } else {
                        xnToast('已关注');
                        _this.getThreadDetailInfo();
                        DeviceEventEmitter.emit('refreshHomeHistory');
                        DeviceEventEmitter.emit('refreshCollectList');
                        DeviceEventEmitter.emit('refreshAttention');
                        DeviceEventEmitter.emit('refreshHomeList');
                        DeviceEventEmitter.emit("refreshAllList");
                        DeviceEventEmitter.emit('reGetThreadDetailInfo');
                    }
                }).catch((error) => {
                    _this.setState({
                        loading: false
                    }, () => {
                        xnToast(error);
                    });
                })
            }
        } else {
            this.setState({
                loading: false
            });
            xnToast('暂无网络连接,请稍后重试!');
        }
    };

    //转发
    _forwardingClick = ()=>{
        let firstFileUrl = !!this.state.detailInfo.user.headFileUrl?this.state.detailInfo.user.headFileUrl :'';//用户头像
        let content = '';
        let placeHolderContent = '';
        let atList= [];
        if(!!this.state.detailInfo.originThread && this.state.detailInfo.originThread.threadDetail){//多次转发,有原贴内容
            firstFileUrl = this.state.detailInfo.originThread.threadDetail.firstFileUrl || firstFileUrl;
            content = this.state.detailInfo.originThread.threadUserName +" : "+this.state.detailInfo.originThread.threadDetail.content;
            placeHolderContent = '//@'+this.state.detailInfo.threadUserName+" : "+(this.state.detailInfo.threadDetail.content || '');
            let user = {
                id:this.state.detailInfo.threadUserId,
                name:this.state.detailInfo.threadUserName
            };
            atList.push(user);
            if (!!this.state.detailInfo.atHistoryList && this.state.detailInfo.atHistoryList.length >0 ){
                for(let i=0;i<this.state.detailInfo.atHistoryList.length;i++){
                    atList.push(this.state.detailInfo.atHistoryList[i]);
                }
            }
        }else {//原贴,没有转发过
            firstFileUrl = !!this.state.detailInfo.threadDetail && !!this.state.detailInfo.threadDetail.firstFileUrl ?
                this.state.detailInfo.threadDetail.firstFileUrl || firstFileUrl :firstFileUrl;//封面图,原贴的第一张图,如果没有,传用户头像
            content  =this.state.detailInfo.threadUserName +" : "+ this.state.detailInfo.threadDetail.content;
        }

        let data = {
            forumId: this.state.detailInfo.forumId,//社区id
            boardId: this.state.detailInfo.boardId,//版块ID,
            threadId :this.state.detailInfo.id,//帖子id
            firstFileUrl:firstFileUrl,
            atList:atList,//帖子@的人列表
            placeHolderContent:placeHolderContent,//转发的转发,别人转发的内容
            content:content,//帖子内容,需要自己拼接为 username:content 的格式
        };

        this.props.navigation.navigate('Forwarding',{from:'Detail',data:data});
    };

    //获取帖子详细信息
    getThreadDetailInfo(){
        let _this = this;
        if (global.isConnected) {
            this.setState({
                loading: true
            });
            AppService.getDetailById({ id: _this.state.id,sourceFrom:'APP' }).then((res) => {
                if (res.message) {
                    _this.setState({
                        loading: false
                    }, () => {
                        xnToast(res.message);
                    });
                    return;
                }
                if (!!res.errors === true && !!res.errors.length > 0) {
                    if (!!data.hasBeenDeleted){
                        xnToast("帖子信息不存在或已被删除");
                        _this.props.navigation.goBack();
                        return
                    }
                    _this.setState({
                        loading: false
                    }, () => {
                        xnToast(res.errors[0].message);
                    });
                } else {
                    let videoUrl = '';
                    let videoCover = '';
                    let videoSize = 0;
                    let attentionID = null;
                    let threadExtend = res.threadExtend || {};
                    let originThread = threadExtend.originThread || {};
                    let attachmentList = originThread.attachmentList || [];
                    let hasFollowed = false;
                    if(!!attachmentList && attachmentList.length > 0) {
                        let attributes = JSON.parse(attachmentList[0].attributes || '{}');
                        videoUrl = !!attachmentList[0].filePath ? attachmentList[0].filePath : '';
                        videoCover = !!attributes.videoCover ? attributes.videoCover : '';
                        videoSize = !!attributes.videoSize ? attributes.videoSize : 0;
                    }
                    if(!!threadExtend.user && !!threadExtend.user.attention && !!threadExtend.user.attention.isActive) {
                        hasFollowed = true;
                        attentionID = threadExtend.user.attention.id || null;
                    }
                    threadExtend.videoUrl = videoUrl;
                    threadExtend.videoCover = videoCover;
                    threadExtend.videoSize = videoSize;
                    threadExtend.hasFollowed = hasFollowed;
                    _this.props.navigation.setParams({
                        headerInfo: threadExtend
                    });
                    _this.setState({
                        detailInfo: threadExtend,
                        attentionID: attentionID,
                        loading: false
                    });
                }
            }).catch((error) => {
                _this.setState({
                    loading: false
                }, () => {
                    xnToast(error.message);
                });
            })
        } else {
            xnToast('暂无网络连接,请稍后重试!')
        }
    }

    //点赞
    _starClick (isLike,type){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        if(this.state.operatorLoading){
            //正在操作
            return;
        }
        let data = this.state.detailInfo;
        let _this = this;
        _this.setState({
            operatorLoading:true,
        });
        //点赞
        if (isLike){

            let params = {
                forumId:data.forumId,//社区id
                boardId:data.boardId,//版块ID
                targetType: type,//点赞类型: 点赞对象的类型 0:帖子点赞 1:评论点 2:回复点赞 3:转发点赞
                targetId:data.id,//点赞对象ID
                likeUserId:global.userId,//点赞用户ID
                likeUserName: global.userName,//点赞用户名字
            };
            console.log(params);

            AppService.like(params).then((data) => {
                console.log(data);
                if (data.message) {
                    _this.setState({
                        operatorLoading:false,
                    });
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    _this.setState({
                        operatorLoading:false,
                    });
                    xnToast(data.errors[0].message);
                } else {
                    xnToast('点赞成功');
                    _this.setState({
                        operatorLoading:false,
                    });

                    _this.getThreadDetailInfo();
                    //通知点赞列表刷新
                    DeviceEventEmitter.emit('refreshPriseList');
                    DeviceEventEmitter.emit('refreshHomeList');
                }
            }).catch((error) => {
                _this.setState({
                    operatorLoading:false,
                });
                xnToast(error)
            })
        }else {//取消点赞
            let params = {
                id: data.threadLike.id//点赞id
            };
            console.log(params);

            AppService.cancelLike(params).then((data) => {
                console.log(data);
                if (data.message) {
                    _this.setState({
                        operatorLoading:false,
                    });
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    _this.setState({
                        operatorLoading:false,
                    });
                    xnToast(data.errors[0].message);
                } else {
                    xnToast('已取消点赞');
                    _this.setState({
                        operatorLoading:false,
                    });

                    _this.getThreadDetailInfo();
                    //通知点赞列表刷新
                    DeviceEventEmitter.emit('refreshPriseList');
                    DeviceEventEmitter.emit('refreshHomeList');
                }
            }).catch((error) => {
                _this.setState({
                    operatorLoading:false,
                });
                xnToast(error)
            })
        }
    };

    //更多
    showMoreModal(){
        this.refs['CommentMore'].openModal();
    }

    //赞赏
    showRewardModal(){
        this.refs['CommentReward'].openRewardModal();
    }

    //评论
    /**
     *  @param inputStr:输入法人内容
     *
     */
    toComment=(data)=> {
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            this.setState({
                operatorLoading:false,
            });
            return;
        }
        this.setState({
            operatorLoading:true,
        });

        let detailInfo = this.state.detailInfo;
        let forwardRichTxt = data.forwardRichContent ==''?'':data.forwardRichContent +'</div>';
        let isForward = data.isForward;

        let params = {
            forumId:detailInfo.forumId,//社区id
            boardId:detailInfo.boardId,//版块ID
            threadId:detailInfo.id,//帖子Id
            floor:1,//楼层,评论的楼层为1,回复的楼层为父级楼层+1
            userId:global.userId,//评论/回复者ID
            userName:global.userName,//评论/回复者的名字
            content: data.content,//评论/回复内容
            richContent:data.richContent,//评论/回复富文本内容
            attachmentList:data.attachmentList,//附件集合
            topicHistoryList: data.tList,//引用的话题列表
            userList: data.aList,//引用的话题列表
            forward: data.isForward,//是否同时转发
            forwardRichContent:forwardRichTxt,//同时转发富文本内容
            forwardContent:data.forwardContent,//同时转发内容
        };
        console.log(params);

        AppService.creatCommentOrReply(params).then((data) => {

            if (data.message) {
                xnToast(data.message);
                this.setState({
                    operatorLoading:false,
                });
                return;
            }
            if (data.errors.length > 0) {
                this.setState({
                    operatorLoading:false,
                });
                xnToast(data.errors[0].message);
            } else {
                xnToast("已评论");
                this.setState({
                    operatorLoading:false,
                });
                if(this.refs.CommentInput != undefined){
                    InteractionManager.runAfterInteractions(() => {
                        this.refs.CommentInput.reset();
                    });
                }
                //通知评论列表刷新
                if (isForward) {
                    DeviceEventEmitter.emit('refreshForward');
                    DeviceEventEmitter.emit('refreshList');
                }
                DeviceEventEmitter.emit('refreshReplyList');
                DeviceEventEmitter.emit('refreshHomeList');
                DeviceEventEmitter.emit('refreshForward');
            }
        }).catch((error) => {
            xnToast(error);
            this.setState({
                operatorLoading:false,
            });
        })
    };

    //显示评论
    commentClick (){
        if (Platform.OS == 'ios'){
            this.setState({
                isShowCommentInput:true
            });
        }
        InteractionManager.runAfterInteractions(() => {
            this.refs.CommentInput.showInputLayout();
        });
    };

    renderCommentInput(){
        return (
            <View>
                <View style={styles.inputBg}>
                    <TouchableOpacity style={styles.greyRadiusBg} onPress={() => this.commentClick()}>
                        <Text style = {{fontSize:14,color:'#000000',marginLeft:14/zoomW}}>写评论...</Text>
                        <Image style={{width:20/zoomW,height:20/zoomW,marginRight:8/zoomW}} source={emj} resizeMode="cover" />
                    </TouchableOpacity>
                    {/*点赞*/}
                    <TouchableOpacity onPress={() => NoDoublePress.onPress(() =>
                        this._starClick(!!this.state.detailInfo.threadLike && !!this.state.detailInfo.threadLike.isActive ? false : true, 0)
                    )}>
                        <Image style={styles.img} source={!!this.state.detailInfo.threadLike && !!this.state.detailInfo.threadLike.isActive ? prised : prise} resizeMode="cover" />
                    </TouchableOpacity>
                    {/*转发*/}
                    <TouchableOpacity onPress={() => NoDoublePress.onPress(() => this._forwardingClick())}>
                        <Image style={styles.img} source={forwarding} resizeMode="cover" />
                    </TouchableOpacity>
                    {/*打赏
                     <TouchableOpacity onPress={() => this.showRewardModal()}>
                     <Image style={styles.img} source={reward} resizeMode="cover" />
                     </TouchableOpacity>*/}
                </View>

                {/*<CommentReward
                 ref = "CommentReward"
                 callback = {(money) =>{alert("打赏"+money)}}/>*/}
            </View>
        );
    }

    //获取显示的文本内容
    getRichContent(){
        let isForward = this.state.detailInfo.isForward ;
        if(isForward){
            let content = '';
            if(!!this.state.detailInfo.originThread
                && !!this.state.detailInfo.originThread.threadDetail && !!this.state.detailInfo.originThread.threadDetail.richContent){
                content   = '<div>' + '↵funew↵<a class="@" href= "id = '+this.state.detailInfo.originThread.threadUserId
                    + '" title = "@'+this.state.detailInfo.originThread.threadUserName+ '" />' + ' : '+this.state.detailInfo.originThread.threadDetail.richContent.replace('<div>','');
            }
            return content;
        }

        if(this.state.detailInfo.threadType == 4){//文章类型
            return this.state.detailInfo.title||'';
        }

        return !!this.state.detailInfo.threadDetail.richContent?this.state.detailInfo.threadDetail.richContent:'';
    }

    //详情
    _detailClick() {
        this.props.navigation.navigate("VideoDetail", { name: 'VideoDetail', id: this.state.detailInfo.originThread.id });
    };

    // 滚动
    scroll(event) {
        let Y = event.nativeEvent.contentOffset.y;
        if(Y > (!!this.state.detailInfo.isBoardTop ? 61 : 57)) {
            if(!this.logic.showHeaderInfo) {
                this.logic.switchHeader(true);
            }
        } else {
            if(this.logic.showHeaderInfo) {
                this.logic.switchHeader(false);
            }
        }
    }

    render(){
        let detail = this.state.detailInfo;
        return(
            <View style={styles.background} onLayout={this._onLayout} {...this._gestureHandlers}>
                <StatusBar
                    backgroundColor={'#B0B1B1'}
                    networkActivityIndicatorVisible
                />
                <Modal
                    animationType="none"
                    transparent
                    visible={this.state.firstIn}
                    onRequestClose={() => {}}
                >
                    <View style={styles.loadingBg}>
                        <View style={styles.loadingBox}>
                            <ActivityIndicator size="large" color="#fff" />
                            <Text
                                style={{ fontSize: 16, color: "#fff", marginTop: 6 / zoomH }}
                            >
                                加载中...
                            </Text>
                        </View>
                    </View>
                </Modal>
                <Modal
                    animationType="none"
                    transparent
                    visible={this.state.loading}
                    onRequestClose={() => {}}
                >
                    <View style={styles.loadingBg}>
                        <View style={styles.loadingBox}>
                            <ActivityIndicator size="large" color="#fff" />
                            <Text
                                style={{ fontSize: 16, color: "#fff", marginTop: 6 / zoomH }}
                            >
                                加载中...
                            </Text>
                        </View>
                    </View>
                </Modal>
                {!this.state.firstIn && !this.state.isFullScreen && <View style={{ width: '100%', height: getHeaderPadding(), backgroundColor: '#fff' }} />}
                {!this.state.firstIn && !this.state.isFullScreen && <View style={styles.headerWrap}>
                    <View style={{ width: 375 / 2 / zoomW, height: '100%', flexDirection: 'row' }}>
                        <TouchableOpacity style={{ height: '100%', justifyContent: 'center', paddingLeft: 15 / zoomW, paddingRight: 15 / zoomW }} onPress={() => this.props.navigation.goBack()}>
                            <Image style={{ width: 18 / zoomW, height: 18 }} source={require('../../img/loadBack.png')} resizeMode="contain"/>
                        </TouchableOpacity>
                        {this.logic.showHeaderInfo && <View style={styles.topInfoWrap}>
                            <TouchableOpacity style={styles.avatar} onPress={() => NoDoublePress.onPress(() => this.goToPersonCenter())}>
                                <Image style={styles.avatar} source={!!detail.threadUserHeadFileUrl ? { uri: detail.threadUserHeadFileUrl + '?x-oss-process=image/resize,w_500' } : require('../../img/defaultIcon.png')} resizeMode="cover" />
                                {!!detail.user && !!detail.user.isAuthented && <Image style={styles.avatarV} source={require('../../img/v.png')} resizeMode="cover" />}
                            </TouchableOpacity>
                            <View style={{ flex: 1, marginLeft: 8 / zoomW }}>
                                <Text style={{ fontSize: 14, color: 'rgba(0,0,0,0.85)' }} numberOfLines={1}>{detail.threadUserName ? detail.threadUserName : ''}</Text>
                                <Text style={{ fontSize: 12, color: 'rgba(0,0,0,0.45)' }} numberOfLines={1}>{(!!detail.user && !!detail.user.beAttentionNum) ? detail.user.beAttentionNum : 0}粉丝</Text>
                            </View>
                        </View>}
                    </View>
                    <Text style={{ fontSize: 18, color: '#000', position: 'absolute' }}>{this.logic.showHeaderInfo ? '' : ''}</Text>
                    <View style={{ width: 375 / 2 / zoomW, height: '100%', flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center' }}>
                        {this.logic.showHeaderInfo && !!detail.user && detail.user.id != global.userId &&
                        <TouchableOpacity activeOpacity={0.8} style={detail.hasFollowed ? styles.hasFollow : [styles.notFollow,{backgroundColor:global.homeColor}]} onPress={() => NoDoublePress.onPress(() => this.followClick())}>
                            <Text style = {{ fontSize: 14, color: detail.hasFollowed ? 'rgba(0,0,0,0.45)' : '#fff' }}>{detail.hasFollowed ? '已关注' : '关注'}</Text>
                        </TouchableOpacity>
                        }
                        <TouchableOpacity style={{ height: '100%', justifyContent: 'center', paddingLeft: 15 / zoomW, paddingRight: 15 / zoomW }} onPress={() => NoDoublePress.onPress(() => this.showMoreModal())}>
                            <Image style={{ width: 21 / zoomW, height: 4 }} source={require('../../img/more.png')}  resizeMode="contain"/>
                        </TouchableOpacity>
                    </View>
                </View>}

                {/*/!*转发、评论、赞赏、赞tab栏*!/*/}
                {!this.state.firstIn && <View style = {{ flex: 1 }}>
                    <FlatList
                        style={{ flex: 1 }}
                        ref = 'flatList'
                        alwaysBounceVertical={false}
                        bounces={false}
                        onScroll={this.scroll.bind(this)}
                        onLayout = {(event)=>{this.onLayoutFlatList(event)}}
                        refreshing={false}
                        onEndReachedThreshold={0.01}
                        onEndReached={() => this._loadMore(this.state.currentTabIndex)}
                        keyExtractor={this.keyExtractor}
                        data={this._data(this.state.currentTabIndex)}
                        ListHeaderComponent = {this.renderListHeader()}
                        ListFooterComponent = {this.footerView()}
                        ListEmptyComponent = {this._emptyView(this.state.currentTabIndex)}
                        renderItem={this.renderItem.bind(this)}/>

                    {/*更多加载*/}
                    {this.state.loadMore && this.renderLoading()}
                </View>}

                {/*/!*评论输入框*!/*/}
                {!this.state.firstIn && !this.state.isFullScreen && !this.state.isShowCommentInput
                && this.renderCommentInput()}

                {/*更多操作*/}
                <CommentMore
                    ref='CommentMore'
                    detailInfo = {this.state.detailInfo}
                    collectClick = {()=>{}}
                    deleteClick = {()=>{this.props.navigation.goBack();}}
                    forum={global.forum}
                />

                {/*局部loading*/}
                {this.state.operatorLoading && (
                    <View style={styles.loadingBg}>
                        <View style={styles.loadingBox}>
                            <ActivityIndicator size="large" color="#fff" />
                            <Text
                                style={{ fontSize: 16, color: "#fff", marginTop: 6 / zoomH }}
                            >
                                加载中...
                            </Text>
                        </View>
                    </View>
                )}

                {Platform.OS == 'ios' && !this.state.loading && this.state.isShowCommentInput && <CommentInput
                    ref = "CommentInput"
                    boardId = {this.state.detailInfo.boardId}
                    callback = { (data)=>{this.toComment(data)}}
                    uploadCallback = {(isLoading) =>{this.setState({operatorLoading:isLoading})}}
                    nav = {this.props.navigation}
                    hasNavHeight = {false}
                />}
                {Platform.OS == 'android' &&<CommentInput
                    ref = "CommentInput"
                    boardId = {this.state.detailInfo.boardId}
                    callback = { (data)=>{this.toComment(data)}}
                    uploadCallback = {(isLoading) =>{this.setState({operatorLoading:isLoading})}}
                    nav = {this.props.navigation}
                    hasNavHeight = {false}
                />}
            </View>
        );
    }

    /// -------Video组件回调事件-------

    _onLoadStart = () => {
        console.log('视频开始加载');
    };

    _onBuffering = () => {
        console.log('视频缓冲中...')
    };

    _onLoaded = (data) => {
        console.log('视频加载完成');
        this.setState({
            duration: data.duration,
            // isBuffer: false,
        });
    };

    _onProgressChanged = (data) => {
        console.log('视频进度更新');
        if(this.state.isBuffer && this.logic.currentTime != 0) {
            this.setState({
                isBuffer: false,
            });
        }
        if (this.logic.isPlaying) {
            this.logic.moveSlider(data.currentTime);
        }
    };

    _onSeek = () => {
        this.logic.switchPlay(true);
        this.logic.tempSwitchPlay(true);
    }

    _onPlayEnd = () => {
        console.log('视频播放结束');
        this.logic.moveSlider(0);
        this.logic.switchPlay(false);
        this.logic.tempSwitchPlay(false);
        this.setState({
            playFromBeginning: true,
            showVideoControl: true
        });
    };

    _onPlayError = () => {
        console.log('视频播放失败');
    };

    ///-------控件点击事件-------

    /// 控制播放器工具栏的显示和隐藏
    hideControl() {
        if (this.state.showVideoControl) {
            this.setState({
                showVideoControl: false,
            })
        } else {
            this.setState({
                showVideoControl: true,
            }, () => {    // 2秒后自动隐藏工具栏
                setTimeout(() => {
                    if(this.logic.isPlaying) {
                        this.setState({
                            showVideoControl: false
                        });
                    }
                }, Platform.OS === 'ios' ? 5000 : 3000);
            })
        }
    }

    // 点击了播放器或工具栏上的播放按钮
    controlPlay() {
        if(!this.logic.isPlaying) {
            setTimeout(() => {
                if(this.logic.isPlaying) {
                    this.setState({
                        showVideoControl: false
                    });
                }
            }, Platform.OS === 'ios' ? 5000 : 3000);
        }
        this.logic.switchPlay(!this.logic.isPlaying);
        this.logic.tempSwitchPlay(!this.logic.tempIsPlaying);
        if (this.state.playFromBeginning) {
            this.videoPlayer.seek(0, '0');
            this.setState({
                playFromBeginning: false,
            })
        }
    }

    /// 点击了工具栏上的全屏按钮
    onControlShrinkPress() {
        if (this.state.isFullScreen) {
            if (Platform.OS === 'ios') {
                Orientation.lockToPortrait();
                Orientation.lockToPortrait();
            } else {
                Orientation.lockToPortrait();
            }
        } else {
            if (Platform.OS === 'ios') {
                Orientation.lockToPortrait();
                Orientation.lockToLandscape();
            } else {
                Orientation.lockToLandscape();
            }
        }
    }

    // 暂停视频
    pauseVideo = () => {
        this.logic.switchPlay(false);
        // if (this.state.playFromBeginning) {
        //     this.videoPlayer.seek(0, '0');
        //     this.setState({
        //         playFromBeginning: false,
        //     })
        // }
    }

    // 返回恢复视频状态
    recoverVideo = () => {
        this.logic.switchPlay(this.logic.tempIsPlaying);
        // if (this.state.playFromBeginning) {
        //     this.videoPlayer.seek(0, '0');
        //     this.setState({
        //         playFromBeginning: false,
        //     })
        // }
    }

    /// 进度条值改变
    onSliderValueChanged(currentTime) {
        if (this.logic.isPlaying) {
            this.logic.switchPlay(false);
            this.logic.tempSwitchPlay(false);
        }
        this.logic.moveSlider(currentTime);
    }

    /// 屏幕旋转时宽高会发生变化,可以在onLayout的方法中做处理,比监听屏幕旋转更加及时获取宽高变化
    _onLayout = (event) => {
        //获取根View的宽高
        let {width, height} = event.nativeEvent.layout;
        console.log('通过onLayout得到的宽度:' + width);
        console.log('通过onLayout得到的高度:' + height);

        // 一般设备横屏下都是宽大于高,这里可以用这个来判断横竖屏
        let isLandscape = (width > height);
        if (isLandscape){
            this.setState({
                videoWidth: width,
                videoHeight: height,
                isFullScreen: true,
            })
        } else {
            this.setState({
                videoWidth: 345 / zoomW,
                videoHeight: 213.5,
                isFullScreen: false,
            })
        }
    };
}

const styles = StyleSheet.create({
    background:{
        flex: 1,
        backgroundColor: '#fff',
        display: 'flex',
        alignItems: 'center',
        justifyContent:'flex-end'
    },
    headerWrap: {
        width: '100%',
        height: 44,
        backgroundColor: '#fff',
        borderBottomColor: '#ddd',
        borderBottomWidth: StyleSheet.hairlineWidth,
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center',
    },
    reading:{
        fontSize:12,
        color:'rgba(0,0,0,0.45)',
        marginLeft:15/zoomW,
        marginTop:10/zoomH,
        marginBottom:10/zoomH
    },
    inputBg:{
        width:'100%',
        height:isIphoneX()?(44/zoomH+34):44/zoomH,
        backgroundColor:'#fff',
        flexDirection:'row',
        justifyContent:'space-between',
        alignItems:'center',
        paddingLeft:20/zoomW,
        paddingRight:20/zoomW,
        paddingBottom:isIphoneX()?34:0,
        borderColor: '#ddd',
        borderWidth: StyleSheet.hairlineWidth,
    },
    greyRadiusBg:{
        flex:1,
        flexDirection:'row',
        height:32/zoomH,
        justifyContent:'space-between',
        alignItems:'center',
        borderRadius:19/zoomW,
        backgroundColor:'#eeeeee'
    },
    img:{
        width:20/zoomW,
        height:20/zoomW,
        marginLeft:25/zoomW
    },
    loadingBg: {
        position: "absolute",
        top: 0,
        width: "100%",
        height: "100%",
        display: "flex",
        justifyContent: "center",
        alignItems: "center"
    },
    loadingBox: {
        width: 100 / zoomW,
        height: 120 / zoomH,
        backgroundColor: "rgba(0,0,0,.5)",
        borderRadius: 8,
        display: "flex",
        alignItems: "center",
        justifyContent: "center"
    },
    forwardingBg: {
        paddingTop:14/zoomH,
        paddingBottom: 14/zoomH,
        borderWidth: 1,
        borderBottomWidth: 0,
        borderColor: "#eeeeee"
    },
    contentForwarding:{
        marginLeft:10/zoomW,
        marginRight:10/zoomW,
    },
    userNameBlack:{
        fontSize:14,
        color:"#000000"
    },
    centerWrap: {
        width: '100%',
        height: 213.5,
        justifyContent: 'center',
        alignItems: 'center'
    },
    videoTimeWrap: {
        width: 40.5 / zoomW,
        height: 20,
        backgroundColor: 'rgba(0,0,0,0.45)',
        borderRadius: 10,
        justifyContent: 'center',
        alignItems: 'center',
        position: 'absolute',
        right: 15 / zoomW,
        bottom: 16
    },
    videoWrap: {
        width: 345 / zoomW,
        height: 213.5,
        backgroundColor: 'rgba(0,0,0,0.8)',
        justifyContent: 'center',
        alignItems: 'center'
    },
    playButton: {
        width: 50 / zoomW,
        height: 50 / zoomW,
    },
    playControl: {
        width: 15 / zoomW,
        height: 19,
    },
    shrinkControl: {
        width: 15 / zoomW,
        height: 15 / zoomW,
    },
    vTime: {
        fontSize: 12,
        color: '#fff',
        marginRight: 15 / zoomW
    },
    control: {
        width: '100%',
        height: 49,
        backgroundColor: 'rgba(0, 0, 0, 0.3)',
        position: 'absolute',
        bottom: 0,
        left: 0,
        flexDirection: 'row',
        alignItems:'center',
    },
    maskWrap: {
        width: '100%',
        height: '100%',
        backgroundColor: '#000',
        alignItems: 'center',
        justifyContent: 'center',
        position: 'absolute',
        top: 0,
        left: 0,
    },
    continueBtn: {
        width: 100 / zoomW,
        height: 28,
        borderRadius: 4,
        borderWidth: StyleSheet.hairlineWidth,
        borderColor: '#fff',
        justifyContent: 'center',
        alignItems: 'center',
        marginTop: 20
    },
    topInfoWrap: {
        flex: 1,
        height: '100%',
        flexDirection: 'row',
        alignItems: 'center',
    },
    avatar:{
        width: 32 / zoomW,
        height: 32 / zoomW,
        borderRadius: 16 / zoomW
    },
    avatarV:{
        width: 10 / zoomW,
        height: 10 / zoomW,
        position: 'absolute',
        right: 4 / zoomW,
        bottom: 2 / zoomW
    },
    hasFollow: {
        width: 60 / zoomW,
        height: 30,
        backgroundColor: '#E9E9E9',
        borderRadius: 4,
        justifyContent: 'center',
        alignItems: 'center'
    },
    notFollow: {
        width: 60 / zoomW,
        height: 30,

        borderRadius: 4,
        justifyContent: 'center',
        alignItems: 'center'
    },

    tabWrap: {
        width: '100%',
        height: 32/zoomH,
        backgroundColor:'#fff',
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent:'space-between',
    },
    itemTabWrapBg:{
        height:'100%',
        flexDirection:'row',
        justifyContent:'space-between',
        alignItems:'center'
    },
    tabMenuActiveWord: {
        fontSize: 14,
        color: '#000',
        fontWeight:'bold'
    },
    tabMenuWord: {
        fontSize: 14,
        color: 'rgba(0,0,0,0.45)',
    },
    tabBtn: {
        height: '100%',
        justifyContent: 'center',
        alignItems: 'center',
        paddingLeft: 15/zoomW,
        paddingRight: 15/zoomW,
    },
    lineStyle: {
        width: 32,
        height: 3,
        borderRadius:2,
        position:'absolute',

        bottom: 0,
    },
    itemBackground:{
        width:'100%',
        flex:1,
        padding:15/zoomW,
        backgroundColor:'#fff',
        flexDirection :'row',
    },
    commonAvatar:{
        width:36/zoomW,
        height:36/zoomW,
        borderRadius:18/zoomW
    },
    commonAvatarV:{
        width:10/zoomW,
        height:10/zoomW,
        position:'absolute',
        right:1/zoomW,
        bottom:1/zoomW
    },
    userNameBlue:{
        marginTop:2,
        fontSize: 14,
        color:'#576B95',
    },
    userIdentity:{
        fontSize: 12,
        color:'#c3c3c3'
    },
    content:{
        fontSize: 16,
        color:'rgba(0,0,0,0.85)',
        marginTop:10/zoomH
    },
    textPrise:{
        fontSize: 13,
        color:'rgba(0,0,0,0.65)',
        marginLeft:5/zoomW
    },
    textPrised:{
        fontSize: 13,
        color:'#EF524C',
        marginLeft:5/zoomW
    },
    time:{
        fontSize: 12,
        color:'rgba(0,0,0,0.45)',
    },
    reply:{
        alignItems:'center',
        justifyContent:'center',
        paddingLeft:10,
        paddingRight:10,
        paddingTop:1,
        paddingBottom:1,
        backgroundColor:'#F3F5F6',
        borderRadius:10,
    },
});