Personal.js 35.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
//个人信息
var Common = require('Common');
var Network = require('Network');
var TVFocus = require('TVFocus');
var FocusInfo = require('FocusInfo');
var TVCanvas = require('TVCanvas');
var TVScrollParameter = require('TVScrollParameter');
var ListView = require('ListView');

cc.Class({
    extends: TVCanvas,

    properties: {
        _iCurrentDressTypeIndex: 0,
        PFB_TYPE: {
            default: null,
            type: cc.Prefab
        },
    },

    onLoad: function () {
        this._super();

        this._oSceneContext.focusPath = "BackScene";

        //服饰分类框框
        this._nodeDressTypeListWrapper = cc.find("Dress/DecorateArea/DressTypeListGroup/DressTypeListWrapper", this.node);
        this._nodeDressTypeList = cc.find("DressTypeList", this._nodeDressTypeListWrapper);
        this._nodeDressTypeList.addComponent(TVScrollParameter);
        //右分类框框
        this._nodeCategoryList = cc.find("Dress/DecorateArea/CategoryList", this.node);
        this._nodeCategoryDataContainer = cc.find('DataContainerMask/DataContainer', this._nodeCategoryList);
        let lvCategoryList = this._nodeCategoryList.addComponent(ListView);
        lvCategoryList.init(this, 4, 0, 4, 2, 'PersonRoleInstallCategoryListCell',
            -60, 160,   //起始位置
            0, 10, 10, 0,  //margin
            1, 1,
            function () {
                this._bIsPersonRoleDataReady = true;
                this.getDefaultRoleRequest();
            }
        );
    },

    /**
     * 获取角色默认装扮
     */
    getDefaultRoleRequest: function () {
        var oGetDefaultRoleParas = {//获取角色的默认装扮
            "view": "json",
            "name": "roleAvatar",
            "start": "0",
            "limit": "5",
            "token": Common.TEST_API_TOKEN,
        }
        Network.ajax('GET', Common.TOPDRAW_API_SERVER + "Promotion/ListItemByName", null, oGetDefaultRoleParas,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        this._oRole = {};
                        this._oRole.aDefaultRole = [];
                        this._oRole.oInstallRoleParts = {};
                        if (oJSONResult.resultSet.length > 0) {
                            for (var i = 0; i < oJSONResult.resultSet.length; i++) {
                                var strSrc = '';
                                if (typeof (oJSONResult.resultSet[i].image) != 'undefined' && oJSONResult.resultSet[i].image[0].fileUrl != null) {
                                    strSrc = oJSONResult.resultSet[i].image[0].fileUrl;
                                }
                                var oTvlink = JSON.parse(oJSONResult.resultSet[i].tvlink);
                                var oCell = {};
                                oCell.group_id = oTvlink.group_id;
                                oCell.weight_ratio = oTvlink.weight_ratio;
                                oCell.image = strSrc;
                                this._oRole.aDefaultRole.push(oCell);
                            }
                            this.getRoleRequest();
                        }
                        cc.log("Success GET DefaultRole LIST...");
                    } else {
                        cc.log("Error GET DefaultRole LIST..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception GET DefaultRole LIST..." + error);
                }
            },
            function (strResponse) {
                cc.log("Communication Error : Get DefaultRole List Information..." + strResponse + "\r\n");
            }, this, "uuid"
        );
    },

    /**
    * 获取角色名及已经上装的部分
    */
    getRoleRequest: function () {
        var oRoleParas = {//获取角色的默认装扮
            "view": "json",
            "token": Common.TEST_API_TOKEN,
        }
        Network.ajax('GET', Common.TOPDRAW_API_SERVER2 + "Character/GetUserCharacter", null, oRoleParas,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        this._oRole.aInstallRole = [];
                        var oResult = oJSONResult.resultSet[0].userCharacter;
                        for (var i = 0; i < oResult.length; i++) {
                            var fileURL = '';
                            if (typeof (oResult[i].images) != 'undefined' && oResult[i].images.map.normal != null) {
                                var index = oResult[i].images.map.normal[0];
                                fileURL = oResult[i].images.list[index].fileUrl;
                            }
                            oResult[i].images = {};
                            oResult[i].images['fileUrl'] = fileURL;//默认规定小图
                            oResult[i].image = fileURL;//大图
                            this._oRole.aInstallRole.push(oResult[i]);
                        }
                        cc.find('Dress/DecorateArea/PersonGroup/NickName/Text', this.node).getComponent(cc.Label).string
                            = oJSONResult.resultSet[0].nick_name.nick_name;
                        this.getRoleCatRequest();
                        cc.log("Success GET Role LIST...");
                    } else {
                        cc.log("Error GET Role LIST..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception GET Role LIST..." + error);
                }
            },
            function (strResponse) {
                cc.log("Communication Error : Get Role List Information..." + strResponse + "\r\n");
            }, this, "uuid"
        );
    },

    /**
     * 获取角色装扮的类型
     */
    getRoleCatRequest: function () {
        var oRoleCatParas = {//获取角色装扮的类型
            "view": "json",
            'start': 0,
            'limit': 20,
            'token': Common.TEST_API_TOKEN,
        }
        Network.ajax('GET', Common.TOPDRAW_API_SERVER2 + "Character/GetAllDressGroup", null, oRoleCatParas,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        var aProgram = oJSONResult.resultSet[0].dressGroup;
                        var aType = oJSONResult.resultSet[0].dressType;
                        // this._oRole.aRoleCat = [];
                        for (var g = 0; g < aType.length; g++) {
                            this._oRole.oInstallRoleParts[aType[g].group_id] = {};
                            this._oRole.oInstallRoleParts[aType[g].group_id].weight_ratio = aType[g].weight_ratio;
                            this._oRole.oInstallRoleParts[aType[g].group_id].group_id = aType[g].group_id;
                            this._oRole.oInstallRoleParts[aType[g].group_id].name = aType[g].name;
                            this._oRole.oInstallRoleParts[aType[g].group_id].image = '';
                            this._oRole.oInstallRoleParts[aType[g].group_id].dress_object_id = -1;
                        }
                        for (var i = 0; i < aProgram.length; i++) {//搞DressTypeList
                            var fileURL = '', width = '', height = '';
                            // if (typeof (aProgram[i].images) != 'undefined' && aProgram[i].images.map.thumbnail != null) {
                            //     var index = aProgram[i].images.map.thumbnail[0];
                            //     fileURL = aProgram[i].images.list[index].fileUrl;
                            //     width = aProgram[i].images.list[index].width;
                            //     height = aProgram[i].images.list[index].height / 2;
                            // }
                            //EPG数据没有thumbnail字段
                            if (typeof (aProgram[i].images) != 'undefined' && aProgram[i].images.map.normal != null) {
                                var index = aProgram[i].images.map.normal[0];
                                fileURL = aProgram[i].images.list[index].fileUrl;
                                width = aProgram[i].images.list[index].width;
                                height = aProgram[i].images.list[index].height / 2;
                            }
                            aProgram[i].images = {};
                            aProgram[i].images['fileUrl'] = fileURL;
                            aProgram[i].width = width;
                            aProgram[i].height = height;
                            aProgram[i].image = fileURL;

                            //恢复上下文带过来的位置
                            // if (this._oSceneContext.requestedDressTypeId && this._oSceneContext.requestedDressTypeId == oJSONResult.resultSet[i].group_id) {
                            //     this._iCurrentDressTypeIndex = i;
                            // }
                            this._oSceneContext.requestedDressGroupId = aProgram[0].group_id;//默认选中第一个group_id
                            let nodeDressTypeListCell = cc.find("DressTypeListCell" + i, this._nodeDressTypeList);
                            if (nodeDressTypeListCell) return;  //注意:TypeList菜单切换会重复生成节点,
                            nodeDressTypeListCell = cc.instantiate(this.PFB_TYPE);
                            nodeDressTypeListCell.width = width;
                            nodeDressTypeListCell.height = height;
                            nodeDressTypeListCell.y = -nodeDressTypeListCell.height / 2 - i * (nodeDressTypeListCell.height + 5) - 10;
                            let nodePic = cc.find('Bg', nodeDressTypeListCell);
                            if (fileURL) {
                                Network.loadImageInNativeRuntime(
                                    Common.TOPDRAW_IMAGE_SERVER + fileURL,
                                    function (texture) {
                                        nodePic.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, width, height));
                                    }, null, this
                                );
                            }
                            this._nodeDressTypeList.addChild(nodeDressTypeListCell, 10, "DressTypeListCell" + i);
                            //准备焦点坐标
                            let fiTypeBlock = nodeDressTypeListCell.addComponent(FocusInfo);
                            fiTypeBlock.init(
                                '',
                                true, null, null, 1.15
                            );
                            this._aFocusTargets[0]['dress_type_list_cell_' + i] = nodeDressTypeListCell;
                        }
                        this._oRole.aRoleCat = [];
                        this._oRole.aRoleCat = aProgram;
                        this.wear2Role();
                        this.requestRolePartsList();
                        cc.log("Success GET DRESSTYPE LIST...");
                    } else {
                        cc.log("Error GET DRESSTYPE LIST..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception GET DRESSTYPE LIST..." + error);
                }
            },
            function (strResponse) {
                cc.log("Communication Error : Get DRESSTYPE List Information..." + strResponse + "\r\n");
            }, this, "uuid"
        );
    },

    /**
     * 上装
     */
    wear2Role: function () {
        for (let i = 0; i < this._oRole.aInstallRole.length; i++) { //搞新装扮
            let iInstallRoleGroupId = this._oRole.aInstallRole[i].group_id;
            if (!cc.find("Dress/DecorateArea/wear_role"+ iInstallRoleGroupId,this.node)) {  //避免重复生成
                let nodeRole = new cc.Node('wear_role' + iInstallRoleGroupId);
                nodeRole.addComponent(cc.Sprite);
                nodeRole.width = 227;
                nodeRole.height = 299;
                let widgetDecoration = nodeRole.addComponent(cc.Widget);
                // widgetDecoration.target=cc.find('DecorateArea',this.node);
                widgetDecoration.isAlignLeft = true;
                widgetDecoration.isAlignTop = true;
                widgetDecoration.top = 103;
                widgetDecoration.left = 90;//固定角色位置
                if (this._oRole.aInstallRole[i].image) {
                    Network.loadImageInNativeRuntime(
                        Common.TOPDRAW_IMAGE_SERVER + this._oRole.aInstallRole[i].image,
                        function (texture) {
                            nodeRole.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                        }, null, this
                    );
                }
                cc.find("Dress/DecorateArea",this.node).addChild(nodeRole, this._oRole.aInstallRole[i].weight_ratio);    //每件衣服权值不同
            }
        }

        for (let i = 0; i < this._oRole.aDefaultRole.length; i++) { //搞默认装扮
            var flag = true;
            let iInstallRoleGroupId = -1;
            let iDefaultRoleGroupId = this._oRole.aDefaultRole[i].group_id;
            for (let j = 0; j < this._oRole.aInstallRole.length; j++) {
                iInstallRoleGroupId = this._oRole.aInstallRole[j].group_id;
                if (iInstallRoleGroupId == iDefaultRoleGroupId) {
                    flag = false;
                }
            }
            if (!flag) continue;   //表示搞了新衣服,不需要穿旧的了
            if (!cc.find("Dress/DecorateArea/wear_role"+ iDefaultRoleGroupId,this.node)) {  //避免重复生成
                let nodeRole = new cc.Node('wear_role' + iDefaultRoleGroupId);
                nodeRole.addComponent(cc.Sprite);
                nodeRole.width = 227;
                nodeRole.height = 299;
                let widgetDecoration = nodeRole.addComponent(cc.Widget);
                // widgetDecoration.target=cc.find('DecorateArea',this.node);
                widgetDecoration.isAlignLeft = true;
                widgetDecoration.isAlignTop = true;
                widgetDecoration.top = 103;
                widgetDecoration.left = 90;//固定角色位置
                if (this._oRole.aDefaultRole[i].image) {
                    Network.loadImageInNativeRuntime(
                        Common.TOPDRAW_IMAGE_SERVER + this._oRole.aDefaultRole[i].image,
                        function (texture) {
                            nodeRole.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                        }, null, this
                    );
                }
                cc.find("Dress/DecorateArea",this.node).addChild(nodeRole, this._oRole.aDefaultRole[i].weight_ratio);    //每件衣服权值不同
            }
        }
    },

    /**
     * 根据分组获取角色配件
     */
    requestRolePartsList: function () {
        let lvCategoryList = this._nodeCategoryList.getComponent(ListView);
        let oCategoryRequestParameters = {
            "view": "json",
            "groupId": this._oSceneContext.requestedDressGroupId,
            // "start":3,
            // "limit":9,
            "token": Common.TEST_API_TOKEN,
        };
        let iStart1 = 0;
        // if (null != this._oSceneContext.categoryRecordIndexOfFirstCell) {
        //     iStart1 = this._oSceneContext.categoryRecordIndexOfFirstCell;
        // }

        // lvCategoryList.setDataSource(
        //     "GET",
        //     Common.TOPDRAW_API_SERVER2 + "Character/GetUserDressObjectByGroup",
        //     oCategoryRequestParameters,
        //     iStart1, (lvCategoryList.getShowCellRows() + lvCategoryList.getAlphaCellRows()) * lvCategoryList.getCellCountEachRow(),
        //     "sequence", "asc"
        // );
        //EPG参数不能携带其他参数,拿不到数据
        lvCategoryList.setDataSource(
            "GET",
            Common.TOPDRAW_API_SERVER2 + "Character/GetUserDressObjectByGroup",
            oCategoryRequestParameters,
            iStart1, (lvCategoryList.getShowCellRows() + lvCategoryList.getAlphaCellRows()) * lvCategoryList.getCellCountEachRow(),
            "", ""
        );

        // var strResponse = BusinessParameter.CARTOON_SPECIAL_CATEGORY;

        lvCategoryList.loadData(
            function (strResponse) {
                // cc.log("网络列表:"+strResponse);
                this._oRole.aRoleParts = [];
                var oJSONResult = JSON.parse(strResponse);
                if (oJSONResult.businessCode == 'success') {
                    this._oRole.aRoleParts = oJSONResult.resultSet;
                }
                lvCategoryList.renderInitData(strResponse);
                this._bIsCategoryListDataInit = true;
                // this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPage();
                this.checkDataReadyAndInitFocus();
            },
            null,
            this
        );
    },

    /**
     * 穿上/卸下衣服
     */
    changeRoleParts: function () {
        let index = this._fiCurrentFocus.node.name.replace("RoleInstallListCell", '');
        if (this._oRole.aRoleParts[index] && !this._oRole.aRoleParts[index].in_use) { //安装
            this.onInstallRolePartsRequest(index);
        } else {  //卸下
            this.onUnInstallRolePartsRequest(index);
        }
    },

    /**
     * 穿上衣服
     */
    onInstallRolePartsRequest: function (index) {
        var currentRoleInstallIndex = index;
        let dress_object_id = this._oRole.aRoleParts[currentRoleInstallIndex].dress_object_id;
        var oInstallRolePartsParas = {//获取角色的默认装扮
            "view": "json",
            'groupId': this._oSceneContext.requestedDressGroupId,
            'newDressObjectId': dress_object_id,
            'oldDressObjectId': (this._oRole.oInstallRoleParts[this._oSceneContext.requestedDressGroupId].dress_object_id != -1) ? this._oRole.oInstallRoleParts[this._oSceneContext.requestedDressGroupId].dress_object_id : '',
            "token": Common.TEST_API_TOKEN,
        }
        Network.ajax('GET', Common.TOPDRAW_API_SERVER2 + "Character/ArrangeDresssObject", null, oInstallRolePartsParas,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        cc.log("装上新装扮成功");
                        this._oRole.aRoleParts[currentRoleInstallIndex].in_use = 1;
                        this._fiCurrentFocus.node.getChildByName('InstallIcon').opacity = 255;
                        cc.find('Explain/Text', this._fiCurrentFocus.node).getComponent(cc.Label).string = "按【确定】卸载";
                        this.wearRolePartsOne(currentRoleInstallIndex);
                    } else {
                        cc.log("Error GET TYPE LIST..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception GET TYPE LIST..." + error);
                }
            },
            function (strResponse) {
                cc.log("Communication Error : Get Type List Information..." + strResponse + "\r\n");
            }, this, "uuid"
        );
    },

    /**
     * 卸下衣服
     */
    onUnInstallRolePartsRequest: function (index) {
        var currentRoleInstallIndex = index;
        let dress_object_id = this._oRole.aRoleParts[currentRoleInstallIndex].dress_object_id;
        var oInstallRolePartsParas = {//获取角色的默认装扮
            "view": "json",
            'groupId': this._oSceneContext.requestedDressGroupId,
            'dressObjectId': dress_object_id,
            "token": Common.TEST_API_TOKEN,
        }
        Network.ajax('GET', Common.TOPDRAW_API_SERVER2 + "Character/DemountDressObject", null, oInstallRolePartsParas,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        cc.log("卸下旧装扮成功");
                        this._oRole.aRoleParts[currentRoleInstallIndex].in_use = 0;
                        this._fiCurrentFocus.node.getChildByName('InstallIcon').opacity = 0;
                        cc.find('Explain/Text', this._fiCurrentFocus.node).getComponent(cc.Label).string = "按【确定】使用";
                        this.wearRolePartsOne();
                    } else {
                        cc.log("Error GET TYPE LIST..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception GET TYPE LIST..." + error);
                }
            },
            function (strResponse) {
                cc.log("Communication Error : Get Type List Information..." + strResponse + "\r\n");
            }, this, "uuid"
        );
    },

    wearRolePartsOne: function (currentRoleInstallIndex) {
        let weight_ratio = '';
        var fileURL = '';
        if (currentRoleInstallIndex) {    //穿上
            weight_ratio = this._oRole.aRoleParts[currentRoleInstallIndex].weight_ratio;
            if (typeof (this._oRole.aRoleParts[currentRoleInstallIndex].images) != 'undefined' && this._oRole.aRoleParts[currentRoleInstallIndex].images.map.normal != null) {
                var index = this._oRole.aRoleParts[currentRoleInstallIndex].images.map.normal[0];
                fileURL = this._oRole.aRoleParts[currentRoleInstallIndex].images.list[index].fileUrl;
            }
        } else {  //卸下
            for (var i = 0; i < this._oRole.aDefaultRole.length; i++) {
                if (this._oRole.aDefaultRole[i].group_id == this._oSceneContext.requestedDressGroupId) {
                    fileURL = this._oRole.aDefaultRole[i].image;
                    weight_ratio = this._oRole.aDefaultRole[i].weight_ratio;
                }
            }
        }

        let nodeRole =cc.find("Dress/DecorateArea/wear_role"+ this._oSceneContext.requestedDressGroupId,this.node);
        if (nodeRole) {
            nodeRole.zIndex = weight_ratio;
            //如果默认装扮没有该类衣服就置空
            fileURL == '' ? nodeRole.getComponent(cc.Sprite).spriteFrame = null : cc.loader.load(Common.TOPDRAW_IMAGE_SERVER + fileURL, function (err, texture) {
                nodeRole.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
            });
        } else {
            let nodeNewRole = new cc.Node('wear_role' + this._oSceneContext.requestedDressGroupId);
            nodeNewRole.addComponent(cc.Sprite);
            nodeNewRole.width = 227;
            nodeNewRole.height = 299;
            let widgetDecoration = nodeNewRole.addComponent(cc.Widget);
            // widgetDecoration.target=cc.find('DecorateArea',this.node);
            widgetDecoration.isAlignLeft = true;
            widgetDecoration.isAlignTop = true;
            widgetDecoration.top = 103;
            widgetDecoration.left = 173;//固定角色位置
            Network.loadImageInNativeRuntime(
                Common.TOPDRAW_IMAGE_SERVER + fileURL,
                function (texture) {
                    nodeNewRole.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                }, null, this
            );
            cc.find("Dress/DecorateArea",this.node).addChild(nodeNewRole, weight_ratio);    //每件衣服权值不同
        }
    },


    checkDataReadyAndInitFocus: function () {
        if (!this._bIsFocusInit) {
            this.scheduleOnce(() => {           //指定0让回调函数在下一帧立即执行
                this.initFocus();
            }, 0);
            this._bIsFocusInit = true;
        }
    },

    initFocus: function () {

        var nodeBackScene = cc.find("BackScene", this.node);
        var fiBackScene = nodeBackScene.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_back_scene'] = nodeBackScene;
        fiBackScene.init(
            null, true
        );

        var nodeInfoButton = cc.find("InfoButton", this.node);
        var fiInfo = nodeInfoButton.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_info_scene'] = nodeInfoButton;
        fiInfo.init(
            null, true
        );

        var nodeDressButton = cc.find("DressButton", this.node);
        var fiDress = nodeDressButton.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_dress_scene'] = nodeDressButton;
        fiDress.init(
            null, true
        );

        if (this._bIsBackStatus) {
            // this._bIsBackStatus = false;
            this.getAchievement();
        }
        var nodeInitFocus = cc.find(this._oSceneContext.focusPath, this.node);
        // var nodeInitFocus = cc.find(this._oSceneContext.focusPath, this.node);
        var nodeFocus = new cc.Node('nodeFocus');
        this.node.addChild(nodeFocus, 10);
        this._cFocus = this.node.getChildByName('nodeFocus').addComponent(TVFocus);
        this._cFocus.init('focusContainer', this,
            nodeInitFocus.getComponent(FocusInfo),
            Common.SCREEN_WIDTH, Common.SCREEN_HEIGHT, 0, 0, 1.0);

        this._cFocus.flyFocus(this._fiCurrentFocus, nodeInitFocus.getComponent(FocusInfo), Common.MOVE_DIRECTION_UP, null, null);//矫正焦点
    },

    keyDownDirection: function (Direct) {
        var fiFocusTarget = null;
        var fiCurrentFocus = this._fiCurrentFocus;
        var oScrollParameter = null;
        let aCheckResult;
        fiFocusTarget = this._cFocus.findTarget(fiCurrentFocus, this._aFocusTargets, 0, Direct);
        if (!fiFocusTarget) { return; }
        aCheckResult = this.checkFocusTarget(fiFocusTarget);
        fiFocusTarget = aCheckResult[0];
        oScrollParameter = aCheckResult[1];
        this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Direct, null, oScrollParameter);
    },

    checkFocusTarget: function (fiFocusTarget, oScrollParameter) {
        if (this._bCardAreaTip || this._bAchievementAraTip) fiFocusTarget = null;      //当名片弹窗显示时禁止跳转
        if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("LeftTypeListCell")) {
            if (0 != this._fiCurrentFocus.node.name.indexOf("LeftTypeListCell")) {
                // cc.log("即将跳往:"+this._iCurrentTypeIndex);
                fiFocusTarget = cc.find("LeftTypeListCell" + this._oSceneContext._iCurrentTypeIndex, this._nodeTypeList).getComponent(FocusInfo);
            } else {

            }
        }
        if (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("DressTypeListCell")) {
            if (0 != this._fiCurrentFocus.node.name.indexOf("DressTypeListCell")) {
                // cc.log("即将跳往:"+this._iCurrentTypeIndex);
                fiFocusTarget = cc.find("DressTypeListCell" + this._iCurrentDressTypeIndex, this._nodeDressTypeList).getComponent(FocusInfo);
            }
        }
        return [fiFocusTarget, oScrollParameter];
    },

    onKeyDown: function (event) {
        this._super(event);
        //TODO:给ListView传值,使其可以让滑块跟随滚动
        // let lvCategoryList = this._nodeAchievementCategoryList.getComponent(PersonalListView);
        // if (lvCategoryList) {
        //     lvCategoryList.setCurrentFocus(this._fiCurrentFocus);
        // }

        switch (event.keyCode) {
            case cc.macro.KEY.up:
            case Common.ANDROID_KEY.up:
                if (this._bCardAreaTip || this._bAchievementAraTip) return;      //当名片弹窗显示时禁止跳转
                if (this._bIsCategoryItemMoving || this._bIsSongListMoving) {
                    return;
                }
                this.keyDownDirection(Common.MOVE_DIRECTION_UP);
                break;
            case cc.macro.KEY.right:
            case Common.ANDROID_KEY.right:
                this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT);
                break;
            case cc.macro.KEY.down:
            case Common.ANDROID_KEY.down:
                if (this._bCardAreaTip || this._bAchievementAraTip) return;      //当名片弹窗显示时禁止跳转
                if (this._bIsCategoryItemMoving || this._bIsSongListMoving) {
                    return;
                }
                this.keyDownDirection(Common.MOVE_DIRECTION_DOWN);
                break;
            case cc.macro.KEY.left:
            case Common.ANDROID_KEY.left:
                this.keyDownDirection(Common.MOVE_DIRECTION_LEFT);
                break;
            case cc.macro.KEY.enter:
            case cc.macro.KEY.space:
            case Common.ANDROID_KEY.enter:
                // this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
                if (0 == this._fiCurrentFocus.node.name.indexOf("RoleInstallListCell")) {   //换衣服
                    this.changeRoleParts();
                }else if(0 == this._fiCurrentFocus.node.name.indexOf("InfoButton")){
                    cc.find("Info",this.node).active=true;
                    cc.find("Dress",this.node).active=false;
                }else if(0 == this._fiCurrentFocus.node.name.indexOf("DressButton")){
                    cc.find("Info",this.node).active=false;
                    cc.find("Dress",this.node).active=true;
                }
                break;
            case cc.macro.KEY.backspace:
            case Common.ANDROID_KEY.back:
                this.backAScene();
                break;
        }

        //记录CategoryList滚动位置
        // if (lvCategoryList) {
        //     this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPage();
        // }
    },

    onBeforeFocusChange: function (event) {
        this._super(event);
        let fiFrom = event.detail.from;
        let fiTo = event.detail.to;
        if (0 == fiFrom.node.getName().indexOf('LeftTypeListCell')) {
            if (0 == fiTo.node.getName().indexOf('LeftTypeListCell')) {
                let index = fiFrom.node.name.replace("LeftTypeListCell", '');
                let width = this._aTypeList[index].image[0].width;
                let height = this._aTypeList[index].image[0].height / 2;
                Network.loadImageInNativeRuntime(
                    Common.TOPDRAW_IMAGE_SERVER + this._aTypeList[index].image[0].fileUrl,
                    function (texture) {
                        fiFrom.node.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, width, height));
                    }, null, this
                );
            }
        }
        if (0 == fiFrom.node.getName().indexOf('DressTypeListCell')) {
            if (0 == fiTo.node.getName().indexOf('DressTypeListCell')) {
                let index = fiFrom.node.name.replace("DressTypeListCell", '');
                let width = this._oRole.aRoleCat[index].width;
                let height = this._oRole.aRoleCat[index].height;
                Network.loadImageInNativeRuntime(
                    Common.TOPDRAW_IMAGE_SERVER + this._oRole.aRoleCat[index].image,
                    function (texture) {
                        fiFrom.node.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, width, height));
                    }, null, this
                );
            }
        }
        if (0 == fiFrom.node.getName().indexOf('RoleInstallListCell')) {
            let index = fiFrom.node.name.replace("RoleInstallListCell", '');
            fiFrom.node.getChildByName('Explain').opacity = 0;
        }
        if (0 == fiFrom.node.getName().indexOf('AchievementListCell')) {
            cc.loader.loadRes('texture/ui/small_achieve_common', cc.SpriteFrame, function (err, spriteFrame) {
                fiFrom.node.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
        }
        if (0 == fiFrom.node.getName().indexOf('DressButton') || 0 == fiFrom.node.getName().indexOf('InfoButton')) {
            fiFrom.node.getChildByName('select').opacity = 0;
        }
    },

    onAfterFocusChange: function (event) {
        this._super(event);
        let fiFrom = event.detail.from;
        let fiTo = event.detail.to;
        if (0 == fiTo.node.getName().indexOf('LeftTypeListCell')) {
            let index = parseInt(fiTo.node.name.replace("LeftTypeListCell", ''));
            this._oSceneContext._iCurrentTypeIndex = index;
            this.updateNavContent();
            let width = this._aTypeList[index].image[0].width;
            let height = this._aTypeList[index].image[0].height / 2;
            Network.loadImageInNativeRuntime(
                Common.TOPDRAW_IMAGE_SERVER + this._aTypeList[index].image[0].fileUrl,
                function (texture) {
                    fiTo.node.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, height, width, height));
                }, null, this
            );
        }
        if (0 == fiTo.node.getName().indexOf('DressTypeListCell')) {
            let index = fiTo.node.name.replace("DressTypeListCell", '');
            this._iCurrentDressTypeIndex = index;
            this._oSceneContext.requestedDressGroupId = this._oRole.aRoleCat[index].group_id;
            let width = this._oRole.aRoleCat[index].width;
            let height = this._oRole.aRoleCat[index].height;
            Network.loadImageInNativeRuntime(
                Common.TOPDRAW_IMAGE_SERVER + this._oRole.aRoleCat[index].image,
                function (texture) {
                    fiTo.node.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, height, width, height));
                }, null, this
            );
            // this.scheduleOnce(this.requestRolePartsList, 1); //使用延迟会有些小问题,快速跳转到TypeList时requestedDressGroupId参数就重新初始化了
            this.requestRolePartsList();//也会有小问题,DressTypeList之间快速跳转ListView列表由于网络请求可能会有些错乱,权衡再三先这样吧
        }
        if (0 == fiTo.node.getName().indexOf('RoleInstallListCell')) {
            let index = fiTo.node.name.replace("RoleInstallListCell", '');
            fiTo.node.getChildByName('Explain').opacity = 255;
        }
        if (0 == fiTo.node.getName().indexOf('AchievementListCell')) {
            cc.loader.loadRes('texture/ui/small_achieve_red', cc.SpriteFrame, function (err, spriteFrame) {
                fiTo.node.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
        }
        if (0 == fiTo.node.getName().indexOf('DressButton') || 0 == fiTo.node.getName().indexOf('InfoButton')) {
            fiTo.node.getChildByName('select').opacity = 255;
        }
    },

    doCurrentFocusTVLinkAction: function (strAction) {
        let strTVLink = this._fiCurrentFocus.getTVLink();
        try {
            let oTVLink = JSON.parse(strTVLink);
            let aOperationList = oTVLink.click;
            for (let i = 0; i < aOperationList.length; i++) {
                switch (aOperationList[i].action) {
                    default:
                        this.doTVLinkAction(aOperationList[i]);
                        break;
                }
            }
        } catch (error) {
            cc.log("runTVLinkAction Exception..." + error);
        }
    },

    onListScrollStart: function () {
        this._bIsSongListMoving = true;
        cc.log("scroll start");
    },
    onListScrollEnd: function () {
        this._bIsSongListMoving = false;
        cc.log("scroll completed");
    },

    onDestroy: function () {
        cc.director.emit('stop_render');   //分发事件
    },

});