12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // IAPUserData.hpp
- // TileManor
- //
- // Created by 徐炼新 on 2024/9/30.
- //
- #ifndef IAPUserData_hpp
- #define IAPUserData_hpp
- #include <cocos2d.h>
- #include "IAPDefine.hpp"
- NS_IAPSHOP_BEGIN
- class IAPUserData {
- public:
- static IAPUserData* getInstance();
-
- IAPUserData();
- ~IAPUserData();
-
- // 添加购买信息
- // 参数说明 : 商品id
- void addBuyInfo(std::string commodityID);
- void addBuyInfo(std::vector<std::string> commodityIDs);
-
- // 获取用户购买记录
- std::vector<std::string> getBuyInfos();
-
- // 清除所有购买信息
- void clearBuyInfo();
- private:
-
- void init();
-
- std::string serialize(const std::vector<std::string>& vec);
- std::vector<std::string> deserialize(const std::string& str);
- void saveVectorString(const std::vector<std::string>& vec, const std::string& key);
- std::vector<std::string> loadVectorString(const std::string& key);
-
- private:
- static IAPUserData* _instance;
-
- std::vector<std::string> _buyInfos; // 用户购买信息
- };
- NS_IAPSHOP_END
- #endif /* IAPUserData_hpp */
|