videoDetail.js 69.6 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
/**
 * Created by xiniu on 2018/11/12.
 */
import React, {Component} from 'react';
import {
    ActivityIndicator,
    DeviceEventEmitter,
    Dimensions,
    FlatList,
    Image, InteractionManager,
    Keyboard,
    Modal,
    NativeModules,
    NetInfo,
    Platform,
    ScrollView,
    StatusBar,
    StyleSheet,
    Text,
    TouchableOpacity,
    TouchableWithoutFeedback,
    View
} from 'react-native';
import {UIManager} from 'NativeModules';
import Video from 'react-native-video';
import Orientation from 'react-native-orientation';
import moment from 'moment';
import Slider from 'react-native-slider';
import {observer} from 'mobx-react';

import { dateToMsgTime, getHeaderPadding, isIphoneX, getHomeColor,xnToast, NoDoublePress } from '../../utils/utils';
import {zoomH} from '../../utils/getSize';
import AppService from '../../service/AppService';
import videoDetailLogic from './videoDetailLogic';
import RichText from "../../widget/RichText";
import CommentInput from '../detail/CommentInput';
import CommentMore from '../detail/CommentMore';
import {screenH} from "../../utils/ScreenUtil";

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/bq_q.png');
const forwarding = require('../../img/zf.png');
const reward = require('../../img/reward.png');
const close = require('../../img/close.png');
const scW = require('../../img/collect.png');
const scY = require('../../img/collect_me.png');

const screenWidth = Dimensions.get('window').width;
const screenHeight = Platform.OS === 'ios' ? Dimensions.get('window').height : Dimensions.get('window').height - StatusBar.currentHeight;
const zoomW = 750 / parseInt(Dimensions.get('window').width);
const pageSize = 20;

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 VideoDetail extends Component {
    static navigationOptions = ({ navigation, screenProps }) => ({
        header: null
    });

    logic = new videoDetailLogic();

    constructor(props) {
        super(props);
        this.reGetThreadDetailInfo = null;
        this.refreshReplyList = null;
        this._gestureHandlers = {
            onStartShouldSetResponder: () => false,
            // 对触摸进行响应
            onMoveShouldSetResponder: () => {
                Keyboard.dismiss();
                return false;
            },
        };
        this.state = {
            id: this.props.navigation.state.params.id || null,
            detail: {},
            videoOriginWidth:0,// 视频原始宽度,通过video组件的natureSize来取得,不允许改变
            videoOriginHeight:0,// 视频原始高度,通过video组件的natureSize来取得,不允许改变
            videoOriginHW:0,// 视频原始的高宽比,用于根据宽度确定高度(当视频为横屏拍摄时),不允许改变
            videoWidth: screenWidth,// 用来约束视频组件的宽度,来实现全屏效果,计算获得
            videoHeight: 190.5 + getHeaderPadding(),// 用来约束视频组件的高度,来实现全屏效果,计算获得
            videoResizeMode:'contain',// 视频的缩放类型,默认是不拉升,如果有需要可以调整,如横屏的时候撑满画面
            hideStatusBar:false,// 是否隐藏状态栏,当在全屏的时候隐藏状态栏
            showVideoControl: false, // 是否显示视频控制组件
            duration: 0,               // 视频的总时长
            isFullScreen: false,     // 当前是否全屏显示
            playFromBeginning: false, // 是否从头开始播放
            firstIn: false,
            loading: false,
            hasFollowed: false,
            numberOfLines: 1,
            commentList: [],
            loadMore: false,
            mobileConnect: false,
            attentionID: null,
            isBuffer: false,
            hasCollect: false,
            gapHeight: isIphoneX() ? getHeaderPadding() : 0,
            isShowCommentInput:false // 是否显示CommentInput输入框组件
        };
    }

    componentWillMount() {
        const _this = this;

        global.pauseDetailVideo = this.pauseVideo;
        global.recoverDetailVideo = 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) {

                        _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, '--------------');
                if (!!results[0].hasBeenDeleted){
                    xnToast("帖子信息不存在或已被删除");
                    _this.props.navigation.goBack();
                    return
                }
                let videoUrl = '';
                let videoCover = '';
                let videoSize = 0;
                let attentionID = null;
                let threadExtend = results[0].threadExtend || {};
                let originThread = threadExtend.originThread || {};
                let attachmentList = threadExtend.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;
                _this.setState({
                    detail: threadExtend,
                    hasFollowed: hasFollowed,
                    attentionID: attentionID,
                    firstIn: false
                }, () => {
                    _this.getReplyList();
                    // 获取网络状态
                    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.refreshReplyList = DeviceEventEmitter.addListener('refreshReplyList',function(){
            console.log('refreshReplyList');
            {_this.setState({
                commentList:[],
                loadMore:false,
            },function(){
                _this.getReplyList();
            })
            }
        });
        // 关闭CommentInput输入框组件的通知
        this.closeCommentInputIos = DeviceEventEmitter.addListener('closeCommentInputIos',function(){
            console.log("closeCommentInputIos");
            _this.setState({
                isShowCommentInput:false,
            })
        });
    };

    componentWillUnmount() {
        Orientation.lockToPortrait();

        global.pauseDetailVideo = null;
        global.recoverDetailVideo = null;

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

    // 获取帖子详情
    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) {
                    _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 = threadExtend.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;
                    _this.setState({
                        detail: threadExtend,
                        hasFollowed: hasFollowed,
                        attentionID: attentionID,
                        loading: false
                    });
                }
            }).catch((error) => {
                _this.setState({
                    loading: false
                }, () => {
                    xnToast(error.message);
                });
            })
        } else {
            xnToast('暂无网络连接,请稍后重试!')
        }
    }

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

    // 关注、取消关注
    followClick() {
        const _this = this;
        if (this.state.loading){
            return;
        }
        if (global.isConnected){
            this.setState({
                loading: true
            });
            const data = this.state.detail;
            if(this.state.hasFollowed) {
                let params = {
                    id: this.state.attentionID
                };
                AppService.cancleAttention(params).then((data) => {

                    if (data.message) {
                        xnToast(data.message);
                        _this.setState({
                            loading: false
                        });
                        return;
                    }
                    if (!!data.errors === true && !!data.errors.length > 0) {
                        _this.setState({
                            loading: false
                        });
                        xnToast(data.errors[0].message);
                    } else {
                        xnToast('取消关注');
                        _this.setState({
                            loading: false,
                            hasFollowed: false
                        });
                        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.setState({
                            attentionID: data.id || null,
                            loading: false,
                            hasFollowed: true
                        });
                        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 {
            xnToast('暂无网络连接,请稍后重试!');
        }
    };

    // 展开收起
    changeLines() {
        if(this.state.numberOfLines === 1) {
            this.setState({
                numberOfLines: null
            })
        } else {
            this.setState({
                numberOfLines: 1
            })
        }
    }

    //获取回复列表
    getReplyList() {
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        let length =  this.state.commentList.length;
        if (length % pageSize == 0 && !this.state.loadMore) {
            let data = this.state.detail;
            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,
            };
            console.log(params);
            this.setState({
                loadMore: true,
            });
            AppService.queryCommentAndReply(params).then((data) => {
                this.setState({
                    loadMore: false,
                });
                console.log(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({
                        commentList:this.state.commentList.concat(data.result),
                    })
                }
            }).catch((error) => {
                this.setState({
                    loadMore: false,
                });
                xnToast(error)
            })
        }
    };

    toCommentReply(id){
        this.props.navigation.navigate("CommentReply",{id:id})
    }

    //点赞
    _basicStarClick (isLike,type){
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        let data = this.state.detail;
        let _this = this;
        //点赞
        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) {
                    xnToast(data.message);
                    return;
                }
                if (data.errors.length > 0) {
                    xnToast(data.errors[0].message);
                } else {
                    xnToast('点赞成功');
                    _this.getThreadDetailInfo();
                    DeviceEventEmitter.emit('refreshHomeList');
                }
            }).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.getThreadDetailInfo();
                    DeviceEventEmitter.emit('refreshHomeList');
                }
            }).catch((error) => {
                xnToast(error);
            })
        }
    };

    // 收藏
    collect(isCollect) {
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        let data = this.state.detail;
        //收藏
        if (isCollect){
            let params = {
                forumId: data.forumId,//社区id
                boardId: data.boardId,//板块id
                threadId: data.id,//帖子id
                collectUserId: global.userId,//收藏用户id
                collectUserName: global.userName,//收藏用户名字
            };
            console.log(params);
            AppService.collect(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.getThreadDetailInfo();
                }
            }).catch((error) => {
                xnToast(error)
            })
        }else {
            //取消收藏
            let params = {
                id:data.collect.id,//社区id
            };
            console.log(params);
            AppService.cancleCollect(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.getThreadDetailInfo();
                }
            }).catch((error) => {
                xnToast(error)
            })
        }
    }

    //点赞
    _starClick (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();
                })
            }
        }).catch((error) => {
            xnToast(error)
        })
    }

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

    //渲染item
    keyExtractor = (item,index) => index;
    renderItem({item,index}){
        return (
            <TouchableOpacity style={styles.itemBackground} activeOpacity={1} onPress={() => NoDoublePress.onPress(() => this.toCommentReply(item.id))} key={index}>
                <TouchableOpacity style={styles.commonAvatar} onPress={() => NoDoublePress.onPress(() => this.toPersonal(!!item.userExtend ? item.userExtend.id : ''))}>
                    <Image  style={styles.commonAvatar}
                            source={!!item.userExtend && !!item.userExtend.avatar?{uri: item.userExtend.avatar +'?x-oss-process=image/resize,w_100'} :defaultIcon}
                            resizeMode="cover" />
                    {!!item.userExtend && !!item.userExtend.isAuthented &&<Image  style={styles.commonAvatarV} source={vIcon} resizeMode="cover" />}
                </TouchableOpacity>
                <View style = {{marginLeft:20/zoomW,flex:1}} >
                    <View style = {{flex:1,flexDirection:'row',justifyContent:'space-between'}}>
                        <Text style = {styles.userNameBlue}>{item.userName}</Text>
                        <TouchableOpacity style = {{flexDirection:'row',marginRight:20/zoomW,alignItems:'center'}}
                                          activeOpacity={1}
                                          onPress={() => NoDoublePress.onPress(() => this._starClick(!!item.threadLike && item.threadLike.isActive ? false : true, item))}>
                            <Image style={{width:16/zoomH,height:16/zoomH}} source={!!item.threadLike && item.threadLike.isActive? prised:prise} resizeMode="cover"  ></Image>
                            {!!item.threadCommentReplyStatistics && item.threadCommentReplyStatistics.likeNum > 0
                            && <Text style = {{fontSize: 13,color:'rgba(0,0,0,0.65)',marginLeft:20/zoomW}}>{item.threadCommentReplyStatistics.likeNum}</Text>}
                        </TouchableOpacity>
                    </View>
                    <Text style = {styles.userIdentity}>{!!item.userExtend && !!item.userExtend.identity?item.userExtend.identity:''}</Text>
                    <RichText
                        item={item.richContent}
                        nav={this.props.navigation}
                        clearNumberOfLine  ={true}
                    />
                    {!!item.attachmentList && item.attachmentList.length>0 &&
                    <TouchableOpacity style={{width:'55%',height:100,marginTop:10/zoomH,justifyContent:'center'}} activeOpacity={1}
                                      onPress={() => NoDoublePress.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',marginTop:2/zoomH}}>
                        <View style = {{flexDirection:'row',alignItems:'center'}}>
                            <Text style = {styles.time}>{dateToMsgTime(item.creationTime)+' · '} </Text>
                            {!!item.threadCommentReplyStatistics && item.threadCommentReplyStatistics.replyNum > 0
                            && <Text style = {false?styles.time:styles.reply}>{item.threadCommentReplyStatistics.replyNum + '回复'}</Text>}
                        </View>
                        {item.userId == global.userId &&
                        <TouchableOpacity onPress={() => NoDoublePress.onPress(() => this.deleteComment(item))}>
                            <Text style = {styles.time}>删除</Text>
                        </TouchableOpacity>}
                    </View>
                </View>
            </TouchableOpacity>
        );
    }

    //无数据时的展示
    _emptyView(){
        return(
            <View style = {{width:'100%',marginTop:30,alignItems:'center'}}>
                <Text style = {{fontSize:12,color:'#c3c3c3'}}>暂无评论</Text>
            </View>
        );
    };

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

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


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


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

    //评论
    /**
     *  @param inputStr:输入法人内容
     *
     */
    toComment=(data)=> {
        if (!global.isConnected){
            xnToast('暂无网络连接,请稍后重试!');
            return;
        }
        this.setState({
            loading: true,
        });
        let detailInfo = this.state.detail;
        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) {
                this.setState({
                    loading:false,
                }, () => {
                    xnToast(data.message);
                });
                return;
            }
            if (data.errors.length > 0) {
                this.setState({
                    loading:false,
                }, () => {
                    xnToast(data.errors[0].message);
                });
            } else {
                if(this.refs.CommentInput != undefined){
                    InteractionManager.runAfterInteractions(() => {
                        this.refs.CommentInput.reset();
                    });
                }
                //评论列表刷新
                this.setState({
                    loading: false,
                    commentList: [],
                    loadMore:false,
                }, () => {
                    xnToast("已评论");
                    this.getReplyList();
                });
                if (isForward) {
                    DeviceEventEmitter.emit('refreshForward');
                    DeviceEventEmitter.emit('refreshList');
                }
                DeviceEventEmitter.emit('refreshHomeList');
            }
        }).catch((error) => {
            this.setState({
                loading:false,
            }, () => {
                xnToast(error);
            });
        })
    };

    renderCommentInput(){
        return (
            <View style = {styles.inputBg} >
                <TouchableOpacity style = {styles.greyRadiusBg} onPress={() => this.commentClick()}>
                    <Text style = {{fontSize:14,color:'#000000',marginLeft:14/zoomW}}>写评论...</Text>
                    <Image style={{width:40/zoomW,height:40/zoomW,marginRight:16/zoomW}} source={emj} resizeMode="cover" />
                </TouchableOpacity>
                {/*点赞*/}
                <TouchableOpacity onPress={() => NoDoublePress.onPress(() =>
                    this._basicStarClick(!!this.state.detail.threadLike && !!this.state.detail.threadLike.isActive ? false : true, 0)
                )}>
                    <Image style={styles.img} source={!!this.state.detail.threadLike && !!this.state.detail.threadLike.isActive ? prised : prise} resizeMode="cover" />
                </TouchableOpacity>
                {/*收藏*/}
                <TouchableOpacity onPress={() => NoDoublePress.onPress(() =>
                    this.collect(!!this.state.detail.collect && this.state.detail.collect.isActive ? false : true)
                )}>
                    <Image style={styles.img} source={!!this.state.detail.collect && this.state.detail.collect.isActive ? scY : scW} resizeMode="cover" />
                </TouchableOpacity>
                {/*转发*/}
                <TouchableOpacity onPress={() => NoDoublePress.onPress(() => this._forwardingClick())}>
                    <Image style={styles.img} source={forwarding} resizeMode="cover" />
                </TouchableOpacity>
            </View>
        );
    }

    // 滚动
    scroll(event) {
        let Y = event.nativeEvent.contentOffset.y;
        if(Y > 0) {
            this._refView.setNativeProps({
                style: [styles.topInfoWrap, { borderBottomWidth: StyleSheet.hairlineWidth }]
            })
        } else {
            this._refView.setNativeProps({
                style: [styles.topInfoWrap, { borderBottomWidth: 0 }]
            })
        }
    }

    renderListHeader(){
        let detail = this.state.detail;
        return(
            <View style={{ borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: '#eee' }}>
                <View style={{ width: '100%', paddingLeft: 30 / zoomW, flexDirection: 'row', marginBottom: 6 }}>
                    <View style={{ flex: 1 }}>
                        <RichText
                            item={!!detail.threadDetail ? (detail.threadDetail.richContent || '<div>暂无内容</div>') : '<div>暂无内容</div>'}
                            nav={this.props.navigation}
                            clearNumberOfLine  ={true}
                        />
                        {/*<Text style={{ fontSize: 17, color: '#000' }} numberOfLines={this.state.numberOfLines}>{!!detail.threadDetail ? (detail.threadDetail.content || '暂无内容') : '暂无内容'}</Text>*/}
                    </View>
                    <TouchableOpacity activeOpacity={0.8} style={styles.arrowIconWrap} onPress={() => this.changeLines()}>
                        <Image style={{ width: 34 / zoomW, height: 10 }} source={this.state.numberOfLines === 1 ? require('../../img/down_Arrow.png') : require('../../img/up_Arrow.png')} resizeMode="cover" />
                    </TouchableOpacity>
                </View>
                {this.state.numberOfLines !== 1 && <View style={styles.bottomInfoWrap}>
                    <Text style={{ fontSize: 12, color: 'rgba(0,0,0,0.45)' }}>
                        {!detail.isForward && '原创 | '}{(!!detail.threadStatistics && detail.threadStatistics.readNum) ? Number(detail.threadStatistics.readNum) + 1 : 1}次播放 | {!!detail.creationTime ? moment(new Date(parseInt(detail.creationTime))).format('YYYY年MM月DD日') : '----年--月--日'}发布
                    </Text>
                </View>}
            </View>
        )
    }

    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>
        )
    }

    render() {
        let detail = this.state.detail;
        let originThread = detail.originThread || {};
        let rotateDeg = detail.threadVideoDirection || originThread.threadVideoDirection || 0;
        return (
            <View style={styles.container} onLayout={this._onLayout} {...this._gestureHandlers}>
                <StatusBar
                    backgroundColor={'rgba(0,0,0,0.8)'}
                    barStyle={'light-content'}
                    networkActivityIndicatorVisible
                    hidden={this.state.hideStatusBar}
                />
                <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 && <View style={[styles.videoWrap, {
                    width: '100%',
                    height: this.state.videoHeight,
                    paddingTop: this.state.gapHeight
                }]}>
                    {!!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={rotateDeg == 0?'cover':'contain'}
                            resizeMode={this.state.videoResizeMode}
                            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 = {rotateDeg ==0 ?'cover':'contain'}
                                                               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', paddingTop: 0, justifyContent: 'center' }]}>
                                    <ActivityIndicator size="large" color="#fff"/>
                                    <Text style={{ fontSize: 14, color: '#fff', marginTop: 8 }}>视频缓冲中…</Text>
                                </View>
                            </View>
                        }
                        {!this.state.isBuffer && <TouchableWithoutFeedback onPress={() => this.hideControl()}>
                            <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: 100 / zoomW, height: 100 / 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 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: 25 / zoomW, marginRight: 0 }]}>{formatTime(this.state.duration)}</Text>
                        <TouchableOpacity style={{ paddingLeft: 25 / zoomW, paddingRight: 30 / 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' }}>播放将消耗{ (detail.videoSize/1024/1024).toFixed(2) || 0.00 }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>}
                {!this.state.firstIn && !this.state.isFullScreen && <View style={{ width: '100%', flex: 1, backgroundColor: '#fff' }}>
                    <View ref={(e) => this._refView = e} 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_100' } : 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, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginLeft: 16 / zoomW }}>
                            <View style={{ flex: 1 }}>
                                <Text style={{ fontSize: 14, color: 'rgba(0,0,0,0.85)' }} numberOfLines={1}>{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>
                            {!!detail.user && detail.user.id != global.userId &&
                            <TouchableOpacity activeOpacity={0.8} style={this.state.hasFollowed ? styles.hasFollow : [styles.notFollow,{backgroundColor: global.homeColor}]} onPress={() => NoDoublePress.onPress(() => this.followClick())}>
                                <Text style = {{ fontSize: 14, color: this.state.hasFollowed ? 'rgba(0,0,0,0.45)' : '#fff' }}>{this.state.hasFollowed ? '已关注' : '关注'}</Text>
                            </TouchableOpacity>
                            }
                        </View>
                    </View>
                    <View style = {{ flex: 1 }}>
                        <FlatList
                            style={{ flex: 1 }}
                            alwaysBounceVertical={false}
                            bounces={false}
                            onScroll={this.scroll.bind(this)}
                            refreshing={false}
                            onEndReachedThreshold={0.01}
                            onEndReached={() => this.getReplyList()}
                            keyExtractor={this.keyExtractor}
                            data={this.state.commentList}
                            ListHeaderComponent = {this.renderListHeader()}
                            ListEmptyComponent = {this._emptyView()}
                            renderItem={this.renderItem.bind(this)}
                        />
                        {/*更多加载*/}
                        {this.state.loadMore && this.renderLoading()}
                    </View>
                </View>}
                {!this.state.firstIn && !this.state.isFullScreen && <View style={{ width: '100%', height: getHeaderPadding(), position: 'absolute', left: 0, top: 0, backgroundColor: 'transparent' }} />}
                {!this.state.firstIn && !this.state.isFullScreen && <View style={styles.headerWrap}>
                    <TouchableOpacity activeOpacity={0.8} style={styles.backWrap}
                                      onPress={() => NoDoublePress.onPress(() => {
                                          this.props.navigation.goBack()})}>
                        <Image source={require('../../img/backWhite.png')} style={{ width: 20 / zoomW, height: 17 }} resizeMode="contain" />
                    </TouchableOpacity>
                    { (detail.threadUserId == global.userId || global.showWchatShare )&& <TouchableOpacity activeOpacity={0.8} style={styles.rightWrap} onPress={() => NoDoublePress.onPress(() => this.refs['CommentMore'].openModal())}>
                        <Image source={require('../../img/more_w.png')} style={{ width: 42 / zoomW, height: 4 }} resizeMode="contain" />
                    </TouchableOpacity>}
                </View>}
                {/*/!*评论输入框*!/*/}
                {!this.state.firstIn && !this.state.isFullScreen && this.renderCommentInput()}
                {/*更多操作*/}
                <CommentMore
                    ref='CommentMore'
                    detailInfo = {this.state.detail}
                    collectClick = {()=>{}}
                    deleteClick = {()=>{this.props.navigation.goBack();}}
                    fromVideoDetail={true}
                    forum={global.forum}
                />
                {Platform.OS == 'ios' && !this.state.loading && this.state.isShowCommentInput && <CommentInput  ref = "CommentInput"
                                                                                                                boardId = {this.state.detail.boardId}
                                                                                                                callback = { (data)=>{this.toComment(data)}}
                                                                                                                uploadCallback = {(isLoading) =>{this.setState({loading:isLoading})}}
                                                                                                                nav = {this.props.navigation}
                                                                                                                hasNavHeight = {false}
                />}
                {Platform.OS == 'android' &&<CommentInput  ref = "CommentInput"
                                                           boardId = {this.state.detail.boardId}
                                                           callback = { (data)=>{this.toComment(data)}}
                                                           uploadCallback = {(isLoading) =>{this.setState({loading:isLoading})}}
                                                           nav = {this.props.navigation}
                                                           hasNavHeight = {false}
                />}
            </View>
        )
    }

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

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

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

    _onLoaded = (data) => {
        console.log('视频加载完成');
        this.setState({
            duration: data.duration,
            videoOriginWidth:data.naturalSize.width,
            videoOriginHeight:data.naturalSize.height,
            videoOriginHW:data.naturalSize.height/data.naturalSize.width,
            // isBuffer: false,
        },()=>{
            let needScale = false;
            if (this.state.videoOriginHeight > 0 &&
                this.state.videoOriginWidth > 0 &&
                this.state.videoOriginWidth>this.state.videoOriginHeight){
                // 当且仅当视频是横屏拍摄时,根据屏幕看度来适配视频高度
                needScale = true;
            }
            if (needScale && !this.state.isFullScreen) {
                this.setState({
                    videoHeight: this.state.videoOriginHW*screenWidth+getHeaderPadding(),
                })
            }
        });
    };

    _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.videoOriginWidth>=this.state.videoOriginHeight){
            if (this.state.isFullScreen) {
                // 横屏恢复
                if (Platform.OS === 'ios') {
                    Orientation.lockToLandscape();
                    Orientation.lockToPortrait();
                } else {
                    Orientation.lockToPortrait();
                }
                this.setState({
                    videoWidth: screenWidth,
                    videoHeight: (this.state.videoOriginHW>0)?
                        (this.state.videoOriginHW*screenWidth+getHeaderPadding()):
                        (190.5 + getHeaderPadding()),
                    isFullScreen:false,
                    videoResizeMode:'contain',// 恢复contain
                    gapHeight: isIphoneX() ? getHeaderPadding() : 0,
                    hideStatusBar:false,
                })
            } else {
                // 横屏
                if (Platform.OS === 'ios') {
                    Orientation.lockToPortrait();
                    Orientation.lockToLandscape();
                } else {
                    Orientation.lockToLandscape();
                }
                // 这里要获取当前屏幕的宽度高度,常量保存的是竖屏的状态
                this.setState({
                    videoWidth: screenHeight,
                    videoHeight: screenWidth,
                    isFullScreen:true,
                    videoResizeMode:'cover',// 横屏拍摄的视屏当切换为横屏的时候拉升满全屏
                    gapHeight: 0,
                    hideStatusBar:true,
                })
            }
        }else{
            // 视频是竖屏拍摄的情况
            if (this.state.isFullScreen) {
                // 恢复
                this.setState({
                    videoWidth:screenWidth,
                    videoHeight: 190.5 + getHeaderPadding(),
                    isFullScreen:false,
                    videoResizeMode:'contain',
                    gapHeight: isIphoneX() ? getHeaderPadding() : 0,
                    hideStatusBar:false,
                });
            } else {
                // 竖屏最大化
                this.setState({
                    videoWidth:screenWidth,
                    videoHeight:screenHeight,
                    isFullScreen:true,
                    videoResizeMode:'cover',
                    gapHeight:0,
                    hideStatusBar:true,
                })
            }
        }
    }

    // 暂停视频
    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) => {
        // 只在进来的时候做一次,当视频加载成功后就可以根据获取到的视频尺寸来缩放界面了
        if(this.state.videoWidth = 0){
            //获取根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,
                    gapHeight: 0,
                    isFullScreen: true,
                })
            } else {
                this.setState({
                    videoWidth: width,
                    videoHeight: 190.5 + getHeaderPadding(),
                    gapHeight: isIphoneX() ? getHeaderPadding() : 0,
                    isFullScreen: false,
                })
            }
        }
        // Orientation.unlockAllOrientations();
    };

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
        display: 'flex',
        alignItems: 'center',
        justifyContent:'flex-end'
    },
    headerWrap: {
        width: '100%',
        height: 44,
        backgroundColor: 'transparent',
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
        position: 'absolute',
        left: 0,
        top: getHeaderPadding()
    },
    backWrap: {
        height: '100%',
        justifyContent: 'center',
        paddingLeft: 30 / zoomW,
        paddingRight: 30 / zoomW
    },
    rightWrap: {
        height: '100%',
        justifyContent: 'center',
        paddingLeft: 44 / zoomW,
        paddingRight: 44 / zoomW
    },
    loadingBg: {
        position: "absolute",
        top: 0,
        width: "100%",
        height: "100%",
        display: "flex",
        justifyContent: "center",
        alignItems: "center"
    },
    loadingBox: {
        width: 200 / zoomW,
        height: 120 / zoomH,
        backgroundColor: "rgba(0,0,0,.5)",
        borderRadius: 8,
        display: "flex",
        alignItems: "center",
        justifyContent: "center"
    },
    videoWrap: {
        width: '100%',
        height: 190.5 + getHeaderPadding(),
        backgroundColor: 'rgba(0,0,0,0.8)',
        justifyContent: 'center',
        alignItems: 'center'
    },
    playButton: {
        width: 100 / zoomW,
        height: 100 / zoomW,
    },
    playControl: {
        width: 29 / zoomW,
        height: 19,
        marginLeft: 30 / zoomW,
    },
    shrinkControl: {
        width: 30 / zoomW,
        height: 30 / zoomW,
    },
    vTime: {
        fontSize: 12,
        color: '#fff',
        marginLeft: 42 / zoomW,
        marginRight: 42 / 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',
        paddingTop: 65.5 + getHeaderPadding(),
        position: 'absolute',
        top: 0,
        left: 0,
    },
    continueBtn: {
        width: 200 / zoomW,
        height: 28,
        borderRadius: 4,
        borderWidth: StyleSheet.hairlineWidth,
        borderColor: '#fff',
        justifyContent: 'center',
        alignItems: 'center',
        marginTop: 20
    },
    topInfoWrap: {
        width: '100%',
        height: 50,
        flexDirection: 'row',
        alignItems: 'center',
        paddingLeft: 30 / zoomW,
        paddingRight: 30 / zoomW,
        borderBottomColor: '#eee'
    },
    avatar:{
        width: 64 / zoomW,
        height: 64 / zoomW,
        borderRadius: 32 / zoomW
    },
    avatarV:{
        width: 20 / zoomW,
        height: 20 / zoomW,
        position: 'absolute',
        right: 8 / zoomW,
        bottom: 4 / zoomW
    },
    hasFollow: {
        width: 120 / zoomW,
        height: 24,
        backgroundColor: '#E9E9E9',
        borderRadius: 4,
        justifyContent: 'center',
        alignItems: 'center'
    },
    notFollow: {
        width: 120 / zoomW,
        height: 24,
        borderRadius: 4,
        justifyContent: 'center',
        alignItems: 'center'
    },
    arrowIconWrap: {
        padding: 9,
        paddingLeft: 30 / zoomW,
        paddingRight: 30 / zoomW
    },
    bottomInfoWrap: {
        width: '100%',
        paddingLeft: 30 / zoomW,
        paddingRight: 30 / zoomW,
        paddingBottom: 20,
    },
    itemBackground:{
        width:'100%',
        flex:1,
        padding: 15/zoomH,
        flexDirection :'row',
    },
    commonAvatar:{
        width:36/zoomH,
        height:36/zoomH,
        borderRadius:18/zoomH
    },
    commonAvatarV:{
        width:10/zoomH,
        height:10/zoomH,
        position:'absolute',
        right:2/zoomW,
        bottom:2/zoomW
    },
    userNameBlue:{
        fontSize: 14,
        color:'#576B95',
    },
    userIdentity:{
        fontSize: 12,
        color:'#c3c3c3'
    },
    time:{
        fontSize: 12,
        color:'rgba(0,0,0,0.45)',
        marginTop:8/zoomH
    },
    reply:{
        fontSize: 10,
        color:'black',
        marginTop:5/zoomH,
        backgroundColor:'#eeeeee',
        borderRadius:10,
        paddingLeft:10,
        paddingRight:10,
        paddingTop:2,
        paddingBottom:2
    },
    inputBg:{
        width:'100%',
        height:isIphoneX()?(44/zoomH+34):44/zoomH,
        backgroundColor:'#fff',
        flexDirection:'row',
        justifyContent:'space-between',
        alignItems:'center',
        paddingLeft:40/zoomW,
        paddingRight:40/zoomW,
        paddingBottom:isIphoneX()?34:0,
        borderColor: '#ddd',
        borderWidth: StyleSheet.hairlineWidth,
    },
    greyRadiusBg:{
        flex:1,flexDirection:'row',height:32/zoomH,justifyContent:'space-between',alignItems:'center',borderRadius:38/zoomW,backgroundColor:'#eeeeee'
    },
    img:{
        width:40/zoomW,height:40/zoomW,marginLeft:50/zoomW
    },
});