QuestMain.js 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const Api = require('../net/Api');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. questItem: {
  6. default: null,
  7. type: cc.Node,
  8. },
  9. questWrap: {
  10. tooltip: '每日任务容器',
  11. default: null,
  12. type: cc.Node
  13. }
  14. },
  15. onLoad () {},
  16. init (quest) {
  17. this.quest = quest
  18. this.questItem.active = false
  19. Api.httpGet({
  20. url: "/task/mainTask.do",
  21. data: {},
  22. success: (res) => {
  23. let tasks = res.tasks
  24. for(let i = 0; i < tasks.length; i++) {
  25. let item = cc.instantiate(this.questItem)
  26. this.questWrap.addChild(item)
  27. item.active = true
  28. item.getComponent('QuestMainItem').init(this, tasks[i].list, tasks[i].sn, i)
  29. }
  30. }
  31. })
  32. },
  33. start () {
  34. },
  35. // update (dt) {},
  36. });