MyPage.js 50.8 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
import React, { Component } from "react";
import {
    DeviceEventEmitter,
    FlatList,
    Image,
    StyleSheet,
    Text,
    TouchableOpacity,
    View,
    Modal, Animated, StatusBar, CameraRoll, NativeModules,Alert,InteractionManager

} from "react-native";
import ViewShot from "react-native-view-shot"
import {height, width, zoomH, zoomW} from "../../../utils/getSize";
import ItemImageText from "../../component/ItemImageText";
import ItemGoodsView from "../../component/ItemGoodsView";

import QuestionHomeListItem from "../../questions/QuestionHomeListItem";
import ScrollableTabView, {
    DefaultTabBar
} from "react-native-scrollable-tab-view";
import AppService from "../../../service/AppService";
import moment from "moment";
import {getHomeColor, xnToast, getTopHeight, getStatusBarHeight, NoDoublePress} from "../../../utils/utils";
import RNFS from "react-native-fs";
// import ForumHeader from'../../../widget/ForumHeader';
const pic = require("../../../img/defaultIcon.png");
const pageSize = 20;

export default class MyPage extends Component {
    static navigationOptions = ({ navigation, screenProps }) => ({
        title: navigation.state.params.userName,
        headerLeft: (
            <View style={{ flex: 1 }}>
                <TouchableOpacity
                    style={{
                        width: 40,
                        height: 40,
                        justifyContent: "center",
                        alignItems: "center"
                    }}
                    onPress={() => navigation.goBack()}
                >
                    <Image
                        style={{ width: 18 / zoomW, height: 18 / zoomH }}
                        source={require("../../../img/loadBack.png")}
                    />
                </TouchableOpacity>
            </View>
        ),
        headerRight: <View />,
        // headerStyle: {
        //   backgroundColor: "#fff",
        //   elevation: 0,
        //   borderStyle: "solid",
        //   borderColor: "#eee",
        //   borderBottomWidth: StyleSheet.hairlineWidth,
        // }
    });
    constructor(props) {
        super(props);
        this.state = {
            defWebViewHeight: 0,
            id: this.props.navigation.state.params.id, // 获取传过来的userId
            userId: global.userId,
            userName: "", // 用户姓名
            userInfo: {}, // 个人信息
            headPath: "", // 头像地址
            textImageList: [],
            textImageTotalCount: 0,
            questionAnswerList: [],
            questionAnswerTotalCount: 0,
            videoList: [],
            videoTotalCount: 0,
            goodList: [],
            loadMore: false,
            loading: false,
            tabNumber: 0,
            isImageAll: false,
            isQuestionAll: false,
            isVideoAll: false,
            refreshing: false,
            attentionId: null,
            goodsList :[],
            isGoodsAll:false,
            approvedResult :'',//关联商家审核状态
            spamasterResult:"",//正在审核中的商家信息
            modalVisible:false,
            codeUrl:'',
            signUrl:'',
            signText:'',
            queryId:'',// 二维码参数
            associateId:''//登录用户的粉丝Id
        };
    }

    componentWillMount() {
        // 获取网络状态
        const _this = this;
        if (global.isConnected) {
            //获取帖子信息
            this.getFirstThreadList(0, 0,true);
            this.getUserInfo();
            this.getSpamaster();
        } else {
            xnToast("请检查网络");
        }

        this.refreshAttention = DeviceEventEmitter.addListener(
            "refreshAttention",
            function() {
                _this.getUserInfo();
            }
        );

        this.refreshPageInfo = DeviceEventEmitter.addListener(
            "refreshPageInfo",
            function() {
                _this.getUserInfo();
                _this.getSpamaster();
                _this.getFirstThreadList(0, 0,true);
            }
        );
        this.refresh = DeviceEventEmitter.addListener("refreshList", () => {
            this.setState({
                textImageList: [],
                textImageTotalCount: 0
            });
            this.getFirstThreadList(0, 0,true);
        });
        this.refreshComm = DeviceEventEmitter.addListener("refreshCommList", () => {
            this.setState({
                questionAnswerList: []
            });
            this.getFirstThreadList(3, 0,true);
        });
        this.refreshVideo = DeviceEventEmitter.addListener(
            "refreshVideoList",
            () => {
                this.setState({
                    videoList: [],
                    videoListtalCount: 0
                });
                this.getFirstThreadList(2, 0,true);
            }
        );
        this.refreshSpamasterInfo = DeviceEventEmitter.addListener(
            "refreshSpamasterInfo",
            () => {
                _this.getSpamaster();
            }
        );

        if (global.tenantId == '852769418315444224' || global.tenantId == '1038991752041734144') {
            // AppService.getSignInfo({}).then((data) => {
            //     if (data.message) {
            //         return;
            //     }
            //     if (!!data.errors === true && !!data.errors.length > 0) {
            //
            //     } else {
            //         let sginInfo = JSON.parse(data.signRule.image)
            //         _this.setState({
            //             signUrl:sginInfo[0].filePath,
            //             signText:data.signRule.signRuleText,
            //         })
            //     }
            // });
            //
            // AppService.createAppScene({tenantId: global.tenantId,appId:global.weChatBySmallProgramAppId,scene:global.userId}).then((data) => {
            //     if (data.message) {
            //         xnToast(data.message);
            //         return;
            //     }
            //     if (!!data.errors === true && !!data.errors.length > 0) {
            //         xnToast(data.errors[0].message);
            //     } else {
            //         _this.setState({
            //             codeUrl:data.imgUrl,
            //         })
            //
            //     }
            // });

            this.promise1();
        }
    }

    promise1 = () => {
        const _this = this;
        // return  new Promise((resolve, reject) => {
        AppService.getSignInfo({}).then((data) => {
            if (data.message) {
                xnToast(error.message);
                // reject(error.message);
                return;
            }
            if (!!data.errors === true && !!data.errors.length > 0) {
                // reject(data.errors);
                return;
            } else {
                let sginInfo = JSON.parse(data.signRule.image)
                _this.setState({
                    signUrl:sginInfo[0].filePath,
                    signText:data.signRule.signRuleText,
                },()=>{
                    // resolve(true);
                    _this.promise2();
                });
            }
        }).catch((error) => {
            // xnToast(error.message);
            // reject(error.message);
        });
        // });
    };
    promise2 = () => {
        const _this = this;
        // return new Promise((resolve, reject) => {
        AppService.getAssociateMemberBySource({sourceType:"WX_OPEN",unionId:global.unionId,tenantId:global.tenantId,name:global.userName,avatarUrl:!!!global.userAvatar?'':global.userAvatar}).then((data) => {
            if (data.message) {
                xnToast(data.message);
                // reject(error.message);
                return;
            }
            if (!!data.errors === true && !!data.errors.length > 0) {
                xnToast(data.errors[0].message);
                // reject(data.errors[0].message);
                return;
            } else {
                _this.setState({
                    associateId:data.associateMember.id,
                },()=>{
                    // resolve(res);
                    _this.promise3();
                });
            }
        }).catch((error) => {
            // xnToast(error.message);
            // reject(error.message);
        });
        // });
    };
    promise3 = () => {
        const _this = this;
        // return new Promise((resolve, reject) => {
        AppService.saveAppScenceParm({'json':JSON.stringify({userId:this.state.userId,rasId:this.state.associateId})}).then((data) => {
            if (data.message) {
                xnToast(data.message);
                // reject(data.message);
                return;
            }
            if (!!data.errors === true && !!data.errors.length > 0) {
                xnToast(data.errors[0].message);
                // reject(data.errors[0].message);
                return;
            } else {
                _this.setState({
                    queryId:data.id,
                },()=>{
                    // resolve(res);
                    _this.promise4();
                });
            }
        }).catch((error) => {
            // xnToast(error.message);
            // reject(error.message);
        });
        // });
    };
    promise4 = () => {
        const _this = this;
        // return new Promise((resolve, reject) => {
        AppService.createAppScene({tenantId: global.tenantId,appId:global.weChatBySmallProgramAppId,scene:'queryId='+this.state.queryId,page:'pages/community/member-detail/member-detail'}).then((data) => {
            if (data.message) {
                xnToast(data.message);
                // reject(data.message);
                return;
            }
            if (!!data.errors === true && !!data.errors.length > 0) {
                xnToast(data.errors[0].message);
                // reject(data.errors[0].message);
            } else {
                _this.setState({
                    codeUrl:data.imgUrl,
                },()=>{
                    // resolve(res);
                })
            }
        }).catch((error) => {
            // xnToast(error.message);
            // reject(error.message);
        });
        // });
    };

    componentWillUnmount() {
        this.refreshAttention.remove();
        this.refreshPageInfo.remove();
        this.refresh.remove();
        this.refreshComm.remove();
        this.refreshVideo.remove();
        this.refreshSpamasterInfo.remove();
    }

    //获取关联商家绑定状态
    getSpamaster(){
        const _this = this;
        let params = {
            // userId: "1074132681786527744"
            sourceId:global.userId
        };
        AppService.getSpamaster(params).then((data) => {
            console.log('-----getSpamaster--',params,data);
            if (data.message) {
                xnToast(data.message);
                return;
            }
            if (!!data.errors === true && !!data.errors.length > 0) {
                xnToast(data.errors[0].message);
            } else {
                if (!!data.result && data.result.length > 0){
                    let sResult = data.result[0];
                    let approvedResult ;
                    if (sResult.isApproved == undefined){
                        approvedResult = "NEW";
                    }else {
                        if (sResult.isApproved == false){//审核中
                            approvedResult  = "APPROVING";
                        }else if (sResult.isApproved == true && sResult.approveResult == "AGREED" ){//审核通过
                            approvedResult = "AGREED";
                        }else if (sResult.isApproved == true && sResult.approveResult == "DISAGREED" ){//审核被拒
                            approvedResult = "DISAGREED";
                        }else {//没绑过
                            approvedResult = "NEW";
                        }
                    }

                    _this.setState({
                        approvedResult :approvedResult,
                        spamasterResult :sResult
                    })
                }

            }
        });
    }
    //获取用户信息
    getUserInfo() {
        const _this = this;
        let params = {
            forumId: global.forumId,
            id: this.state.id
        };
        AppService.getUserInfo(params).then((data) => {
            // _this.setState({
            //     loading: false
            // });
            console.log('-----getUserInfo--',params,data);
            if (data.message) {
                xnToast(data.message);
                return;
            }
            if (!!data.errors === true && !!data.errors.length > 0) {
                xnToast(data.errors[0].message);
            } else {
                if (!!data.userExtend) {
                    let userInfo = data.userExtend;
                    _this.setState({
                        userInfo: userInfo,
                        userName: userInfo.name,
                        headPath: userInfo.headFileUrl
                    });
                    _this.props.navigation.setParams({
                        userName: userInfo.name
                    });
                }
            }
        })
            .catch(error => {
                xnToast(error);
            });
    }

    // 时间格式化
    timeAgo(dateTimeStamp) {
        // dateTimeStamp是一个时间毫秒,注意时间戳是秒的形式,在这个毫秒的基础上除以1000,就是十位数的时间戳。13位数的都是时间毫秒。
        const minute = 1000 * 60; // 把分,时,天,周,半个月,一个月用毫秒表示
        const hour = minute * 60;
        const day = hour * 24;
        const now = new Date().getTime(); // 获取当前时间毫秒
        const diffValue = now - dateTimeStamp; // 时间差
        if (diffValue < 0) {
            return;
        }
        const minC = diffValue / minute; // 计算时间差的分,时,天,周,月
        const hourC = diffValue / hour;
        const dayC = diffValue / day;
        if (minC >= 1 && hourC < 1) {
            result = parseInt(minC) + "分钟前";
        } else if (hourC >= 1 && dayC < 1) {
            result = parseInt(hourC) + "小时前";
        } else if (dayC >= 1) {
            result = moment(new Date(dateTimeStamp)).format("YYYY/MM/DD");
        } else {
            result = "刚刚";
        }
        return result;
    }


    getGoodsList = (length) => {
        let params = {
            pageNumber:length/pageSize+1,
            pageSize:pageSize,
            // operatingUnitId: "801756150419828736",
            operatingUnitId: "910123914666053632",

            systemType:'B2C',
            deviceType:'MOBILE',
            supplierId: this.state.spamasterResult.ownSupplierId ||0,
            tenantId: global.tenantId
        }
        AppService.findCommodityExtend(params).then(data => {
            console.log('-----findCommodityExtend----',params,data);
            if (data.message) {
                xnToast(data.message);
                return;
            }
            if (data.errors == null || data.errors.length > 0) {
                xnToast(data.errors[0].message);
            } else {
                this.setState({
                    goodsList:data.result,
                })
            }

        });
    }

    // 获取第一页数据
    getFirstThreadList = (threadType, length, isRefresh) => {
        if (isRefresh) {
            if(threadType==0){
                this.setState(
                    {
                        textImageList: [],
                    }
                );
            }else if(threadType==3){
                this.setState(
                    {
                        questionAnswerList: [],
                    }
                );
            }else if(threadType==2){
                this.setState(
                    {
                        videoList: [],
                    }
                );
            }else {
                this.setState(
                    {
                        textImageList: [],
                    }
                );
            }

        }
        const _this = this;
        AppService.queryList({
            forumId: global.forumId,
            threadUserId: this.state.userId,
            pageNumber: length / pageSize + 1,
            searchType: "HAS_PUBLISH",
            sourceFrom:'APP',
            pageSize: pageSize,
            isActive: true,
            threadType: threadType
        }).then(data => {
            if (data.message) {
                xnToast(data.message);
                return;
            }
            if (data.errors == null || data.errors.length > 0) {
                xnToast(data.errors[0].message);
            } else {
                if (threadType == 0) {
                    this.setState(
                        {
                            textImageList: _this.state.textImageList.concat(data.result),
                            textImageTotalCount: data.totalCount
                        },
                        () => {
                            if (_this.state.textImageList.length == Number(data.totalCount)) {
                                _this.setState({
                                    isImageAll: true
                                });
                            }
                        }
                    );
                } else if (threadType == 2) {
                    this.setState(
                        {
                            videoList: _this.state.videoList.concat(data.result),
                            videoListtalCount: data.totalCount
                        },
                        () => {
                            if (_this.state.videoList.length == Number(data.totalCount)) {
                                _this.setState({
                                    isVideoAll: true
                                });
                            }
                        }
                    );
                } else if (threadType == 3) {
                    this.setState(
                        {
                            questionAnswerList: _this.state.questionAnswerList.concat(
                                data.result
                            )
                        },
                        () => {
                            if (
                                _this.state.questionAnswerList.length == Number(data.totalCount)
                            ) {
                                _this.setState({
                                    isQuestionAll: true
                                });
                            }
                        }
                    );
                } else {
                    this.setState(
                        {
                            textImageList: _this.state.textImageList.concat(data.result),
                            textImageTotalCount: data.totalCount
                        },
                        () => {
                            if (_this.state.textImageList.length == Number(data.totalCount)) {
                                _this.setState({
                                    isImageAll: true
                                });
                            }
                        }
                    );
                }
                console.log(this.state.textImageList);
            }
        });
    };

    // 加载更多
    loadMore = threadType => {
        console.log(threadType);
        let length = 0;
        if (threadType == 0) {
            length = this.state.textImageList.length;
            if (this.state.isImageAll) {
                return;
            }
        } else if (threadType == 2) {
            length = this.state.videoList.length;
            if (this.state.isVideoAll) {
                return;
            }
        } else if (threadType == 3) {
            length = this.state.questionAnswerList.length;
            if (this.state.isQuestionAll) {
                return;
            }
        } else {
            length = this.state.textImageList.length;
            if (this.state.isImageAll) {
                return;
            }
        }
        this.getFirstThreadList(threadType, length,false);
    };

    renderImageItem(item, i) {
        let imageSize = this.state.imageList.length;
        let parentHeight = 400 / zoomH;
        let itemWidth, itemHeight;
        if (imageSize == 1) {
            itemWidth = "100%";
            itemHeight = parentHeight;
        } else if (imageSize == 2 || imageSize == 4) {
            itemWidth = "50%";
            itemHeight = parentHeight / 2;
        } else {
            itemWidth = "33%";
            itemHeight = parentHeight / 3;
        }

        return (
            <View
                key={i}
                style={{
                    width: itemWidth,
                    height: itemHeight,
                    padding: 2,
                    backgroundColor: "#FFFFFF"
                }}
            >
                <Image style={{ width: "100%", height: "100%" }} source={pic} />
            </View>
        );
    }

    keyExtractor = (item, index) => index;
    //图文列表
    renderImageTextItem({ item, index }) {
        return <ItemImageText itemList={item} nav={this.props.navigation} />;
    }
    //问答列表
    renderQuestionItem({ item, index }) {
        return <QuestionHomeListItem item={item} nav={this.props.navigation} />;
    }
    //商品列表
    renderGoodsItem({ item, index }) {
        return <ItemGoodsView itemList={item} nav={this.props.navigation} />;
    }
    //视频列表
    renderVideoItem({ item, index }) {
        return (
            <ItemImageText
                itemList={item}
                nav={this.props.navigation}
                isVideo={true}
            />
        );
    }

    // 跳转关注
    goAttention = () => {
        this.props.navigation.navigate("Attention", {
            id: 1,
            name: "Attention",
            userId: global.userId
        });
    };

    goFans = () => {
        this.props.navigation.navigate("Attention", {
            id: 2,
            name: "Attention",
            userId: global.userId
        });
    };

    //关联商家
    relateMerchants(){
        if (this.state.approvedResult == "NEW" || this.state.approvedResult == ""){//之前没有关联过
            this.props.navigation.navigate("RelateMerchants", {
                name: "RelateMerchants",
            });
            return;
        }
        //关联过,审核结果还没有通过
        let _this = this;
        this.props.navigation.navigate("ApplyResult", {
            name:_this.state.spamasterResult.applySupplierName || "",
            isApproving:_this.state.approvedResult == "DISAGREED"? false :true,
            refusedReason : _this.state.spamasterResult.refusedReason || "",
        });
    }
    // 跳转收藏
    goCollect = () => {
        this.props.navigation.navigate("HistoryHome", { name: "HistoryHome", type: 2 });
    };

    // 跳转历史
    goHistroy = () => {
        this.props.navigation.navigate("HistoryHome", { name: "HistoryHome", type: 1 });
    };

    // 分割线
    _separator = () => {
        return <View style={{ height: 6 / zoomH, backgroundColor: "#F3F5F6" }} />;
    };

    // 列表底部
    _footer = () => (
        <View style={styles.footerWrap}>
            <Text style={{ fontSize: 12, color: "#A4A9B0" }}>到底啦</Text>
        </View>
    );

    render() {
        let _this = this;
    let identifyTypeNames = this.state.userInfo.identifyTypeNames?(this.state.userInfo.identifyTypeNames!=''?
        this.state.userInfo.identifyTypeNames.replace(/\,/g,' '):global.defaultInentifyTypeName):
        global.defaultInentifyTypeName;
        return (
            <View style={styles.background}>
                {/*<ForumHeader title={this.props.navigation.state.params.userName} pop navigation={this.props.navigation}/>*/}
                <View style={styles.mineInfo}>
                    <View style={styles.mineInfoLeft}>
                        <View style={styles.headImage}>
                            {!!this.state.headPath ? (
                                <Image
                                    style={{
                                        height: 80 / zoomH,
                                        width: 80 / zoomH,
                                        borderRadius: 40 / zoomH
                                    }}
                                    source={{ uri: this.state.headPath +'?x-oss-process=image/resize,w_200'}}
                                />
                            ) : (
                                <Image
                                    style={{
                                        height: 80 / zoomH,
                                        width: 80 / zoomH,
                                        borderRadius: 40 / zoomH
                                    }}
                                    source={pic}
                                />
                            )}
                        </View>
                    </View>
                    <View style={styles.mineInfoRight}>
                        <View style={styles.upText}>
                            <View>
                                <TouchableOpacity onPress={() => this.goCollect()}>
                                    <View>
                                        <Text style={styles.upTextCount}>
                                            {this.state.userInfo.collectNum}
                                        </Text>
                                    </View>
                                    <View>
                                        <Text style={styles.upTextFont}>收藏</Text>
                                    </View>
                                </TouchableOpacity>
                            </View>
                            <View>
                                <TouchableOpacity onPress={() => this.goAttention()}>
                                    <View>
                                        <Text style={styles.upTextCount}>
                                            {this.state.userInfo.attentionNum}
                                        </Text>
                                    </View>
                                    <View>
                                        <Text style={styles.upTextFont}>关注</Text>
                                    </View>
                                </TouchableOpacity>
                            </View>
                            <View>
                                <TouchableOpacity onPress={() => this.goFans()}>
                                    <View>
                                        <Text style={styles.upTextCount}>
                                            {this.state.userInfo.beAttentionNum}
                                        </Text>
                                    </View>
                                    <View>
                                        <Text style={styles.upTextFont}>粉丝</Text>
                                    </View>
                                </TouchableOpacity>
                            </View>



                            <View style={{ marginRight: 29 / zoomW }}>
                                <TouchableOpacity onPress={() => this.goHistroy()}>
                                    <View>
                                        <Text style={styles.upTextCount}>
                                            {this.state.userInfo.footprintNum}
                                        </Text>
                                    </View>
                                    <View>
                                        <Text style={styles.upTextFont}>历史</Text>
                                    </View>
                                </TouchableOpacity>
                            </View>
                        </View>
                        <View style={styles.bottomText}>
                            <View style={styles.privateLetter}>
                                <Text
                                    onPress={() => {
                                        this.props.navigation.navigate("EditProfile", {
                                            name: "EditProfile",
                                            userInfo: this.state.userInfo
                                        });
                                    }}
                                    style={{ textAlign: "center", fontSize: 14, color: "#000" }}
                                >
                                    编辑资料
                                </Text>
                            </View>
                            {/*this.state.userInfo.isAuthented &&*/}
                            { this.state.userInfo.isAuthented && this.state.approvedResult != "AGREED" &&  this.state.approvedResult != ""&&
                            <View style={[styles.attentionAlready,{backgroundColor: global.homeColor}]}>
                                <Text onPress={() => {this.relateMerchants();}}
                                      style={{ textAlign: "center", fontSize: 14, color: "#fff" }}>关联商家</Text>
                            </View> }
                        </View>

                        {(global.tenantId == '852769418315444224'||global.tenantId == '1038991752041734144')&&<TouchableOpacity style={{width:'100%',height:30/zoomW,alignItems:'flex-end'}} onPress={()=>{this.setState({
                            modalVisible:true
                        })}}>
                            <Image source={require('../../../img/quickmark_press.png')} style={{marginRight:20/zoomW,width:30/zoomW,height:30/zoomW}}/>
                        </TouchableOpacity>}
                    </View>
                </View>
                <View style={styles.abstract}>
                    <View style={{ flexDirection: "row" }}>
                        <Text style={{ fontSize: 14, color: "#000", opacity: 0.65 }}>
                            认证:
                        </Text>
                        {!!this.state.userInfo.isAuthented && (
              <Text style={{ fontSize: 14, color: "#000" }}>{identifyTypeNames}</Text>
                        )}
                        {!this.state.userInfo.isAuthented && (
                            <Text style={{ fontSize: 14, color: "#000" }}>未认证</Text>
                        )}
                    </View>
                    <View style={{marginTop: 8/zoomH, flexDirection: 'row',width:"80%"}}>
                        <Text style={{fontSize: 14, color: '#000', opacity: 0.65}}>简介:</Text>
                        { !!this.state.userInfo.description &&<Text numberOfLines={3} style={{fontSize: 14, color: '#000'}}>{this.state.userInfo.description}</Text>}
                        { !this.state.userInfo.description &&<Text style={{fontSize: 14, color: '#DDD'}}>还没有简介哦</Text>}
                    </View>
                </View>
                <View style={{ height: 8 / zoomH, backgroundColor: '#F3F5F6', marginTop: 20 / zoomH }} />
                <ScrollableTabView
                    renderTabBar={() => <DefaultTabBar style={styles.tabStyle} />}
                    tabBarActiveTextColor={global.homeColor}
                    tabBarUnderlineStyle={[styles.lineStyle,{backgroundColor: global.homeColor,marginLeft: !!this.state.userInfo.isAuthented   ?30/zoomW:46/zoomW}]}
                    tabBarInactiveTextColor="#000000"
                    tabBarBackgroundColor="#fff"
                    locked={false}
                    onScroll={(obj) => {
                    }}
                    onChangeTab={obj => {
                        let threadType = 0;
                        let needReSearch = true;
                        if (obj.i == 0) {
                            threadType = 0;
                            if (
                                this.state.textImageList != null &&
                                this.state.textImageList.length > 0
                            ) {
                                needReSearch = false;
                            }
                        } else if (obj.i == 1) {
                            threadType = 3;
                            if (
                                this.state.questionAnswerList != null &&
                                this.state.questionAnswerList.length > 0
                            ) {
                                needReSearch = false;
                            }
                        } else if (obj.i == 2) {
                            threadType = 2;
                            if (
                                this.state.videoList != null &&
                                this.state.videoList.length > 0
                            ) {
                                needReSearch = false;
                            }
                        }else  if (obj.i == 3) {
                            this.getGoodsList(0);
                            return
                        }

                        if (needReSearch) {
                            this.getFirstThreadList(threadType, 0,true);
                        }
                    }}
                >
                    <View tabLabel="图文">
                        {this.state.textImageList && this.state.textImageList.length >0 &&<FlatList
                            data={this.state.textImageList}
                            ItemSeparatorComponent={this._separator}
                            renderItem={this.renderImageTextItem.bind(this)}
                            onEndReachedThreshold={0.01}
                            onRefresh={() => this.getFirstThreadList(0,0,true)}
                            onEndReached={() => this.loadMore(0)}
                            ListFooterComponent={
                                this.state.textImageList.length > 0 && this.state.isImageAll
                                    ? this._footer
                                    : null
                            }
                            refreshing={this.state.refreshing}
                            keyExtractor={this.keyExtractor}
                        />}
                        {(!this.state.textImageList ||this.state.textImageList.length == 0) &&
                        <View style = {[styles.defaultStyle]}>
                            <Image  style = {{height:100/zoomH}}source={require('../../../img/empty.png')} resizeMode= 'contain'></Image>
                            <Text style = {{marginTop:10,color:'rgba(0,0,0,0.45)'}}>暂无图文帖子</Text>
                        </View>}
                    </View>
                    <View tabLabel="问答">
                        {this.state.questionAnswerList && this.state.questionAnswerList.length >0 &&<FlatList
                            data={this.state.questionAnswerList}
                            ItemSeparatorComponent={this._separator}
                            renderItem={this.renderQuestionItem.bind(this)}
                            onEndReachedThreshold={0.01}
                            onRefresh={() => this.getFirstThreadList(3,0,true)}
                            onEndReached={() => this.loadMore(3)}
                            ListFooterComponent={
                                this.state.questionAnswerList.length > 0 &&
                                this.state.isQuestionAll
                                    ? this._footer
                                    : null
                            }
                            refreshing={this.state.refreshing}
                            keyExtractor={this.keyExtractor}
                        />}
                        {(!this.state.questionAnswerList ||this.state.questionAnswerList.length == 0) &&
                        <View style = {[styles.defaultStyle]}>
                            <Image  style = {{height:100/zoomH}}source={require('../../../img/empty.png')} resizeMode= 'contain'></Image>
                            <Text style = {{marginTop:10,color:'rgba(0,0,0,0.45)'}}>暂无问答帖子</Text>
                        </View>}
                    </View>
                    <View tabLabel="视频">
                        {this.state.videoList && this.state.videoList.length >0 &&<FlatList
                            data={this.state.videoList}
                            ItemSeparatorComponent={this._separator}
                            renderItem={this.renderVideoItem.bind(this)}
                            onEndReachedThreshold={0.01}
                            onRefresh={() => this.getFirstThreadList(2,0,true)}
                            onEndReached={() => this.loadMore(2)}
                            ListFooterComponent={
                                this.state.videoList.length > 0 && this.state.isVideoAll
                                    ? this._footer
                                    : null
                            }
                            refreshing={this.state.refreshing}
                            keyExtractor={this.keyExtractor}
                        />}
                        {(!this.state.videoList || this.state.videoList.length == 0) &&
                        <View style = {[styles.defaultStyle]}>
                            <Image  style = {{height:100/zoomH}}source={require('../../../img/empty.png')} resizeMode= 'contain'></Image>
                            <Text style = {{marginTop:10,color:'rgba(0,0,0,0.45)'}}>暂无视频帖子</Text>
                        </View>
                        }
                    </View>
                    {!!this.state.userInfo.isAuthented  && <View tabLabel="商品">
                        {this.state.goodsList && this.state.goodsList.length >0 &&<FlatList
                            data={this.state.goodsList}
                            ItemSeparatorComponent={this._separator}
                            renderItem={this.renderGoodsItem.bind(this)}
                            onEndReachedThreshold={0.01}
                            onRefresh={() => {
                                _this.setState({
                                    goodList:[]
                                },function () {
                                    this.getGoodsList(0)
                                })

                            }}
                            onEndReached={() => {
                                if(_this.state.isGoodsAll){
                                    return;
                                }
                                _this.getGoodsList(this.state.goodList.length);
                            }}
                            ListFooterComponent={
                                this.state.goodsList.length > 0 && this.state.isGoodsAll
                                    ? this._footer
                                    : null
                            }
                            refreshing={this.state.refreshing}
                            keyExtractor={this.keyExtractor}
                        />}
                        {(!this.state.goodsList || this.state.goodsList.length == 0) &&
                        <View style = {[styles.defaultStyle]}>
                            <Image  style = {{height:100/zoomH}}source={require('../../../img/empty.png')} resizeMode= 'contain'></Image>
                            <Text style = {{marginTop:10,color:'rgba(0,0,0,0.45)'}}>暂无商品</Text>
                        </View>
                        }
                    </View> }
                </ScrollableTabView>
                <Modal
                    animationType="slide"
                    transparent={true}
                    visible={this.state.modalVisible}
                    onRequestClose={() => {
                    }}>
                    <View style={styles.modalBg} >
                        <View style={{width:width,height:height*0.9,marginTop:44/zoomH}}>
                            <ViewShot ref='viewShot' options={{ format: "jpg", quality: 0.5 }} style={{flex:1}}>
                                <Image source={!!!this.state.signUrl?require('../../../img/default_cover.jpg'):{uri:this.state.signUrl}} style={{width:width,height:width}} />
                                <View style={{flex:1,backgroundColor:'#fff',flexDirection:'row',padding:15}}>
                                    <View style={{flex:2,justifyContent:'space-around'}}>
                                        <Text>{this.state.signText}</Text>
                                        <View style={{flexDirection:'row',marginTop:15}}>
                                            <Image source={{uri:this.state.headPath}} style={{width:60/zoomW,height:60/zoomW,borderRadius:30/zoomW}}/>
                                            <View style={{marginLeft:10,flex:1}}>
                                                <Text style={{fontSize:20}}>{this.state.userName}</Text>
                                                <Text style={{color:'#d1d2d3'}}>我在芳聊,等您来</Text>
                                            </View>
                                        </View>
                                    </View>

                                    <View style={{flex:1,justifyContent:'space-around',alignItems:'center'}}>
                                        <Image source={{uri:this.state.codeUrl}} style={{width:100/zoomW,height:100/zoomW,marginBottom: 5}}/>
                                        <Text style={{flex:1}}>长按识别二维码</Text>
                                    </View>
                                </View>
                            </ViewShot>
                            {/*按钮区*/}
                            <View style={{width:width,height:height*0.1,backgroundColor:'#fff',flexDirection:'row',justifyContent:'space-around',alignItems:'center'}}>
                                <TouchableOpacity style={{width:70,height:height*0.1,alignItems:'center',justifyContent:'space-around'}} onPress={()=>{
                                    NoDoublePress.onPress(()=>{
                                        // TODO:因直接使用签到图片,发朋友就不需要截图了,可以提高速度
                                        // this.refs.viewShot.capture().then(uri => {
                                        //     console.log("do something with ", uri);
                                        //
                                        //     let fileName = uri.substring(uri.lastIndexOf('/') + 1);
                                        //     let _this = this;
                                        //     AppService.getAccess({name: fileName}).then((data) => {
                                        //
                                        //         if (data.message) {
                                        //
                                        //             return;
                                        //         }
                                        //         if (data.errors.length > 0) {
                                        //
                                        //         } else {
                                        //             NativeModules.system.simpleUpload(data.accessKeyId, data.accessKeySecret, data.securityToken,
                                        //                 data.info.endpoint, data.info.bucket, fileName, uri).then((res) => {

                                        let path = '/pages/community/member-detail/member-detail?id='+global.userId;//小程序的地址
                                        // path
                                        var temp = '';
                                        var webUrl = 'https://sns.xiniunet.com/wechatpage/dist/index.html#/center';
                                        webUrl = webUrl + '?path='+path;
                                        var wxOriginalID = '';
                                        if(global.appTarget == 'fangPartner'){
                                            // 芳聊小程序的原始ID
                                            wxOriginalID = 'gh_38cacc3e0a30';
                                        }
                                        // 这是测试App 300029承租人下的芳聊社区,用于debug芳聊测试环境的小程序
                                        if(global.appTarget == 'xntalkTest' || global.appTarget == 'fang'){
                                            wxOriginalID = 'gh_e1c3c68d4919';
                                            //wxOriginalID = 'wx878f29f4478f429d';
                                        }
                                        // 小程序卡片的图片固定是300X300的正方形
                                        var temp = !!!this.state.signUrl?defaultSingPicUrl:this.state.signUrl;
                                        // url = defaultSingPicUrl;
                                        var url = temp+'?x-oss-process=image/resize,m_fill,h_600,w_600/format,jpg';
                                        NativeModules.system.wchatShare(path,webUrl,this.state.userName,'' ,url,wxOriginalID);
                                        // var promise = CameraRoll.saveToCameraRoll(uri)
                                        // promise.then(function(result) {
                                        //
                                        // }).catch(function(error) {
                                        //
                                        // })
                                        //             }).catch((error) => {
                                        //
                                        //                 xnToast(error)
                                        //             })
                                        //         }
                                        //     }).catch((error) => {
                                        //
                                        //         xnToast(error)
                                        //     })
                                        //
                                        // })
                                    })
                                }}>
                                    <Image style={{width:52/zoomW,height:52/zoomW}} source={require('../../../img/sharewechat.png')}/>
                                    <Text style={{color:'#000'}}>发朋友</Text>

                                </TouchableOpacity>
                                <TouchableOpacity style={{width:70,height:height*0.1,alignItems:'center',justifyContent:'space-around'}} onPress={()=>{
                                    NoDoublePress.onPress(()=>{
                                        this.refs.viewShot.capture().then(uri => {
                                            console.log("do something with ", uri);
                                            var promise = CameraRoll.saveToCameraRoll(uri)
                                            promise.then(function(result) {
                                                // xnToast('保存成功,请至相册查看');
                                                Alert.alert('保存成功,请至相册查看')
                                            }).catch(function(error) {
                                                // xnToast('保存失败');
                                                Alert.alert('保存失败')
                                            })
                                        })
                                    })
                                }}>
                                    <Image style={{width:52/zoomW,height:52/zoomW}} source={require('../../../img/save.png')}/>
                                    <Text style={{color:'#000'}}>保存</Text>
                                </TouchableOpacity>
                                <TouchableOpacity style={{width:70,height:height*0.1,alignItems:'center',justifyContent:'space-around'}} onPress={()=>{
                                    NoDoublePress.onPress(()=>{
                                        this.setState({modalVisible:false})
                                    })
                                }}>
                                    <Image style={{width:52/zoomW,height:52/zoomW}} source={require('../../../img/cancel.png')}/>
                                    <Text style={{color:'#000'}}>取消</Text>
                                </TouchableOpacity>
                            </View>
                        </View>
                    </View>

                </Modal>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    background: {
        flex: 1,
        backgroundColor: "#ffffff",
        display: "flex"
    },
    mineInfo: {
        display: "flex",
        flexDirection: "row",
        marginTop: 20 / zoomH
    },
    mineInfoLeft: {
        marginLeft: 15 / zoomW
    },
    headImage: {
        height: 80 / zoomH,
        width: 80 / zoomW
        // backgroundColor: '#ccc',
    },
    mineInfoRight: {
        marginLeft: 20 / zoomW,
        flex: 1
    },
    upText: {
        display: "flex",
        flexDirection: "row",
        justifyContent: "space-between"
    },
    upTextCount: {
        textAlign: "center",
        color: "#000000",
        fontSize: 18
    },
    upTextFont: {
        fontSize: 12,
        color: "#000000",
        opacity: 0.45
    },
    bottomText: {
        display: "flex",
        flexDirection: "row",
        justifyContent: "space-between",
        marginTop: 14 / zoomH
    },
    privateLetter: {
        height: 28 / zoomH,
        width: "42%",
        borderColor: "#DDDDDD",
        borderWidth: 0.5,
        borderStyle: "solid",
        borderRadius: 4,
        justifyContent: "center"
    },
    attentionAlready: {
        width: "42%",
        marginRight: 29 / zoomW,
        height: 28 / zoomH,
        borderColor: "#DDDDDD",
        borderWidth: 1,
        borderStyle: "solid",
        borderRadius: 4,
        justifyContent: "center"
        // display: 'none'
    },
    abstract: {
    marginTop: 20 / zoomH,
        marginLeft: 20 / zoomW
    },
    tabStyle: {
        height: 36/zoomH,
        marginTop: 8/zoomH,
        // marginBottom: 17/zoomH,
        // width: '80%',
    },
    lineStyle: {
        width:36/zoomW,
        height: 3/zoomH,

    },
    headIcon: {
        display: "flex",
        flexDirection: "row",
        marginLeft: 15 / zoomW
    },

    goodsContainer: {
        display: "flex",
        flexDirection: "row",
        marginTop: 18 / zoomH,
        justifyContent: "space-between"
    },
    goodsDesc: {
        width: 190 / zoomW,
        height: 140 / zoomH,
        marginLeft: 12 / zoomW
    },
    itemLine: {
        height: 8 / zoomH,
        backgroundColor: "rgba(0,0,0,0.1)"
    },
    footerWrap: {
        borderStyle: "solid",
        borderColor: "#DDDDDD",
        borderTopWidth: 0.5,
        width: "100%",
        height: 52.5 / zoomH,
        flexDirection: "row",
        alignItems: "center",
        justifyContent: "center"
    },
    line: {
        width: 200 / zoomW,
        height: 1 / zoomH,
        backgroundColor: "#D0D0D0"
    },
    defaultStyle: {
        width:'100%',
        flexDirection: 'column',
        alignItems: 'center',
        justifyContent: 'center',
        marginTop:100/zoomH
    },
    modalBg: {
        width: width,
        height: height,
        backgroundColor: 'rgba(0,0,0,1)',
        display: 'flex',
        alignItems: 'center'
    },
    empty:{

    }
});