Mall.js 51.7 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
//商城
var Common = require('Common');
var Network = require('Network');
var TVFocus = require('TVFocus');
var FocusInfo = require('FocusInfo');
var TVCanvas = require('TVCanvas');

cc.Class({
    extends: TVCanvas,

    properties: {
        _strWallPaperBg: '',
        _strOtherItemBg: '',
        _iItemTypeId: 1,  //商品类型 1墙纸,2装饰,3角色装扮
        _iItemDetailTypeId: 0,  //0 小屋 1墙上 2地上 3功能 0装扮
        _iCurrentPage: 0,    //当前页
        _iCountPage: 0,
        _aTabType: [],
        _iCurrentTypeIndex: 0,
        _bWallPaperFirstInit: false, //墙纸商品第一次初始化
        _aWallPaperList: [],
        _aProductList: [],
        _bCheckBuyBox: false,
        _iProductIndex: -1,
        _oProductRequestPara: {
            default: null,
        },
        PFB_TYPE: {
            default: null,
            type: cc.Prefab
        },
        PFB_WALLPAPER: {
            default: null,
            type: cc.Prefab
        },
        PFB_PRODUCT: {
            default: null,
            type: cc.Prefab
        },
    },

    onLoad() {
        this._super();

        this._oSceneContext = {
            requestedTypeId: null,
            categoryRecordIndexOfFirstCell: 0,
            nodeTypeListX: 0,
            focusPath: "CategoryList/DataContainerMask/DataContainer/EnglishListCell0"
        };
        this._oProductRequestPara = {
            "view": "json",
            "itemTypeId": this._iItemTypeId ? this._iItemTypeId : 0,
            "itemDetailTypeId": this._iItemDetailTypeId ? this._iItemDetailTypeId : 0,
            "start": 0,
            "limit": 2,
            "token": Common.TEST_API_TOKEN
        };

        cc.find("MallWindow/ArrowLeftIcon", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 26, 50));
        cc.find("MallWindow/ArrowRightIcon", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 26, 50));
        cc.find("CheckBuyBox/YesIcon", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 152, 59));
        cc.find("CheckBuyBox/NoIcon", this.node).getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 152, 59));

        //Tab分类框框
        this._nodeTypeListWrapper = cc.find("TypeListGroup/TypeListWrapper", this.node);
        this._nodeTypeList = cc.find("TypeList", this._nodeTypeListWrapper);
        //墙纸分类框框
        this._nodeWallPaperListWrapper = cc.find("MallWindow/WallPaperListGroup/WallPaperListWrapper", this.node);
        this._nodeWallPaperList = cc.find("WallPaperList", this._nodeWallPaperListWrapper);
        //商品分类框框
        this._nodeProductListWrapper = cc.find("MallWindow/ProductListGroup/ProductListWrapper", this.node);
        this._nodeProductList = cc.find("ProductList", this._nodeProductListWrapper);

        this.initPrefab();
        this.getPageBg(this, "background");
        this.addHomeIcon(this);
        this.getUserBean();
        this.getMallBgRequest();
        this.getTabRequest();
    },

    initPrefab: function () {
        for (let i = 0; i < 2; i++) {
            let nodeWallPaperListCell = cc.instantiate(this.PFB_WALLPAPER);
            nodeWallPaperListCell.x = nodeWallPaperListCell.width / 2 + i * (nodeWallPaperListCell.width + 100);
            this._nodeWallPaperList.addChild(nodeWallPaperListCell, 10, 'WallPaperListCell' + i);
            //准备焦点坐标
            let nodeWallPaperBean = cc.find('BeanBg', nodeWallPaperListCell);
            cc.loader.loadRes('game/mall/item_price_bg', cc.SpriteFrame, function (error, spriteFrame) {
                spriteFrame.setTexture(null, new cc.rect(0, 0, 148, 56));
                nodeWallPaperBean.getComponent(cc.Sprite).spriteFrame.setRect(cc.rect(0, 0, 148, 56));
                spriteFrame._calculateUV();
            });
            let fiBeanBlock = nodeWallPaperBean.addComponent(FocusInfo);
            fiBeanBlock.init(
                '', true, null, null, 1.0
            );
            this._aFocusTargets[0]['bean_list_cell_' + i] = nodeWallPaperBean;
        }
        for (let i = 0; i < 8; i++) {
            let nodeProductListCell = cc.instantiate(this.PFB_PRODUCT);
            if (i <= 3) {
                nodeProductListCell.x = nodeProductListCell.width / 2 + i * (nodeProductListCell.width + 55);
                nodeProductListCell.y = -nodeProductListCell.height / 2
            } else {
                nodeProductListCell.x = nodeProductListCell.width / 2 + (i - 4) * (nodeProductListCell.width + 55);
                nodeProductListCell.y = -nodeProductListCell.height / 2 - nodeProductListCell.height - 5;
            }
            this._nodeProductList.addChild(nodeProductListCell, 10, 'ProductListCell' + i);
            //准备焦点坐标
            let nodeProductBean = cc.find('BeanBg', nodeProductListCell);
            cc.loader.loadRes('game/mall/item_price_bg', cc.SpriteFrame, function (error, spriteFrame) {
                spriteFrame.setTexture(null, new cc.rect(0, 0, 148, 56));
                nodeProductBean.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                spriteFrame._calculateUV();
            });
            let fiBeanBlock = nodeProductBean.addComponent(FocusInfo);
            fiBeanBlock.init(
                '', true, null, null, 1.0
            );
            this._aFocusTargets[0]['product_bean_list_cell_' + i] = nodeProductBean;
        }
        cc.find('MallWindow/ProductListGroup', this.node).active = false;//先将其他商品列表隐藏掉
    },

    //获取我的金豆
    getUserBean: function () {
        let oMyBeanRequestParameter = {
            "view": "json",
            "token": Common.TEST_API_TOKEN
        };
        Network.ajax("GET", Common.TOPDRAW_API_SERVER2 + "Mall/GetUserBean", null, oMyBeanRequestParameter,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        var beans = parseInt(oJSONResult.resultSet[0].gold_bean);
                        if (beans > 10000) {
                            beans = parseInt(beans / 1000) / 10;
                            beans = beans + "万";
                        }
                        cc.find('MyBean/Text', this.node).getComponent(cc.Label).string = beans;
                        // this.checkDataReadyAndInitFocus();
                    } else {
                        cc.log("Error When Get GatherDetail..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception When Get GatherDetail..." + error);
                }
            },
            function (error) {
                cc.log("Error When Get GatherDetail..." + error);
            }, this, "uuid");
    },

    //获取货架背景及角色形象
    getMallBgRequest: function () {
        let oMallBgRequestPara = {
            "view": "json",
            "start": 0,
            "limit": 3,
            "dictionaryCode": "MALL_BG_ITEM",
            "token": Common.TEST_API_TOKEN
        };
        Network.ajax("GET", Common.TOPDRAW_API_SERVER + "Dictionary/ListItem", null, oMallBgRequestPara,
            function (strResponse) {
                try {
                    var self = this;
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        for (let i = 0; i < oJSONResult.resultSet.length; i++) {
                            if ("characterModel" == oJSONResult.resultSet[i].key) {   //小孩角色
                                Network.loadImageInNativeRuntime(
                                    Common.TOPDRAW_IMAGE_SERVER + oJSONResult.resultSet[i].image[0].fileUrl,
                                    function (texture) {
                                        cc.find('MallWindow/CharacterModelIcon', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                    }, null, this
                                );
                            } else if ("otherItemBackground" == oJSONResult.resultSet[i].key) {//其他商品货架
                                this._strOtherItemBg = oJSONResult.resultSet[i].image[0].fileUrl;
                            } else if ("wallPaperBackground" == oJSONResult.resultSet[i].key) {//墙纸货架
                                this._strWallPaperBg = oJSONResult.resultSet[i].image[0].fileUrl;
                            }
                        }
                        if (1 == this._iItemTypeId) {   //墙纸
                            Network.loadImageInNativeRuntime(
                                Common.TOPDRAW_IMAGE_SERVER + this._strWallPaperBg,
                                function (texture) {
                                    cc.find('MallWindow/Bg', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                }, null, this
                            );
                        } else {
                            Network.loadImageInNativeRuntime(
                                Common.TOPDRAW_IMAGE_SERVER + this._strOtherItemBg,
                                function (texture) {
                                    cc.find('MallWindow/Bg', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                }, null, this
                            );
                        }
                        // this.checkDataReadyAndInitFocus();
                    } else {
                        cc.log("Error When Get GatherDetail..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception When Get GatherDetail..." + error);
                }
            },
            function (error) {
                cc.log("Error When Get GatherDetail..." + error);
            }, this, "uuid");
    },

    //获取tab推荐位
    getTabRequest: function () {
        let oPromotionTabRequestPara = {
            "view": "json",
            "name": "mallTab",
            "start": 0,
            "limit": 5,
            "sortField": "left",
            "sortDirection": "asc",
            "token": Common.TEST_API_TOKEN
        };
        Network.ajax("GET", Common.TOPDRAW_API_SERVER + "Promotion/ListItemByName", null, oPromotionTabRequestPara,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        if (oJSONResult.resultSet.length > 0) {
                            this._aTabType = [];
                            let count = oJSONResult.resultSet.length;
                            for (var i = 0; i < oJSONResult.resultSet.length; i++) {
                                this._aTabType.push(oJSONResult.resultSet[i]);
                                //恢复上下文带过来的位置
                                // if (this._oSceneContext.requestedTypeId && this._oSceneContext.requestedTypeId == oJSONResult.resultSet[i].id) {
                                //     this._iCurrentTypeIndex = i;
                                // }
                                let width = oJSONResult.resultSet[i].width;
                                let height = oJSONResult.resultSet[i].height;
                                let nodeTypeListCell = cc.instantiate(this.PFB_TYPE);
                                nodeTypeListCell.width = width;
                                nodeTypeListCell.height = height;
                                nodeTypeListCell.x = nodeTypeListCell.width / 2 + i * (nodeTypeListCell.width + 5);
                                if (oJSONResult.resultSet[i].image[0]) {
                                    Network.loadImageInNativeRuntime(
                                        Common.TOPDRAW_IMAGE_SERVER + oJSONResult.resultSet[i].image[0].fileUrl,
                                        function (texture) {
                                            count--;
                                            nodeTypeListCell.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, width, height));

                                            if (!count) {
                                                this._bIsTabInit = true;
                                                this.checkDataReadyAndInitFocus();
                                            }
                                        }, null, this
                                    );
                                }
                                this._nodeTypeList.addChild(nodeTypeListCell, 10, "TypeListCell" + i);
                                //准备焦点坐标
                                let fiTypeBlock = nodeTypeListCell.addComponent(FocusInfo);
                                fiTypeBlock.init(
                                    '',
                                    true, null, null, 1.15
                                );
                                this._aFocusTargets[0]['type_list_cell_' + i] = nodeTypeListCell;
                            }
                            this._oSceneContext.requestedTypeId = this._aTabType[this._iCurrentTypeIndex].id;
                            this.getProductRequest();
                        }
                    } else {
                        cc.log("Error When Get GatherDetail..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception When Get GatherDetail..." + error);
                }
            },
            function (error) {
                cc.log("Error When Get GatherDetail..." + error);
            }, this, "uuid");
    },

    //获取商品
    getProductRequest: function () {
        Network.ajax("GET", Common.TOPDRAW_API_SERVER2 + "Mall/GetProductsByTypes", null, this._oProductRequestPara,
            function (strResponse) {
                try {
                    var self = this;
                    var oJSONResult = JSON.parse(strResponse);
                    if (oJSONResult.businessCode == 'success') {
                        if (1 == this._iItemTypeId) {   //墙纸
                            cc.find('MallWindow/WallPaperListGroup', this.node).active = true;//
                            cc.find('MallWindow/ProductListGroup', this.node).active = false;//
                            this._iCountPage = Math.ceil(oJSONResult.count / 2);
                            Network.loadImageInNativeRuntime(
                                Common.TOPDRAW_IMAGE_SERVER + this._strWallPaperBg,
                                function (texture) {
                                    cc.find('MallWindow/Bg', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                }, null, this
                            );
                            var oResult = oJSONResult.resultSet[0].products;
                            this._aWallPaperList = [];
                            for (let i = 0; i < oResult.length; i++) {
                                this._aWallPaperList.push(oResult[i]);
                                let nodeWallPaperListCell = cc.find('WallPaperListCell' + i, this._nodeWallPaperList);
                                nodeWallPaperListCell.active = true;
                                if (!nodeWallPaperListCell) return;
                                // cc.log("获取名称"+oResult[i].name);
                                cc.find('Name/ActiveName/NameContainer/NameText/NameText1', nodeWallPaperListCell).getComponent(cc.Label).string = oResult[i].name;
                                cc.find('Name/ActiveName/NameContainer/NameText/NameText2', nodeWallPaperListCell).getComponent(cc.Label).string = oResult[i].name;
                                cc.find('Name/NormalName/MidName', nodeWallPaperListCell).getComponent(cc.Label).string = oResult[i].name;
                                cc.find('PicAd/Text', nodeWallPaperListCell).getComponent(cc.Label).string = oResult[i].advertise;
                                cc.find('BeanBg/Text', nodeWallPaperListCell).getComponent(cc.Label).string = oResult[i].bean_price;
                                cc.find('IsSell', nodeWallPaperListCell).getComponent(cc.Label).string = oResult[i].is_sell;
                                let normal = oResult[i].images.map.normal[0];
                                Network.loadImageInNativeRuntime(
                                    Common.TOPDRAW_IMAGE_SERVER + oResult[i].images.list[normal].fileUrl,
                                    function (texture) {
                                        cc.find('Pic', nodeWallPaperListCell).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                    }, null, this
                                );
                                if (oResult[i].is_sell == "1") {    //已购买
                                    cc.loader.loadRes('game/mall/has_bought', cc.Texture2D, function (err, texture) {
                                        nodeWallPaperListCell.getChildByName('BeanBg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                        cc.find('BeanBg/Text', nodeWallPaperListCell).opacity = 0;
                                    });
                                } else {
                                    cc.loader.loadRes('game/mall/item_price_bg', cc.SpriteFrame, function (error, spriteFrame) {
                                        spriteFrame.setTexture(null, new cc.rect(0, 0, 148, 56));
                                        nodeWallPaperListCell.getChildByName('BeanBg').getComponent(cc.Sprite).spriteFrame = spriteFrame;
                                        cc.find('BeanBg/Text', nodeWallPaperListCell).opacity = 255;
                                    });
                                }
                            }
                            for (let i = oResult.length; i < 2; i++) {  //没有赋值到的预制搞掉它
                                let nodeWallPaperListCell = cc.find('WallPaperListCell' + i, this._nodeWallPaperList);
                                nodeWallPaperListCell.active = false;
                            }
                            //弄翻页
                            let compPageNum = cc.find('MallWindow/PagerNumText', this.node).getComponent(cc.Label);
                            this._iCountPage == 0 ? compPageNum.string = "1/1" : compPageNum.string = ((this._iCurrentPage + 1) + "/" + this._iCountPage);
                            if (!this._bWallPaperFirstInit) { //第一次弄下,
                                this._bWallPaperFirstInit = true;
                                if (this._iCountPage > 1) {
                                    cc.loader.loadRes('game/mall/arrow_right', cc.Texture2D, function (err, texture) {
                                        cc.find('MallWindow/ArrowRightIcon', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 50, 26, 50));
                                    });
                                }
                            }
                        }
                        else {  //其他商品
                            cc.find('MallWindow/WallPaperListGroup', this.node).active = false;//
                            cc.find('MallWindow/ProductListGroup', this.node).active = true;//
                            this._iCountPage = Math.ceil(oJSONResult.count / 8);
                            Network.loadImageInNativeRuntime(
                                Common.TOPDRAW_IMAGE_SERVER + this._strOtherItemBg,
                                function (texture) {
                                    cc.find('MallWindow/Bg', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                }, null, this
                            );
                            var oResult = oJSONResult.resultSet[0].products;
                            this._aProductList = [];
                            for (let i = 0; i < oResult.length; i++) {
                                this._aProductList.push(oResult[i]);
                                let nodeProductListCell = cc.find('ProductListCell' + i, this._nodeProductList);
                                nodeProductListCell.active = true;
                                if (!nodeProductListCell) return;
                                // cc.log("获取名称"+oResult[i].name);
                                cc.find('Name/ActiveName/NameContainer/NameText/NameText1', nodeProductListCell).getComponent(cc.Label).string = oResult[i].name;
                                cc.find('Name/ActiveName/NameContainer/NameText/NameText2', nodeProductListCell).getComponent(cc.Label).string = oResult[i].name;
                                cc.find('Name/NormalName/MidName', nodeProductListCell).getComponent(cc.Label).string = oResult[i].name;
                                // cc.find('Name', nodeProductListCell).getComponent(cc.Label).string = oResult[i].name;
                                cc.find('PicAd/Text', nodeProductListCell).getComponent(cc.Label).string = oResult[i].advertise;
                                cc.find('BeanBg/Text', nodeProductListCell).getComponent(cc.Label).string = oResult[i].real_bean_price;
                                cc.find('IsSell', nodeProductListCell).getComponent(cc.Label).string = oResult[i].is_sell;
                                let thumbnail = oResult[i].images.map.thumbnail[0];
                                Network.loadImageInNativeRuntime(
                                    Common.TOPDRAW_IMAGE_SERVER + oResult[i].images.list[thumbnail].fileUrl,
                                    function (texture) {
                                        cc.find('Pic', nodeProductListCell).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                    }, null, this
                                );
                                if (oResult[i].is_sell == "1") {    //已购买
                                    cc.loader.loadRes('game/mall/has_bought', cc.Texture2D, function (err, texture) {
                                        nodeProductListCell.getChildByName('BeanBg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
                                        cc.find('BeanBg/Text', nodeProductListCell).opacity = 0;
                                    });
                                } else {
                                    cc.loader.loadRes('game/mall/item_price_bg', cc.SpriteFrame, function (error, spriteFrame) {
                                        spriteFrame.setTexture(null, new cc.rect(0, 0, 148, 56));
                                        nodeProductListCell.getChildByName('BeanBg').getComponent(cc.Sprite).spriteFrame = spriteFrame;
                                        cc.find('BeanBg/Text', nodeProductListCell).opacity = 255;
                                    });
                                }
                            }
                            for (let i = oResult.length; i < 8; i++) {  //没有赋值到的预制搞掉它
                                let nodeProductListCell = cc.find('ProductListCell' + i, this._nodeProductList);
                                nodeProductListCell.active = false;
                            }
                            //弄翻页
                            let compPageNum = cc.find('MallWindow/PagerNumText', this.node).getComponent(cc.Label);
                            this._iCountPage == 0 ? compPageNum.string = "1/1" : compPageNum.string = ((this._iCurrentPage + 1) + "/" + this._iCountPage);
                        }
                    } else {
                        cc.log("Error When Get GatherDetail..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception When Get GatherDetail..." + error);
                }
            },
            function (error) {
                cc.log("Error When Get GatherDetail..." + error);
            }, this, "uuid");
    },

    getProductList: function (type) {
        var self = this;
        if ("XIAOWU" == type) {
            this._iItemTypeId = 1;
            this._iItemDetailTypeId = 0;
            this._iCurrentPage = 0;
            this._oProductRequestPara.itemTypeId = this._iItemTypeId;
            this._oProductRequestPara.itemDetailTypeId = this._iItemDetailTypeId;
            this._oProductRequestPara.start = 0;
            this._oProductRequestPara.limit = 2;
        } else if ("right" == type) {
            if (this._iCountPage == this._iCurrentPage + 1) { return }
            this._iCurrentPage++;
            this._oProductRequestPara.start = this._oProductRequestPara.limit * this._iCurrentPage;
            let fiFocusTarget = null;
            this._iItemTypeId == 1 ? fiFocusTarget = this._nodeWallPaperList.getChildByName('WallPaperListCell0').getChildByName('BeanBg').getComponent(FocusInfo) :
                fiFocusTarget = this._nodeProductList.getChildByName('ProductListCell0').getChildByName('BeanBg').getComponent(FocusInfo);
            setTimeout(function () {    //使用下一帧执行有缺陷
                this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_RIGHT, null, null);
            }.bind(this), 300);
        } else if ("left" == type) {
            if (0 == this._iCurrentPage) { return }
            this._iCurrentPage--;
            this._oProductRequestPara.start = this._oProductRequestPara.limit * this._iCurrentPage;
            let fiFocusTarget = null;
            this._iItemTypeId == 1 ? fiFocusTarget = this._nodeWallPaperList.getChildByName('WallPaperListCell1').getChildByName('BeanBg').getComponent(FocusInfo) :
                fiFocusTarget = this._nodeProductList.getChildByName('ProductListCell7').getChildByName('BeanBg').getComponent(FocusInfo);
            setTimeout(function () {
                this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_LEFT, null, null);
            }.bind(this), 300);
        } else if ("enterRight" == type) {
            if (this._iCountPage == this._iCurrentPage + 1) { return }
            this._iCurrentPage++;
            this._oProductRequestPara.start = this._oProductRequestPara.limit * this._iCurrentPage;
        } else if ("enterLeft" == type) {
            if (0 == this._iCurrentPage) { return }
            this._iCurrentPage--;
            this._oProductRequestPara.start = this._oProductRequestPara.limit * this._iCurrentPage;
        } else if ("QIANGSHANG" == type) {
            this._iItemTypeId = 2;
            this._iItemDetailTypeId = 1;
            this._iCurrentPage = 0;
            this._oProductRequestPara.itemTypeId = this._iItemTypeId;
            this._oProductRequestPara.itemDetailTypeId = this._iItemDetailTypeId;
            this._oProductRequestPara.start = 0;
            this._oProductRequestPara.limit = 8;
        } else if ("DISHANG" == type) {
            this._iItemTypeId = 2;
            this._iItemDetailTypeId = 2;
            this._iCurrentPage = 0;
            this._oProductRequestPara.itemTypeId = this._iItemTypeId;
            this._oProductRequestPara.itemDetailTypeId = this._iItemDetailTypeId;
            this._oProductRequestPara.start = 0;
            this._oProductRequestPara.limit = 8;
        } else if ("GONGNENG" == type) {
            this._iItemTypeId = 2;
            this._iItemDetailTypeId = 3;
            this._iCurrentPage = 0;
            this._oProductRequestPara.itemTypeId = this._iItemTypeId;
            this._oProductRequestPara.itemDetailTypeId = this._iItemDetailTypeId;
            this._oProductRequestPara.start = 0;
            this._oProductRequestPara.limit = 8;
        } else if ("ZHUANGBAN" == type) {
            this._iItemTypeId = 3;
            this._iItemDetailTypeId = 0;
            this._iCurrentPage = 0;
            this._oProductRequestPara.itemTypeId = this._iItemTypeId;
            this._oProductRequestPara.itemDetailTypeId = this._iItemDetailTypeId;
            this._oProductRequestPara.start = 0;
            this._oProductRequestPara.limit = 8;
        }
        this.getProductRequest();
        //翻页
        let compPageNum = cc.find('MallWindow/PagerNumText', this.node).getComponent(cc.Label);
        this._iCountPage == 0 ? compPageNum.string = "1/1" : compPageNum.string = ((this._iCurrentPage + 1) + "/" + this._iCountPage);
        if ((this._iCurrentPage + 1) > 1) {
            cc.loader.loadRes('game/mall/arrow_left', cc.Texture2D, function (err, texture) {
                cc.find('MallWindow/ArrowLeftIcon', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 50, 26, 50));
            });
        } else {
            cc.loader.loadRes('game/mall/arrow_left', cc.Texture2D, function (err, texture) {
                cc.find('MallWindow/ArrowLeftIcon', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 50, 26, 50));
            });
        }
        if (this._iCountPage != 0 && this._iCountPage != (this._iCurrentPage + 1)) {
            cc.loader.loadRes('game/mall/arrow_right', cc.Texture2D, function (err, texture) {
                cc.find('MallWindow/ArrowRightIcon', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 50, 26, 50));
            });
        } else {
            cc.loader.loadRes('game/mall/arrow_right', cc.Texture2D, function (err, texture) {
                cc.find('MallWindow/ArrowRightIcon', self.node).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 50, 26, 50));
            });
        }
    },

    /**
     * 购买商品
     */
    onBuyProduct: function () {
        var productIds = '';
        if (this._iItemTypeId == 1) {
            productIds = this._aWallPaperList[this._iProductIndex].product_id;
        } else {
            productIds = this._aProductList[this._iProductIndex].product_id;
        }
        let oBuyProductPara = {
            "view": "json",
            "productIds": productIds,
            "token": Common.TEST_API_TOKEN
        };
        Network.ajax("GET", Common.TOPDRAW_API_SERVER2 + "Mall/BuyProducts", null, oBuyProductPara,
            function (strResponse) {
                try {
                    var oJSONResult = JSON.parse(strResponse);
                    this._bCheckBuyBox = false;
                    cc.find('CheckBuyBox', this.node).active = false;
                    let fiFocusTarget = null;
                    var value = 0;    //购买商品的价格
                    var name = '';    //购买商品的名称
                    var nodeBeanBg = null;
                    if (this._iItemTypeId == 1) {
                        nodeBeanBg = cc.find('WallPaperListCell' + this._iProductIndex + "/BeanBg", this._nodeWallPaperList);
                        value = this._aWallPaperList[this._iProductIndex].real_bean_price;
                        name = this._aWallPaperList[this._iProductIndex].name;
                    } else {
                        nodeBeanBg = cc.find('ProductListCell' + this._iProductIndex + "/BeanBg", this._nodeProductList);
                        value = this._aProductList[this._iProductIndex].real_bean_price;
                        name = this._aProductList[this._iProductIndex].name;
                    }
                    fiFocusTarget = nodeBeanBg.getComponent(FocusInfo);  //处理焦点跳回去
                    this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_LEFT, null, null); //不管有没有购买成功,都要将购买弹窗消掉
                    if (oJSONResult.businessCode == 'success') {
                        nodeBeanBg.parent.getChildByName('IsSell').getComponent(cc.Label).string = "1";    //修改状态
                        cc.loader.loadRes('game/mall/has_bought', cc.SpriteFrame, function (err, spriteFrame) { //变成已购买
                            nodeBeanBg.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                            cc.find('Text', nodeBeanBg).opacity = 0;
                        });
                        var myBeans = cc.find('MyBean/Text', this.node).getComponent(cc.Label).string;    //处理我的金豆
                        if (myBeans.indexOf("万") > -1) {
                            myBeans = parseFloat(myBeans) * 10000;
                            myBeans = myBeans - value;
                            if (myBeans > 9999) {
                                myBeans = myBeans / 10000 + "万";
                            }
                            cc.find('MyBean/Text', this.node).getComponent(cc.Label).string = myBeans;
                        } else {
                            myBeans = parseInt(myBeans);
                            cc.find('MyBean/Text', this.node).getComponent(cc.Label).string = myBeans - value;
                        }
                        //显示5秒的购买成功弹窗
                        this.childTip("<color=#23699A>购买成功<br/>恭喜获得" + name + "</color>");
                    } else {    //购买失败
                        if (0 == oJSONResult.description.indexOf("金豆不足")) {
                            this.childTip("<color=#23699A>购买失败<br/>您的金豆不足</color>");
                        } else if (0 == oJSONResult.description.indexOf("售空")) {
                            this.childTip("<color=#23699A>购买失败<br/>您所购买的物品已售空</color>");
                        } else if (0 == oJSONResult.description.indexOf("下架")) {
                            this.childTip("<color=#23699A>购买失败<br/>您所购买的物品已下架</color>");
                        }
                        cc.log("Error When Get GatherDetail..." + oJSONResult.description);
                    }
                } catch (error) {
                    cc.log("Exception When Get GatherDetail..." + error);
                }
            },
            function (error) {
                cc.log("Error When Get GatherDetail..." + error);
            }, this, "uuid");
    },

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

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

        //弄翻页图标
        var nodeLeftArrow = cc.find("MallWindow/ArrowLeftIcon", this.node);
        var fiLeft = nodeLeftArrow.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_left'] = nodeLeftArrow;
        fiLeft.init(
            null, true
        );
        var nodeRightArrow = cc.find("MallWindow/ArrowRightIcon", this.node);
        var fiRight = nodeRightArrow.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_right'] = nodeRightArrow;
        fiRight.init(
            null, true
        );

        //搞购买弹窗
        var nodeYesIcon = cc.find("CheckBuyBox/YesIcon", this.node);
        var fiYesIcon = nodeYesIcon.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_yes'] = nodeYesIcon;
        fiYesIcon.init(
            null, false
        );
        var nodeNoIcon = cc.find("CheckBuyBox/NoIcon", this.node);
        var fiNoIcon = nodeNoIcon.addComponent(FocusInfo);
        this._aFocusTargets[0]['to_no'] = nodeNoIcon;
        fiNoIcon.init(
            null, false
        );

        var nodeInitFocus = cc.find("TypeListCell0", this._nodeTypeList);
        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);
        // cc.log("nodeInitFocus的name:"+nodeInitFocus.name);
        if (0 == nodeInitFocus.name.indexOf('TypeListCell')) {
            let index = nodeInitFocus.name.replace("TypeListCell", '');    //显示收藏框框
            let height = this._aTabType[index].height;
            let width = this._aTabType[index].width;
            if (this._aTabType[index].image[0]) {
                Network.loadImageInNativeRuntime(
                    Common.TOPDRAW_IMAGE_SERVER + this._aTabType[index].image[0].fileUrl,
                    function (texture) {
                        nodeInitFocus.getChildByName('Bg').getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, height, width, height));
                    }, null, this
                );
            }
        }
    },

    keyDownDirection: function (Direct) {
        var fiFocusTarget = null;
        var fiCurrentFocus = this._fiCurrentFocus;
        var oScrollParameter = null;
        //var fScaleFactor=1.0;
        let nodeFrom = null;
        let nodeTo = null;
        let aCheckResult;
        fiFocusTarget = this._cFocus.findTarget(fiCurrentFocus, this._aFocusTargets, 0, Direct);
        if (!fiFocusTarget) { return; }
        if (this._bCheckBuyBox) { //购买弹窗弹出,只能选确定或取消
            if (fiFocusTarget != cc.find("CheckBuyBox/YesIcon", this.node).getComponent(FocusInfo) && fiFocusTarget != cc.find("CheckBuyBox/NoIcon", this.node).getComponent(FocusInfo)) {
                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 (fiFocusTarget && 0 == fiFocusTarget.node.name.indexOf("TypeListCell")) {
            if (0 != this._fiCurrentFocus.node.name.indexOf("TypeListCell")) {//如果不是TypeList之间跳转,则哪里来回哪里去
                fiFocusTarget = cc.find("TypeListCell" + this._iCurrentTypeIndex, this._nodeTypeList).getComponent(FocusInfo);
            }
        }
        return [fiFocusTarget, oScrollParameter];
    },

    onKeyDown: function (event) {
        this._super(event);
        switch (event.keyCode) {
            case cc.macro.KEY.up:
            case Common.ANDROID_KEY.up:
                this.keyDownDirection(Common.MOVE_DIRECTION_UP);
                break;
            case cc.macro.KEY.right:
            case Common.ANDROID_KEY.right:
                if (0 == this._fiCurrentFocus.node.parent.getName().indexOf('WallPaperListCell1')
                    || 0 == this._fiCurrentFocus.node.parent.getName().indexOf('ProductListCell7')) {
                    this.getProductList('right');
                    return;
                }
                this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT);
                break;
            case cc.macro.KEY.down:
            case Common.ANDROID_KEY.down:
                this.keyDownDirection(Common.MOVE_DIRECTION_DOWN);
                break;
            case cc.macro.KEY.left:
            case Common.ANDROID_KEY.left:
                if (0 == this._fiCurrentFocus.node.parent.getName().indexOf('WallPaperListCell0') ||
                    0 == this._fiCurrentFocus.node.parent.getName().indexOf('ProductListCell0')) {
                    this.getProductList('left');
                    return;
                }
                this.keyDownDirection(Common.MOVE_DIRECTION_LEFT);
                break;
            case cc.macro.KEY.enter:
            case cc.macro.KEY.space:
            case Common.ANDROID_KEY.enter:
                if (0 == this._fiCurrentFocus.node.getName().indexOf('ArrowLeftIcon')) {
                    this.getProductList('enterLeft');
                    return;
                } else if (0 == this._fiCurrentFocus.node.getName().indexOf('ArrowRightIcon')) {
                    this.getProductList('enterRight');
                    return;
                } else if (0 == this._fiCurrentFocus.node.parent.getName().indexOf('WallPaperListCell')) {
                    let iSell = this._fiCurrentFocus.node.parent.getChildByName('IsSell').getComponent(cc.Label).string;
                    this._iProductIndex = this._fiCurrentFocus.node.parent.name.replace("WallPaperListCell", '');
                    let text = cc.find('CheckBuyBox/RichText', this.node).getComponent(cc.RichText);
                    let beanNum = cc.find('BeanBg/Text', this._fiCurrentFocus.node.parent).getComponent(cc.Label).string;
                    let name = cc.find('Name/NormalName/MidName', this._fiCurrentFocus.node.parent).getComponent(cc.Label).string;
                    if (iSell != "1") {
                        this._bCheckBuyBox = true;
                        cc.find('CheckBuyBox', this.node).active = true;
                        text.string = "<color=#23699A>你确定花" + beanNum + "金豆<br/>购买" + name + "吗?</color>"
                        let fiFocusTarget = this.node.getChildByName('CheckBuyBox').getChildByName('YesIcon').getComponent(FocusInfo);
                        this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_LEFT, null, null);
                    }
                } else if (0 == this._fiCurrentFocus.node.parent.getName().indexOf('ProductListCell')) {
                    let iSell = this._fiCurrentFocus.node.parent.getChildByName('IsSell').getComponent(cc.Label).string;
                    this._iProductIndex = this._fiCurrentFocus.node.parent.name.replace("ProductListCell", '');
                    let text = cc.find('CheckBuyBox/RichText', this.node).getComponent(cc.RichText);
                    let beanNum = cc.find('BeanBg/Text', this._fiCurrentFocus.node.parent).getComponent(cc.Label).string;
                    let name = cc.find('Name/NormalName/MidName', this._fiCurrentFocus.node.parent).getComponent(cc.Label).string;
                    if (iSell != "1") {
                        this._bCheckBuyBox = true;
                        cc.find('CheckBuyBox', this.node).active = true;
                        text.string = "<color=#23699A>你确定花" + beanNum + "金豆<br/>购买" + name + "吗?</color>"
                        let fiFocusTarget = this.node.getChildByName('CheckBuyBox').getChildByName('YesIcon').getComponent(FocusInfo);
                        this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_LEFT, null, null);
                    }
                } else if (0 == this._fiCurrentFocus.node.getName().indexOf('NoIcon')) {
                    if (this._bCheckBuyBox) {
                        this._bCheckBuyBox = false;
                        cc.find('CheckBuyBox', this.node).active = false;
                        let fiFocusTarget = null;
                        if (this._iItemTypeId == 1) {
                            fiFocusTarget = cc.find('WallPaperListCell' + this._iProductIndex + "/BeanBg", this._nodeWallPaperList).getComponent(FocusInfo);
                        } else {
                            fiFocusTarget = cc.find('ProductListCell' + this._iProductIndex + "/BeanBg", this._nodeProductList).getComponent(FocusInfo);
                        }
                        this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_LEFT, null, null);
                    }
                } else if (0 == this._fiCurrentFocus.node.getName().indexOf('YesIcon')) {
                    if (this._bCheckBuyBox) {
                        this.onBuyProduct();
                    }
                }else if (0 == this._fiCurrentFocus.node.getName().indexOf('LeftAppIcon')) {
                    this.backAScene();
                    return;
                } 
                // this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
                break;
            case cc.macro.KEY.backspace:
            case Common.ANDROID_KEY.back:
                this.backAScene();
                break;
        }
    },

    //显示规定时间的弹窗
    childTip: function (strTip, iTime) {
        if (!this.commonTipFnCallback) {
            this.commonTipFnCallback = function () {
                nodeTip.active = false;
            }
        }
        this.unschedule(this.commonTipFnCallback);
        if (!strTip) return;
        iTime = iTime || 3;
        let nodeTip = cc.find("CheckAfterBuyBox", this.node);
        let labelText = nodeTip && nodeTip.getChildByName("RichText").getComponent(cc.RichText);
        labelText.string = strTip;
        nodeTip.active = true;
        nodeTip.zIndex = 100;//权值高于焦点
        this.scheduleOnce(this.commonTipFnCallback, iTime); //修改tip时间
    },

    onBeforeFocusChange: function (event) {
        this._super(event);
        let fiFrom = event.detail.from;
        let fiTo = event.detail.to;
        if (0 == fiFrom.node.getName().indexOf('TypeListCell')) {
            if (0 == fiTo.node.getName().indexOf('TypeListCell')) {
                let index = fiFrom.node.name.replace("TypeListCell", '');    //显示收藏框框
                let height = this._aTabType[index].height;
                let width = this._aTabType[index].width;
                if (this._aTabType[index].image[0]) {
                    Network.loadImageInNativeRuntime(
                        Common.TOPDRAW_IMAGE_SERVER + this._aTabType[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("BeanBg")) {
            if (fiFrom.node.parent.getChildByName('IsSell').getComponent(cc.Label).string != 1) {    //未购买的才改变背景
                cc.loader.loadRes('game/mall/item_price_bg', cc.Texture2D, function (error, texture) {
                    fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 148, 56));
                });
            }
            cc.find('PicAd', fiFrom.node.parent).opacity = 0;
            let nodeCellName = fiFrom.node.parent.getChildByName('Name');
            cc.find("NormalName", nodeCellName).opacity = 255;
            //如有滚动停止滚动
            let nodeScreenTitleText = cc.find('ActiveName/NameContainer/NameText', nodeCellName);
            if (null != nodeScreenTitleText.getActionByTag(Common.OVERLENGTH_MOVING)) {
                nodeScreenTitleText.stopActionByTag(Common.OVERLENGTH_MOVING);
                nodeScreenTitleText.getChildByName('NameText2').active = false;
                cc.find("ActiveName/NameContainer", nodeCellName).opacity = 0;
            }
            nodeScreenTitleText.x = 0;
        }
        if (0 == fiFrom.node.getName().indexOf('YesIcon')) {
            cc.loader.loadRes('game/mall/checkBox_yes', cc.Texture2D, function (err, texture) {
                fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 152, 59));
            });
        }
        if (0 == fiFrom.node.getName().indexOf('NoIcon')) {
            cc.loader.loadRes('game/mall/checkBox_no', cc.Texture2D, function (err, texture) {
                fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 152, 59));
            });
        }
    },

    onAfterFocusChange: function (event) {
        this._super(event);
        let fiFrom = event.detail.from;
        let fiTo = event.detail.to;

        if (0 == fiTo.node.getName().indexOf('TypeListCell')) {
            let index = fiTo.node.name.replace("TypeListCell", '');    //显示收藏框框
            this._iCurrentTypeIndex = index;
            let height = this._aTabType[index].height;
            let width = this._aTabType[index].width;
            if (this._aTabType[index].image[0]) {
                Network.loadImageInNativeRuntime(
                    Common.TOPDRAW_IMAGE_SERVER + this._aTabType[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
                );
            }

            var tvlink = this._aTabType[index].tvlink;
            eval("this." + tvlink);
        }

        if (0 == fiTo.node.getName().indexOf('BeanBg')) {
            if (fiTo.node.parent.getChildByName('IsSell').getComponent(cc.Label).string != 1) {    //未购买的才改变背景
                cc.loader.loadRes('game/mall/item_price_bg', cc.Texture2D, function (error, texture) {
                    fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 56, 148, 56));
                });
            }
            cc.find('PicAd/Text', fiTo.node.parent).getComponent(cc.Label).string != "" ? cc.find('PicAd', fiTo.node.parent).opacity = 255 : '';
            let nodeCellName = fiTo.node.parent.getChildByName('Name');
            cc.find("NormalName", nodeCellName).opacity = 255;
            //超出滚动
            let nodeScreenTitleText = cc.find('ActiveName/NameContainer/NameText', nodeCellName);

            let fOriginalX = nodeScreenTitleText.x;
            let fOriginalY = nodeScreenTitleText.y;

            let nodeScreenTitleText1 = nodeScreenTitleText.getChildByName('NameText1');
            let nodeScreenTitleText2 = nodeScreenTitleText.getChildByName('NameText2');
            nodeScreenTitleText2.x = nodeScreenTitleText1.x + nodeScreenTitleText1.width + 10;//TODO:补丁,解决滚动重叠
            if (nodeScreenTitleText1.width > nodeScreenTitleText.width) {
                cc.find("ActiveName/NameContainer", nodeCellName).opacity = 255;
                cc.find("NormalName", nodeCellName).opacity = 0;
                let fEndPositionDelta = (nodeScreenTitleText1.width + 30);
                //下方时长和字有关系,才能速度一样
                var ftaScreenTitleMoveToTarget = cc.moveTo(10 * (nodeScreenTitleText1.width / nodeScreenTitleText.width), fOriginalX - fEndPositionDelta, fOriginalY);
                var ftaScreenTitleMoveToBack = cc.moveTo(0, fOriginalX, fOriginalY);
                var sequenceMediaTitle = cc.sequence(ftaScreenTitleMoveToTarget, ftaScreenTitleMoveToBack);
                var repeatScreenTitle = cc.repeat(sequenceMediaTitle, 10);
                repeatScreenTitle.setTag(Common.OVERLENGTH_MOVING);
                nodeScreenTitleText.runAction(repeatScreenTitle);
                nodeScreenTitleText2.active = true;
            }
        }
        if (0 == fiTo.node.getName().indexOf('YesIcon')) {
            cc.loader.loadRes('game/mall/checkBox_yes', cc.Texture2D, function (err, texture) {
                fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 59, 152, 59));
            });
        }
        if (0 == fiTo.node.getName().indexOf('NoIcon')) {
            cc.loader.loadRes('game/mall/checkBox_no', cc.Texture2D, function (err, texture) {
                fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 59, 152, 59));
            });
        }
    },

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

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

});