StoreRecommend.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. item: cc.Prefab,
  5. content: cc.Node,
  6. },
  7. // LIFE-CYCLE CALLBACKS:
  8. // onLoad () {},
  9. init(content) {
  10. if (this._shops != undefined) {
  11. return;
  12. }
  13. this._shops = {};
  14. content.getShopsByType(1).then( (respondData) => {
  15. this._shops = respondData.shops;
  16. /// 购买了就是一条数据
  17. this._tjShops = respondData.tjShops;
  18. /// 合辑数据
  19. let albumItem = cc.instantiate(this.item);
  20. albumItem.getComponent('StoreBigItem').initAlbum(this._tjShops);
  21. this.content.addChild(albumItem);
  22. for (let i = 0; i < this._shops.length; ++ i) {
  23. let recomendItem = cc.instantiate(this.item);
  24. recomendItem.getComponent('StoreBigItem').init(this._shops[i], 20, 1, i);
  25. this.content.addChild(recomendItem);
  26. }
  27. }).catch((code, msg) => {
  28. console.log(code, msg);
  29. })
  30. },
  31. start () {
  32. },
  33. // update (dt) {},
  34. });