Common.js 6.42 KB
cc.Class({
    extends: cc.Component,

    properties: {

    },

    // use this for initialization
    onLoad: function () {

    },

    statics: {

        SCREEN_WIDTH: 1280.0,
        SCREEN_HEIGHT: 720.0,

        MOVE_DIRECTION_UP: 0,
        MOVE_DIRECTION_RIGHT: 1,
        MOVE_DIRECTION_DOWN: 2,
        MOVE_DIRECTION_LEFT: 3,

        FOCUS_FLY_DURATION: 0.3,
        FOCUS_BREATH_DURATION: 0.8,

        //Action Tag
        FEATURE_NODE_TRANSFER: 1,
        FOCUS_CELL_TRANSFER: 1,
        FOCUS_CONTAINER_TRANSFER: 1,
        FOCUS_CONTAINER_BREATH: 2,
        FOCUS_CONTAINER_JOGGLE: 3,

        OVERLENGTH_MOVING: 4,

        SCROLL_BY_FOCUS_CHANGE: 5,

        API_SORT_ASC: 'asc',
        API_SORT_DESC: 'desc',

        FEMALE: 0,
        MALE: 1,
        BAND: 2,

        ANDROID_KEY: {
            back: 6,
            up: 1003,
            right: 1001,
            down: 1004,
            left: 1000,
            enter: 1005
        },

        BUSINESS_PARAMETER: {
            //  {:,

        },

        //天津少儿2.0测试接口
        // TOPDRAW_API_SERVER:'http://202.99.114.74:52118/hyperion.chimera/',
        // TOPDRAW_API_SERVER2:'http://202.99.114.74:52118/hyperion.archer/',
        // TOPDRAW_IMAGE_SERVER:'http://202.99.114.74:52118/hyperion.resource/',

        //新部署测试接口
        TOPDRAW_API_SERVER: 'http://139.196.192.242:8080/hyperion.chimera/',
        TOPDRAW_API_SERVER2: 'http://139.196.192.242:8080/hyperion.archer/',
        TOPDRAW_IMAGE_SERVER: 'http://139.196.192.242:8080/hyperion.resource/',
        // TOPDRAW_API_SERVER : "http://111.11.189.12:8080/hyperion.chimera/",   //暂且取用EPG数据
        // TOPDRAW_IMAGE_SERVER : "http://111.11.189.12:8080/hyperion.resource/",
        // TOPDRAW_API_SERVER2:'http://111.11.189.12:8080/hyperion.archer/',
        TEST_API_TOKEN: 'dd4b1968eb5b417e834c2687e23d2471',
        TEST_API_TOKEN2: '2016f5a5ada24b86afebf6cd2ba30c70',

        //教育
        TOPDRAW_API_SERVER_EDU: 'http://139.196.4.234:38080/hyperion.chimera/',
        TOPDRAW_IMAGE_SERVER_EDU: 'http://139.196.4.234:38080/eduHall/pages/index/',
        TOPDRAW_IMAGE_SERVER_EDU_RIGHT: 'http://139.196.4.234:38080/hyperion.resource/',
        TEST_API_TOKEN_EDU: 'b4863228c5ef4593991ad4cc83f0cabf',

        BI_BASE_PATH: 'http://139.196.192.242:82/1.gif',

        TV_LINK_ACTION_CLICK: 100,
        TV_LINK_ACTION_HOVER: 101,

        // TEST_API_TOKEN:'8a56a215e7be4cf6910990d4d7c95e2c',
        USER_ID: '1',
        AUTH_STATUS: 0,
        DEBUG_MODE: 0,//0非调试模式,1调试模式
        APP_VERSION_NAME: '1.0.0',

        g_strCurrentSceneName: "",

        loadRes: function (strResourceURL,/*iResourceIndex,*/onSuccess, onError, oScope) {
            cc.loader.loadRes(strResourceURL,
                function (error, loadedResource) {
                    if (error) {
                        if (null != oScope) {
                            onError.call(oScope, error);
                        } else {
                            onError(error);
                        }
                    } else {
                        if (null != oScope) {
                            onSuccess.call(oScope, loadedResource/*,iResourceIndex*/);
                        } else {
                            onSuccess(loadedResource/*,iResourceIndex*/);
                        }
                    }
                }
            );

        },

        setTimeout: function (onTimeComplete, iDuration, oScope, argements) {

            /*
            window.setTimeout(onTimeComplete,iDuration,);
            
            
            cc.loader.loadRes(strResourceURL, 
                function(error,loadedResource){
                    if (error){
                        if(null!=oScope){
                            onError.call(oScope,error);
                        }else{
                            onError(error);
                        }   
                    }else{
                        if(null!=oScope){
                            onSuccess.call(oScope,loadedResource);
                        }else{
                            onSuccess(loadedResource);
                        }   
                    }             
                }            
            );
            */
        },
        getAbsolutePositionX: function (node) {

        },
        getAbsolutePositionY: function (node) {

        },
        promiseAjax: function () {

        },

        getNodePath: function (node) {
            let strPath = "";
            while (node.parent && node.parent.parent) {//不算TopCanvas
                strPath = "/" + node.name + strPath;
                node = node.parent;
            }
            return strPath.substring(1);
        },
        getX: function (tempNode) {
            let fCenterX = 0;
            while (tempNode.parent.parent) {//不算TopCanvas
                //cc.log(tempNode.name+"  X: "+tempNode.x)
                fCenterX += tempNode.x;
                tempNode = tempNode.parent;
            }
            return fCenterX;
        },
        getY: function (tempNode) {
            let fCenterY = 0;
            while (tempNode.parent.parent) {//不算TopCanvas
                //cc.log(tempNode.name+"  Y: "+tempNode.y)
                fCenterY += tempNode.y;
                tempNode = tempNode.parent;
            }
            return fCenterY;
        },


        /**
         * 用于合并对象 By Eva
         * @param target
         * @param firstSource
         * @returns {any}
         */
        assign: function (target, firstSource) {
            if (target === undefined || target === null)
                throw new TypeError("Cannot convert first argument to object");
            var to = Object(target);
            for (var i = 1; i < arguments.length; i++) {
                var nextSource = arguments[i];
                if (nextSource === undefined || nextSource === null) continue;
                var keysArray = Object.keys(Object(nextSource));
                for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
                    var nextKey = keysArray[nextIndex];
                    var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
                    if (desc !== undefined && desc.enumerable) to[nextKey] = nextSource[nextKey];
                }
            }
            return to;
        },


    }
    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});