Sign.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. // onLoad () {},
  6. OnShowView:function(){
  7. this.BindButtonInit();
  8. this.$('NoClick').setContentSize(10000, 10000);
  9. this.OnUpdateSignView31();
  10. },
  11. OnClick_BtSign:function(){
  12. cc.gSoundRes.PlaySound('Button');
  13. console.log('OnClicked_BtSign')
  14. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  15. var webUrl = window.PHP_HOME+'/SignIn.php?&GetMark=1&dwUserID='+pGlobalUserData.dwUserID;
  16. WebCenter.GetData(webUrl, null, function (data) {
  17. var Res = JSON.parse(data);
  18. this.ShowAlert(Res.Desc);
  19. this.OnShowView(true);
  20. WebCenter.SetDataOutTime('GetMark=5');
  21. this.m_Hook.OnBtRefeshRoomCard();
  22. }.bind(this));
  23. },
  24. OnUpdateSignView31:function(){
  25. this.m_NdView = this.$('BG');
  26. var TempData = new Date();
  27. cc.log("當前時間: "+TempData);
  28. this.$("BG/Month@Label").string = TempData.getMonth()+1;
  29. this.$('BG/Time@Label').string = TempData.getFullYear()+'年';//+(TempData.getMonth()+1)+'月'+TempData.getDate()+'日' ;
  30. var Today = TempData.getDate();
  31. var day = new Date(TempData.getFullYear(),TempData.getMonth()+1,0).getDate(); //本月天数
  32. TempData.setDate(1) //本月首日
  33. var LastDay = this.GetLastMonthDays(); //上月天数
  34. var StartIndex = TempData.getDay();//0-6 周日-周6
  35. //周期转化为周1-周日
  36. // if(StartIndex == 0) StartIndex = 7;
  37. // StartIndex = StartIndex - 1
  38. //结束索引
  39. var EndIndex = StartIndex + day;
  40. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  41. var webUrl = window.PHP_HOME+'/SignIn.php?&GetMark=0&dwUserID='+pGlobalUserData.dwUserID;
  42. WebCenter.GetData(webUrl,0, function (data) {
  43. var SignArr = JSON.parse(data);
  44. var SignCnt = 0;
  45. for(var i=1;i<=31;i++){
  46. if(SignArr[i] == null) SignArr[i] = 0;
  47. else SignCnt++;
  48. }
  49. this.$('BG/BtSign@Button').interactable = (!SignArr[Today]);
  50. this.$('BG/Num/Num@Label').string = SignCnt+'次';
  51. //console.log('OnUpdateSignView31 0 ', day,LastDay,StartIndex,EndIndex )
  52. for(var i=0;i<37;i++){
  53. var Day = '';
  54. if(i < StartIndex) {
  55. //上月
  56. Day = LastDay - StartIndex + i + 1;
  57. this.$('BG/content/'+i+'/today').active = false;
  58. this.$('BG/content/'+i+'/ok').active = false;
  59. this.$('BG/content/'+i+'/NoLight').active = true;
  60. this.$('BG/content/'+i+'/day').color = cc.color(222,221,200);
  61. }else if(i >= EndIndex){
  62. //下月
  63. Day = i - StartIndex + 1 - day;
  64. this.$('BG/content/'+i+'/today').active = false;
  65. this.$('BG/content/'+i+'/ok').active = false;
  66. this.$('BG/content/'+i+'/NoLight').active = true;
  67. this.$('BG/content/'+i+'/day').color = cc.color(222,221,200);
  68. }else {
  69. //当月
  70. Day = i - StartIndex + 1;
  71. this.$('BG/content/'+i+'/today').active = Today==Day;
  72. //this.$('content/'+i+'/SignBG_p' ,this.m_NdView).active = (Today>Day && SignArr[Day]==0)
  73. if(SignArr[Day] > 0){
  74. this.$('BG/content/'+i+'/ok').active = true;
  75. }else{
  76. if(i<parseInt(Today+StartIndex-1)){
  77. // this.$('BG/content/'+i+'/no').active = true;
  78. this.$('BG/content/'+i+'/day').color = cc.color(253,168,147);
  79. }
  80. }
  81. this.$('BG/content/'+i+'/NoLight').active = false;
  82. }
  83. this.$('BG/content/'+i+'/day@Label').string = Day;
  84. if(Today==Day){
  85. this.$('BG/content/'+i+'/day').color = cc.color(255,180,0);
  86. }
  87. // }else if(SignArr[Day] > 0){
  88. // this.$('BG/content/'+i+'/day').color = cc.color(76,187,40);
  89. // }else{
  90. // this.$('BG/content/'+i+'/day').color = cc.color(189,70,52);
  91. // }
  92. }
  93. }.bind(this));
  94. },
  95. GetLastMonthDays:function(){
  96. var TempData = new Date();
  97. var day;
  98. if(TempData.getMonth() > 1){
  99. day = new Date(TempData.getFullYear(),TempData.getMonth(),0)
  100. }else{
  101. day = new Date(TempData.getFullYear()-1,12,0)
  102. }
  103. return day.getDate();
  104. },
  105. // update (dt) {},
  106. });