|
@@ -5,13 +5,15 @@
|
|
|
// Created by 徐炼新 on 2024/1/16.
|
|
|
//
|
|
|
|
|
|
-#include "IAPCtlShopUI.hpp"
|
|
|
-#include "IAPCtlShopItem.hpp"
|
|
|
+#include "IAPCtlShop.hpp"
|
|
|
+
|
|
|
#include "RUUtils.h"
|
|
|
#include "RUPlatform.h"
|
|
|
|
|
|
-#include "IAPCtlShop.hpp"
|
|
|
+#include "IAPConf.hpp"
|
|
|
#include "IAPUserData.hpp"
|
|
|
+#include "IAPCtlShopUI.hpp"
|
|
|
+#include "IAPCtlShopItem.hpp"
|
|
|
#include <regex>
|
|
|
|
|
|
IAPCtlShopUI* IAPCtlShopUI::_instance = nullptr;
|
|
@@ -47,42 +49,6 @@ void IAPCtlShopUI::clear() {
|
|
|
_cb = nullptr;
|
|
|
}
|
|
|
|
|
|
-bool IAPCtlShopUI::create(Node* pNode, IAPConf* cfg, int placementId) {
|
|
|
- redutils::Platform::getInstance()->reportLog("open iap");
|
|
|
- _cfg = cfg;
|
|
|
- _bUIShowing = true;
|
|
|
- _placementId = placementId;
|
|
|
- clear();
|
|
|
-
|
|
|
- _layer = redutils::RUReboltLayer::createReboltLayer("shop_interface.redream");
|
|
|
- pNode->addChild(_layer, 3);
|
|
|
- _layer->registerOnNotify([this](const redutils::ReboltNotifyData& data){
|
|
|
- _onNotifyDevelopment(data);
|
|
|
- });
|
|
|
- _layer->runBehaviacWhitFunName("初始化");
|
|
|
-
|
|
|
-// _igCoin->doOwnInit();
|
|
|
-
|
|
|
- if (_goodsInfo.size() == 0) {
|
|
|
- IAPConf::getInstance()->getAllGoods(_goodsInfo);
|
|
|
- }
|
|
|
-
|
|
|
- // 构建 list 区域
|
|
|
- constructShopItem(false);
|
|
|
- cocos2d::Size size = _ndScrollArea->getContentSize();
|
|
|
- _tableView = redutils::RUTableView::create(&_tableData, cocos2d::Size(size.width, size.height));
|
|
|
- _tableView->setCascadeOpacityEnabled(true);
|
|
|
- _tableView->setCascadeColorEnabled(true);
|
|
|
- _tableView->setDirection(ScrollViewSmooth::Direction::VERTICAL);
|
|
|
- _tableView->setVerticalFillOrder(TableViewSmooth::VerticalFillOrder::TOP_DOWN, false);
|
|
|
- _tableView->setDelegate(&_tableData);
|
|
|
- _tableView->setBounceable(true);
|
|
|
-// _tableView->setOutSightClean(false);
|
|
|
- _ndScrollArea->addChild(_tableView);
|
|
|
-
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
bool IAPCtlShopUI::create(Node* pNode, IAPConf* cfg, iap::ShopRequirement& requirement,int placementId) {
|
|
|
redutils::Platform::getInstance()->reportLog("open iap");
|
|
|
_cfg = cfg;
|
|
@@ -183,7 +149,7 @@ void IAPCtlShopUI::constructShopItem(bool bShowAll) {
|
|
|
break;
|
|
|
}
|
|
|
// 当前有效的区域
|
|
|
- int bigPackCount,SmallPackCount; // 需要显示的礼包
|
|
|
+ int bigPackCount,smallPackCount; // 需要显示的礼包
|
|
|
auto iapCtlShop = iap::IAPCtlShop::createWith();
|
|
|
int leval = iapCtlShop->getDeviceLevel();
|
|
|
size_t placementCount = iapCtlShop->getPlacementCount();
|
|
@@ -191,7 +157,7 @@ void IAPCtlShopUI::constructShopItem(bool bShowAll) {
|
|
|
case 1:
|
|
|
// 低等级
|
|
|
bigPackCount = 2;
|
|
|
- SmallPackCount = 1;
|
|
|
+ smallPackCount = 1;
|
|
|
break;
|
|
|
case 2:
|
|
|
// 中等级
|
|
@@ -199,10 +165,10 @@ void IAPCtlShopUI::constructShopItem(bool bShowAll) {
|
|
|
case 3:
|
|
|
if(placementCount >= 2){
|
|
|
bigPackCount = 3;
|
|
|
- SmallPackCount = 0;
|
|
|
+ smallPackCount = 0;
|
|
|
}else{
|
|
|
bigPackCount = 2;
|
|
|
- SmallPackCount = 2;
|
|
|
+ smallPackCount = 2;
|
|
|
}
|
|
|
// 高等级
|
|
|
break;
|
|
@@ -210,47 +176,54 @@ void IAPCtlShopUI::constructShopItem(bool bShowAll) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- // 显示商品
|
|
|
- for (const auto& gi : _goodsInfo) {
|
|
|
- // 判断是否显示
|
|
|
- bool isShow = false;
|
|
|
- if (bShowAll) {
|
|
|
- isShow = true;
|
|
|
- }else{
|
|
|
- if(gi.type == "panel" && bigPackCount > 0){
|
|
|
- isShow = true;
|
|
|
- bigPackCount--;
|
|
|
- }
|
|
|
- if(gi.type == "bar" && SmallPackCount > 0){
|
|
|
+ // 展示活动商品
|
|
|
+
|
|
|
+
|
|
|
+ // 判断是否还有版位
|
|
|
+ if(bigPackCount != 0 || smallPackCount != 0 || bShowAll){
|
|
|
+ // 显示常规商品
|
|
|
+ for (const auto& gi : _goodsInfo) {
|
|
|
+ // 判断是否显示
|
|
|
+ bool isShow = false;
|
|
|
+ if (bShowAll) {
|
|
|
isShow = true;
|
|
|
- SmallPackCount--;
|
|
|
+ }else{
|
|
|
+ if(gi.type == "panel" && bigPackCount > 0){
|
|
|
+ isShow = true;
|
|
|
+ bigPackCount--;
|
|
|
+ }
|
|
|
+ if(gi.type == "bar" && smallPackCount > 0){
|
|
|
+ isShow = true;
|
|
|
+ smallPackCount--;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // 商品显示
|
|
|
- if (isShow) {
|
|
|
- bool bNeedAnim = height <= size.height;
|
|
|
- Node* nd = Node::create();
|
|
|
- nd->setCascadeOpacityEnabled(true);
|
|
|
- nd->setCascadeColorEnabled(true);
|
|
|
- auto si = IAPCtlShopItem::create(gi, _placementId);
|
|
|
- auto sz = si->getSize();
|
|
|
- cocos2d::Vec2 pos(size.width/2.0, sz.height/2.0);
|
|
|
- nd->addChild(si);
|
|
|
- si->setPosition(bNeedAnim ? pos+offset : pos);
|
|
|
- _goodsItems.push_back(si);
|
|
|
- _tableData.insertCell(index++, nd);
|
|
|
- _allSizes.push_back(sz);
|
|
|
- height += sz.height;
|
|
|
-
|
|
|
- if (bNeedAnim) {
|
|
|
- // 加入动画
|
|
|
- auto d = DelayTime::create(delayIdx*dur/8.0);
|
|
|
- auto m = EaseBackOut::create(MoveBy::create(dur, cocos2d::Vec2(-offset.x, offset.y)));
|
|
|
- si->runAction(Sequence::create(d, m, NULL));
|
|
|
- delayIdx ++;
|
|
|
+ // 商品显示
|
|
|
+ if (isShow) {
|
|
|
+ bool bNeedAnim = height <= size.height;
|
|
|
+ Node* nd = Node::create();
|
|
|
+ nd->setCascadeOpacityEnabled(true);
|
|
|
+ nd->setCascadeColorEnabled(true);
|
|
|
+ auto si = IAPCtlShopItem::create(gi, _placementId);
|
|
|
+ auto sz = si->getSize();
|
|
|
+ cocos2d::Vec2 pos(size.width/2.0, sz.height/2.0);
|
|
|
+ nd->addChild(si);
|
|
|
+ si->setPosition(bNeedAnim ? pos+offset : pos);
|
|
|
+ _goodsItems.push_back(si);
|
|
|
+ _tableData.insertCell(index++, nd);
|
|
|
+ _allSizes.push_back(sz);
|
|
|
+ height += sz.height;
|
|
|
+
|
|
|
+ if (bNeedAnim) {
|
|
|
+ // 加入动画
|
|
|
+ auto d = DelayTime::create(delayIdx*dur/8.0);
|
|
|
+ auto m = EaseBackOut::create(MoveBy::create(dur, cocos2d::Vec2(-offset.x, offset.y)));
|
|
|
+ si->runAction(Sequence::create(d, m, NULL));
|
|
|
+ delayIdx ++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// 添加展示所有按钮
|
|
|
if (!bShowAll) {
|
|
|
// 加入show All btn, 这个是一定会有动画的
|