mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
53
JisolGameCocos/assets/script/ui/Shop/ShopGiftItem.ts
Normal file
53
JisolGameCocos/assets/script/ui/Shop/ShopGiftItem.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { TB, TbGEnum } from '../../config/data/schema';
|
||||
import JNScrollViewItem from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { TD } from '../../App';
|
||||
import { Label } from 'cc';
|
||||
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import GiftData from '../../data/GiftData';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ShopGiftItem')
|
||||
export class ShopGiftItem extends JNScrollViewItem<TB.TbGShop> {
|
||||
|
||||
@property(Label)
|
||||
giftName:Label; //礼包名称
|
||||
|
||||
@property(Label)
|
||||
giftLimit:Label; //限购
|
||||
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView; //礼包列表
|
||||
|
||||
gift: TB.TbGGift;
|
||||
|
||||
onInit(data: TB.TbGShop): void {
|
||||
|
||||
this.gift = TD.TbGGift.get(data.giftId);
|
||||
|
||||
}
|
||||
|
||||
protected start(): void {
|
||||
|
||||
this.giftName.string = this.data.tig;
|
||||
|
||||
if(this.gift.limit == TbGEnum.TGiftLimit.Unlimited)
|
||||
this.giftLimit.string = "( 无限 )";
|
||||
if(this.gift.limit == TbGEnum.TGiftLimit.DayLimit)
|
||||
this.giftLimit.string = `每天( ${GiftData.getIns().getGiftDayRecordCount(this.gift.id)}/${this.gift.limitValue} )`;
|
||||
if(this.gift.limit == TbGEnum.TGiftLimit.Limit)
|
||||
this.giftLimit.string = `限制( ${GiftData.getIns().getGiftRecordCount(this.gift.id)}/${this.gift.limitValue} )`;
|
||||
|
||||
this.views.refreshData(this.gift.rewards);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//点击购买礼包
|
||||
async onClickBuy(){
|
||||
await GiftData.getIns().buy(this.gift.id)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3c689f59-1914-4f82-b32f-9b60142cd8f8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
43
JisolGameCocos/assets/script/ui/Shop/ShopView.ts
Normal file
43
JisolGameCocos/assets/script/ui/Shop/ShopView.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import { app, TD } from '../../App';
|
||||
import GiftData, { GiftDataEnum } from '../../data/GiftData';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//商店页面
|
||||
@ccclass('ShopView')
|
||||
export class ShopView extends JNLayerBase {
|
||||
|
||||
//商店礼包列表
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView
|
||||
|
||||
async onJNLoad(data?: any) {
|
||||
|
||||
super.onJNLoad(data);
|
||||
|
||||
await this.onUpdateView();
|
||||
|
||||
//监听
|
||||
app.event.on(GiftDataEnum.BUY,this.onUpdateView,this)
|
||||
|
||||
}
|
||||
|
||||
onJNClose(): void {
|
||||
super.onJNClose();
|
||||
app.event.off(GiftDataEnum.BUY,this.onUpdateView,this)
|
||||
}
|
||||
|
||||
async onUpdateView() {
|
||||
|
||||
await GiftData.getIns().UpdateGiftRecord();
|
||||
await GiftData.getIns().UpdateGiftDayRecord();
|
||||
|
||||
this.views.refreshData(TD.TbGShop.getDataList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
9
JisolGameCocos/assets/script/ui/Shop/ShopView.ts.meta
Normal file
9
JisolGameCocos/assets/script/ui/Shop/ShopView.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "eb3d9ece-55ba-4a24-8103-75b6ae2c3f4d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user