课程弹窗.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var httpUtils = require("HttpUtils");
  2. cc.Class({
  3. extends: require("Base"),
  4. properties: {
  5. label_title: {
  6. default: null,
  7. type: cc.Label
  8. },
  9. sprite_back: {
  10. default: null,
  11. type: cc.Sprite
  12. },
  13. sprite_catalog: {
  14. default: null,
  15. type: cc.Sprite
  16. },
  17. courseware_prefab: {
  18. default: null,
  19. type: cc.Prefab
  20. },
  21. view_scroll: {
  22. default: null,
  23. type: cc.ScrollView
  24. },
  25. view_layout: {
  26. default: null,
  27. type: cc.Layout
  28. }
  29. },
  30. // LIFE-CYCLE CALLBACKS:
  31. onLoad() {
  32. setViewTouch(
  33. this.sprite_back,
  34. null,
  35. function() {
  36. this.node.destroy();
  37. },
  38. null,
  39. this
  40. );
  41. this.initView(null);
  42. },
  43. start() {
  44. this.view_scroll.scrollToTop(0);
  45. },
  46. lateUpdate: function(dt) {
  47. setScaleX(this.root_view);
  48. },
  49. update(dt) {},
  50. initView: function(data) {
  51. var a = 33;
  52. if (a <= 4) {
  53. this.view_layout.node.setPosition(0, 171);
  54. } else {
  55. this.view_layout.node.setPosition(0, 0);
  56. }
  57. for (let i = 0; i < a; i++) {
  58. var courseware = cc.instantiate(this.courseware_prefab);
  59. courseware.getComponent("课件icon").kejian = this;
  60. var temp = this;
  61. courseware.getComponent("课件icon").setClickFunction(function() {
  62. // alert("position:" + i);
  63. temp.showShare();
  64. });
  65. this.view_layout.node.addChild(courseware);
  66. }
  67. },
  68. setTitle: function(title) {
  69. this.label_title.string = title;
  70. },
  71. showShare: function() {
  72. console.log(this)
  73. // cc.instantiate(this.detail_prefab).getComponent("popup").curriculum_window = this;
  74. this.curriculum_window.showShare();
  75. }
  76. });