indexJS.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. var httpUtils = require("HttpUtils");
  2. cc.Class({
  3. extends: require("Base"),
  4. properties: {
  5. // defaults, set visually when attaching this script to the Canvas
  6. siji: {
  7. default: null,
  8. type: dragonBones.ArmatureDisplay
  9. },
  10. shijian: {
  11. default: null,
  12. type: dragonBones.ArmatureDisplay
  13. },
  14. zijideshiqingzijizuo: {
  15. default: null,
  16. type: dragonBones.ArmatureDisplay
  17. },
  18. view_scroll: {
  19. default: null,
  20. type: cc.ScrollView
  21. },
  22. curriculum_prefab: {
  23. default: null,
  24. type: cc.Prefab
  25. },
  26. helloWorld: {
  27. default: null,
  28. type: cc.Sprite
  29. },
  30. share_prefab: {
  31. default: null,
  32. type: cc.Prefab
  33. },
  34. content_prefab: {
  35. default: null,
  36. type: cc.Prefab
  37. }
  38. },
  39. // use this for initialization
  40. onLoad: function() {
  41. setViewTouch(
  42. this.siji,
  43. null,
  44. function(event) {
  45. cc.log("点击了四季");
  46. if (cc.sys.OS_ANDROID == cc.sys.os) {
  47. cc.log("android系统------------------");
  48. jsb.reflection.callStaticMethod(
  49. "org/cocos2dx/javascript/CallAndroid",
  50. "showMessage",
  51. "(Ljava/lang/String;)V",
  52. "点击了四季"
  53. );
  54. }
  55. var seq = cc.repeat(
  56. cc.sequence(cc.moveBy(0.1, 5, 0), cc.moveBy(0.1, -5, 0)),
  57. 5
  58. );
  59. this.siji.node.runAction(seq);
  60. },
  61. null,
  62. this
  63. );
  64. setViewTouch(
  65. this.siji,
  66. null,
  67. function(event) {
  68. cc.log("点击了四季");
  69. },
  70. null,
  71. this
  72. );
  73. setViewTouch(
  74. this.shijian,
  75. null,
  76. function(event) {
  77. cc.log("点击了时间");
  78. this.showCurriculum(null);
  79. if (cc.sys.OS_ANDROID == cc.sys.os) {
  80. cc.log("android系统------------------");
  81. jsb.reflection.callStaticMethod(
  82. "org/cocos2dx/javascript/CallAndroid",
  83. "callJS",
  84. "()V"
  85. );
  86. }
  87. },
  88. null,
  89. this
  90. );
  91. setViewTouch(
  92. this.zijideshiqingzijizuo,
  93. null,
  94. function(event) {
  95. // httpUtils
  96. // .getInstance()
  97. // .httpGets(
  98. // "https://api.weixin.qq.com/sns/userinfo?access_token=123&openid=123",
  99. // function(data) {
  100. // cc.log("data:" + data);
  101. // jsb.reflection.callStaticMethod(
  102. // "org/cocos2dx/javascript/CallAndroid",
  103. // "LogE",
  104. // "(Ljava/lang/String;)V",
  105. // data
  106. // );
  107. // }
  108. // );
  109. },
  110. null,
  111. this
  112. );
  113. setViewTouch(
  114. this.helloWorld,
  115. null,
  116. function(event) {
  117. cc.log("helloWorld");
  118. // this.showCurriculum(null);
  119. // navigator.navigate('New Scene');
  120. // cc.director.loadScene('New Scene')
  121. let parameter = {};
  122. parameter.title = 'wang ronghui';
  123. cc.wangronghui.navigator.navigate('New Scene', parameter);
  124. },
  125. null,
  126. this
  127. );
  128. },
  129. start: function(dt) {
  130. this.view_scroll.scrollToLeft(0);
  131. if (cc.sys.OS_ANDROID == cc.sys.os) {
  132. jsb.reflection.callStaticMethod(
  133. "org/cocos2dx/javascript/CallAndroid",
  134. "removeLoadingImage",
  135. "()V"
  136. );
  137. }
  138. },
  139. lateUpdate: function(dt) {
  140. setScaleX(this.root_view);
  141. },
  142. update: function(dt) {},
  143. showCurriculum: function() {
  144. var curriculum = cc.instantiate(this.curriculum_prefab);
  145. console.log('=======',curriculum)
  146. curriculum.getComponent("课程弹窗").curriculum_window = this;
  147. curriculum.getComponent("课程弹窗").setTitle("点击了时间");
  148. curriculum.getComponent("课程弹窗").initView(null);
  149. this.node.addChild(curriculum);
  150. },
  151. showShare: function() {
  152. var share = cc.instantiate(this.share_prefab);
  153. share.getComponent("popup").curriculum_window = this;
  154. this.node.addChild(share);
  155. },
  156. showDetail: function() {
  157. var content = cc.instantiate(this.content_prefab);
  158. content.getComponent("detail").curriculum_window = this;
  159. this.node.addChild(content);
  160. }
  161. });