|
@@ -79,6 +79,45 @@ bool IAPCtlShopUI::create(Node* pNode, IAPConf* cfg, int placementId) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool IAPCtlShopUI::create(Node* pNode, IAPConf* cfg, iap::ShopRequirement& requirement,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);
|
|
|
|
+ }
|
|
|
|
+ sortGoods(requirement);
|
|
|
|
+
|
|
|
|
+ // 构建 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;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
void IAPCtlShopUI::_onNotifyDevelopment(const redutils::ReboltNotifyData& data) {
|
|
void IAPCtlShopUI::_onNotifyDevelopment(const redutils::ReboltNotifyData& data) {
|
|
if (data.notify == "绑定显示区域") {
|
|
if (data.notify == "绑定显示区域") {
|
|
_ndScrollArea = data.outNode;
|
|
_ndScrollArea = data.outNode;
|
|
@@ -207,6 +246,44 @@ void IAPCtlShopUI::constructShopItem(bool bShowAll) {
|
|
}, 0.05, "SCH_Update_Cells");
|
|
}, 0.05, "SCH_Update_Cells");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void IAPCtlShopUI::sortGoods(iap::ShopRequirement &requirement){
|
|
|
|
+ std::map<int, bool> m;
|
|
|
|
+ int cnt = 0;
|
|
|
|
+ for(const auto& goodsInfo : _goodsInfo){
|
|
|
|
+ for(const auto area : goodsInfo.areas){
|
|
|
|
+ bool flag = false;
|
|
|
|
+ for(int i = 0;i < area.size(); i++){
|
|
|
|
+ if(area[i].name != "coin")continue;
|
|
|
|
+ if(std::stoi(area[i].count) >= requirement.coinsMin){
|
|
|
|
+ m[cnt] = true;
|
|
|
|
+ flag = true;
|
|
|
|
+ break;
|
|
|
|
+ }else{
|
|
|
|
+ m[cnt] = false;
|
|
|
|
+ flag = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(flag)break;
|
|
|
|
+ }
|
|
|
|
+ cnt++;
|
|
|
|
+ }
|
|
|
|
+ std::vector<GoodsInfo> newGoodsInfo;
|
|
|
|
+ // 添加符合条件的礼包
|
|
|
|
+ for(int i = 0;i < _goodsInfo.size(); i++){
|
|
|
|
+ if(m[i]){
|
|
|
|
+ newGoodsInfo.push_back(_goodsInfo[i]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 添加不符合条件的礼包(不清楚是不是需要显示,暂放到列表末尾)
|
|
|
|
+ for(int i = 0;i < _goodsInfo.size(); i++){
|
|
|
|
+ if(!m[i]){
|
|
|
|
+ newGoodsInfo.push_back(_goodsInfo[i]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ _goodsInfo = newGoodsInfo;
|
|
|
|
+}
|
|
|
|
+
|
|
void IAPCtlShopUI::quit() {
|
|
void IAPCtlShopUI::quit() {
|
|
if (_layer) {
|
|
if (_layer) {
|
|
_layer->runBehaviacWhitFunName("退出");
|
|
_layer->runBehaviacWhitFunName("退出");
|