MoYuWang 9 месяцев назад
Родитель
Сommit
a9c2e83efb

+ 3 - 1
Classes/IAP/IAPCtlShop.cpp

@@ -52,7 +52,9 @@ void IAPCtlShop::setCfg4Failure(std::string &cfgFN){
 }
 
 void IAPCtlShop::displayFailureCardIn(cocos2d::Node *node){
-    IAPCtlShopUI::getInstance()->displayFailureCardIn(node);
+    int stillNeedCoins = 0;
+    if(_delegate)stillNeedCoins = _delegate->getStillNeedCoinsWhenFailed();
+    IAPCtlShopUI::getInstance()->displayFailureCardIn(node, stillNeedCoins);
 }
 
 void IAPCtlShop::setDeviceLevel(int level){

+ 3 - 0
Classes/IAP/IAPDelegate.hpp

@@ -18,6 +18,9 @@ public:
     // 用户成功购买通知
     virtual void onUserBuySuccess(std::map<std::string, string> buyInfo) = 0;
     
+    // 获取还需要的金币数量
+    virtual int getStillNeedCoinsWhenFailed() = 0;
+    
 };
 
 

+ 2 - 1
Classes/IAP/Shop/IAPCtlShopUI.cpp

@@ -99,7 +99,7 @@ bool IAPCtlShopUI::create(Node* pNode, IAPConf* cfg, iap::ShopRequirement& requi
     return true;
 }
 
-void IAPCtlShopUI::displayFailureCardIn(cocos2d::Node *pNode){
+void IAPCtlShopUI::displayFailureCardIn(cocos2d::Node *pNode, int stillNeedCoins){
     clear();
     
     IAPCardView::sDotCfg cfg;
@@ -125,6 +125,7 @@ void IAPCtlShopUI::displayFailureCardIn(cocos2d::Node *pNode){
     cardView->setDelegate(cardViewDelegate);
 
     for (const auto& goodInfo : _goodsInfo) {
+        if(goodInfo.getCoinNumber() < stillNeedCoins)continue;
         auto item = IAPCtlShopItem::create(goodInfo, 1);
         _failItems.push_back(item);
         cardView->addCard(item);

+ 1 - 1
Classes/IAP/Shop/IAPCtlShopUI.hpp

@@ -29,7 +29,7 @@ public:
     // 以滑动卡片的形式在某个节点中显示某些版位(适用于失败时的场景)
     // pParent 父节点
     // plIds 需要的版位id
-    void displayFailureCardIn(cocos2d::Node* pNode);
+    void displayFailureCardIn(cocos2d::Node* pNode, int stillNeedCoins);
     
     // 添加一个商店版位
     // id 卡片id(添加版位时的id)