活动:弹出商店保护

This commit is contained in:
luying
2022-05-16 21:42:08 +08:00
parent f6c50f6cfd
commit b877931a0e
@@ -117,6 +117,7 @@ export class PopUpShopData extends ActivityBase {
public checkItem(data: ActivityPopUpShopModelType, productID: string) { public checkItem(data: ActivityPopUpShopModelType, productID: string) {
let pkg = this.findPackageById(data.id); let pkg = this.findPackageById(data.id);
let item = pkg.findItemByProductID(productID); let item = pkg.findItemByProductID(productID);
if(!item) return false
return item.hasBoughtCnt < item.buyCnt; return item.hasBoughtCnt < item.buyCnt;
} }
@@ -124,6 +125,7 @@ export class PopUpShopData extends ActivityBase {
let pkg = this.findPackageById(data.id); let pkg = this.findPackageById(data.id);
let dataItem = data.items.find(cur => cur.productID == productID); let dataItem = data.items.find(cur => cur.productID == productID);
let item = pkg.findItemByProductID(productID); let item = pkg.findItemByProductID(productID);
if(!item) return null
return item.updateItem(dataItem); return item.updateItem(dataItem);
} }
@@ -206,9 +208,11 @@ export class PopUpShopPackage {
if(data.beginTime <= now && data.endTime > now) { // 正在进行中 if(data.beginTime <= now && data.endTime > now) { // 正在进行中
for(let itemData of data.items) { for(let itemData of data.items) {
let item = this.findItemByProductID(itemData.productID); let item = this.findItemByProductID(itemData.productID);
if(item) {
item.setPlayerRecords(data, itemData); item.setPlayerRecords(data, itemData);
this.isPushing = true; this.isPushing = true;
} }
}
} else if (data.beginTime < now && data.endTime < now) { // 已经结束了的 } else if (data.beginTime < now && data.endTime < now) { // 已经结束了的
if(data.hasBought) { // 是否看到了,但是没有买 if(data.hasBought) { // 是否看到了,但是没有买
this.hasPassCnt = 0; this.hasPassCnt = 0;
@@ -219,9 +223,11 @@ export class PopUpShopPackage {
for(let itemData of data.items) { for(let itemData of data.items) {
let item = this.findItemByProductID(itemData.productID); let item = this.findItemByProductID(itemData.productID);
if(item) {
item.addPushCnt(); item.addPushCnt();
} }
} }
}
public setLatestBought(data: ActivityPopUpShopModelType) { public setLatestBought(data: ActivityPopUpShopModelType) {
this.latestItemId = data.items[0].id; this.latestItemId = data.items[0].id;
@@ -307,7 +313,7 @@ export class PopUpShopPackage {
let items: PopUpShopItemShow[] = []; let items: PopUpShopItemShow[] = [];
for(let item of popUpShopRec.items) { for(let item of popUpShopRec.items) {
let itemObj = this.findItemByProductID(item.productID); let itemObj = this.findItemByProductID(item.productID);
if(itemObj.isPushing) { if(itemObj && itemObj.isPushing) {
let obj = new PopUpShopItemShow(itemObj); let obj = new PopUpShopItemShow(itemObj);
items.push(obj); items.push(obj);
} }