CLoginInfo.cpp 677 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "stdafx.h"
  2. #include "CLoginInfo.h"
  3. CLoginInfo::CLoginInfo()
  4. {
  5. }
  6. CLoginInfo::~CLoginInfo()
  7. {
  8. }
  9. bool CLoginInfo::Init(std::string data)
  10. {
  11. if (data.empty())
  12. {
  13. return false;
  14. }
  15. try
  16. {
  17. nlohmann::json j = nlohmann::json::parse(data.begin(), data.end());
  18. if (j["code"].get<int>() == 0)
  19. {
  20. //
  21. this->token = j["data"]["token"].get<std::string>();
  22. this->auth_data = j["data"]["auth_data"].get<std::string>();
  23. return true;
  24. }
  25. else
  26. {
  27. this->m_error_msg = S_CA2W(j["message"].get<std::string>().c_str(), CP_UTF8).GetBuffer(0);
  28. return false;
  29. }
  30. }
  31. catch (...)
  32. {
  33. this->m_error_msg = L"½âÎöÊý¾Ý´íÎó";
  34. return false;
  35. }
  36. return false;
  37. }