41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import { GoodsComp } from './GoodsComp';
|
|
import { smc } from '../common/SingletonModuleComp';
|
|
import { getRandomGoods } from '../common/config/Goods';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('ShopPageComp')
|
|
export class ShopPageComp extends Component {
|
|
daily:any[]=[]
|
|
weekly:any[]=[]
|
|
monthly:any[]=[]
|
|
special:any[]=[]
|
|
start() {
|
|
this.update_daily()
|
|
this.update_weekly()
|
|
}
|
|
update_daily(){
|
|
let items=this.node.getChildByName("daily").getChildByName("items").children
|
|
for(let i=0;i<items.length;i++){
|
|
let goods=items[i]
|
|
goods.getComponent(GoodsComp).update_data(smc.shop.daily[i],i)
|
|
}
|
|
}
|
|
update_weekly(){
|
|
if(smc.shop.weekly.length ==0) {
|
|
this.weekly=getRandomGoods()
|
|
}
|
|
smc.shop.weekly=this.weekly
|
|
let items=this.node.getChildByName("weekly").getChildByName("items").children
|
|
for(let i=0;i<items.length;i++){
|
|
let goods=items[i]
|
|
goods.getComponent(GoodsComp).update_data(smc.shop.weekly[i],i+4)
|
|
}
|
|
}
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
}
|
|
|
|
|