#include "stdafx.h" #include "CUserInfo.h" #include "FileOperate.h" CUserInfo::CUserInfo() : id(0), port(0) { } CUserInfo::~CUserInfo() { } bool CUserInfo::Init(std::string data) { try { nlohmann::json j = nlohmann::json::parse(data.begin(), data.end()); if (j["ret"].get() == 1) { auto userinfo = j["data"]["user"]; // this->id = userinfo.at("id").get(); this->username = userinfo.at("account").get(); this->expiretime = userinfo.at("expired_at").get(); this->password = userinfo.at("passwd").get(); this->unusedTraffic = userinfo.at("unusedTraffic").get(); this->uuid = userinfo.at("uuid").get(); this->level = userinfo.at("level").get(); this->port = userinfo.at("port").get(); // this->access_token = j["data"]["access_token"].get(); this->token_type = j["data"]["token_type"].get(); return true; } else { this->m_error_msg = j["msg"].get(); return false; } } catch (...) { this->m_error_msg = "½âÎöÊý¾Ý´íÎó"; return false; } return false; } LPCSTR CUserInfo::GetLastErrorA() { return SStringA().Format("%s", m_error_msg.c_str()).GetBuffer(0); } LPCWSTR CUserInfo::GetLastErrorW() { return S_CA2W(m_error_msg.c_str(), CP_UTF8); }