| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- cc.Class({
- extends: cc.Component,
- properties: {
- item:cc.Prefab,
- listView:cc.ScrollView,
- gameLayout:cc.Layout,
- },
- init(){
- cc.vv.userMgr.getActivityList(this.OnGetPageData.bind(this));
- },
- // OnGetPageData(ret){
- // console.log(ret)
- // },
- OnGetPageData(ret){
- console.log("OnGetPageData bxx")
- if (ret.data && ret.data.length>0) {
- this.gameLayout.node.children.forEach(element => {
- element.destroy()
- });
- var gameitems = ret.data
- // gameitems.sort(function (a,b) {
- // return a.id - b.id
- // })
- for (let index = 0; index < gameitems.length; index++) {
- const data = gameitems[index]
- var gameItem = cc.instantiate(this.bxxitem)
- gameItem.name = "item"+data.id
- gameItem.getComponent('ActivityItem').setGameData(data,this)
- this.gameLayout.node.addChild(gameItem)
- }
- this.gameLayout.node.width = gameitems.length*gameItem.width +10
- this.gameLayout.node.parent.width =this.gameLayout.node.width
- this.listView.scrollToOffset(cc.v2(0,0),0)
- // this.gameLayout.node.height = 248
- }
- },
- OnBtnClicked(sender,gameid,type,money)
- {
- // var data = {
- // gameid : gameid,
- // type : type,
- // money : money
- // }
- // cc.vv.userMgr.turnOutMoney(data,this.init.bind(this));
- },
- });
|