var SDKManage = require("SDKManage") cc.Class({ extends: cc.Component, properties: { cpaicons: { default: [], type: cc.Node, }, function_id:9, icontype:2, refreshtime:5, }, // LIFE-CYCLE CALLBACKS: onLoad () { cc.Notifier.on('refreshcpa', this, this.refresh.bind(this)); }, onDestroy(){ cc.Notifier.off('refreshcpa',this); }, start () { this.time = 0 this.offset = 0 this.cpanum = 0 var type = 0; var flag = 0; this.recomlength = 0 for (var i in SDKManage.sortList.function_id) { if (this.function_id == SDKManage.sortList.function_id[i]) { flag = 1 type = SDKManage.sortList.type this.recomlength = SDKManage.sortList.id.length break; } } if (!flag) { for (var i in SDKManage.weightList.function_id) { if (this.function_id == SDKManage.weightList.function_id[i]) { flag = 1 type = SDKManage.weightList.type this.recomlength = SDKManage.weightList.id.length break; } } } if (type == 1){ this.refreshmode=3 } else { this.refreshmode=2 } this.type = type this.refresh() }, refresh(){ if (this.icontype == 0) { var cpadata = SDKManage.getRecommendList(this.type,this.cpaicons.length,this.icontype,this.offset) for(var i=0;ithis.recomlength){ this.offset = 0 }else{ this.offset+=this.cpaicons.length this.offset%=this.recomlength } } } else if (this.icontype == 1){ var cpadata = SDKManage.getRecommendListone(this.offset,this.cpaicons.length,this.cpaicons.length) for(var i=0;iSDKManage.cpalist.length){ this.offset = 0 }else{ this.offset+=this.cpaicons.length this.offset%=SDKManage.cpalist.length } } }, close(){ //this.node.destroy() }, update (dt) { this.time+=dt if(this.time>this.refreshtime&&(this.refreshmode==2||this.refreshmode==3)){ this.time = 0 this.refresh() this.cpanum++ } }, });