MacInfo.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_SpNet:cc.Sprite,
  5. m_SpPower:cc.Sprite,
  6. m_LabTime:cc.Label,
  7. m_atlas:cc.SpriteAtlas
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad :function() {
  11. this.CheckMacInfo();
  12. this.schedule(this.CheckMacInfo, 3);
  13. },
  14. CheckMacInfo:function () {
  15. //时间
  16. var date = new Date();
  17. this.m_LabTime.string = pad(date.getHours(),2) +':'+pad(date.getMinutes(),2);
  18. //网络
  19. var strN = 'signal'
  20. if(window.g_NetResponseTime>800 || window.g_NetResponseTime < 0) strN+='1';
  21. else if(window.g_NetResponseTime>500) strN+='2';
  22. else if(window.g_NetResponseTime>200)strN+='3';
  23. else if(window.g_NetResponseTime>100)strN+='4';
  24. else if(window.g_NetResponseTime<=100)strN+='5';
  25. this.m_SpNet.spriteFrame = this.m_atlas.getSpriteFrame(strN);
  26. //电量
  27. var pLv = ThirdPartyGetBattery();
  28. var strP = 'power'
  29. if(pLv<0.4) strP+='1';
  30. else if(pLv<0.6) strP+='2';
  31. else if(pLv<0.8) strP+='3';
  32. else if(pLv>=0.8) strP+='4';
  33. this.m_SpPower.spriteFrame = this.m_atlas.getSpriteFrame(strP);
  34. },
  35. // update (dt) {},
  36. });