guoqing.zhu 067c712f62 udpate
2022-06-14 13:51:53 +08:00

47 lines
1013 B
TypeScript

import { ShopItem } from './ShopItem';
const { ccclass, property } = cc._decorator;
@ccclass
export class UIShop extends cc.Component {
@property(cc.Node) itemContentNd: cc.Node = null;
@property(cc.Prefab) itemPrefab: cc.Prefab = null;
private shopItems: any;
private a = {
goods_id: 30100,
item_id: 30100,
price_info: {
cost_list: [[{ item_id: 10001, item_num: 50, discount: 0 }]],
discount_begin_time: 1655210850,
discount_end_time: 1655210850,
},
flag_icon: '',
limit_type: '',
bought_times: 0,
total_buy_times: '',
};
init(data) {
this.shopItems = data.info.goods_list1;
this.reSetUI();
}
reSetUI() {
for (let i = 0; i < this.shopItems.length; i += 1) {
let singleData = this.shopItems[i];
let node = cc.instantiate(this.itemPrefab);
this.itemContentNd.addChild(node);
let shotinfo = node.getComponent(ShopItem);
shotinfo.init(singleData);
}
}
start() {}
onclose() {
this.node.destroy();
}
}