#include "stdafx.h" #include "CSysConfig.h" #include "CManageNetWork.h" CSysConfig::CSysConfig() { userbuylink.empty(); userattrlink.empty(); useronlinekflink.empty(); user_tag = 0; } CSysConfig::~CSysConfig() { } bool CSysConfig::Inti(std::string data) { if (data.empty()) { return false; } try { nlohmann::json j = nlohmann::json::parse(data.begin(), data.end()); if (j["code"].get() == 0) { // //auto stime = j["data"]["user_login_url"].get(); //userbuylink = j["data"]["user_login_url"].get(); //userattrlink = j["data"]["affurl"].get(); //useronlinekflink = j["data"]["user_ticket"].get(); user_reg = j["data"]["register"].get(); user_reset = j["data"]["user_reset"].get(); home = j["data"]["home"].get(); //user_tutorial = j["data"]["user_tutorial"].get(); //user_tag = j["data"]["tag"].get(); return true; } else { this->m_error_msg = S_CA2W(j["message"].get().c_str(), CP_UTF8).GetBuffer(0); return false; } } catch (...) { this->m_error_msg = L"解析数据错误"; return false; } return false; } bool CSysConfig::IntiLogin(std::string data) { if (data.empty()) { return false; } try { nlohmann::json j = nlohmann::json::parse(data.begin(), data.end()); if (j["code"].get() == 0) { // //auto stime = j["data"]["user_login_url"].get(); //userbuylink = j["data"]["user_login_url"].get(); //userattrlink = j["data"]["affurl"].get(); //useronlinekflink = j["data"]["user_ticket"].get(); LoginToHome = j["data"].get(); //user_tutorial = j["data"]["user_tutorial"].get(); //user_tag = j["data"]["tag"].get(); return true; } else { this->m_error_msg = S_CA2W(j["message"].get().c_str(), CP_UTF8).GetBuffer(0); return false; } } catch (...) { this->m_error_msg = L"解析数据错误"; return false; } return false; } SStringW CSysConfig::GetLoginHomeLink() { return S_CA2W(LoginToHome.c_str(), CP_UTF8); //return SStringW().Format(L"%s?email=%s&password=%s", S_CA2W(userbuylink.c_str(), CP_UTF8).GetBuffer(0), CManageNetWork::getSingletonPtr()->GetUsername(), CManageNetWork::getSingletonPtr()->GetPassWord()); } SStringW CSysConfig::GetHomeLink() { return S_CA2W(home.c_str(), CP_UTF8); //return SStringW().Format(L"%s?email=%s&password=%s", S_CA2W(userbuylink.c_str(), CP_UTF8).GetBuffer(0), CManageNetWork::getSingletonPtr()->GetUsername(), CManageNetWork::getSingletonPtr()->GetPassWord()); } SStringW CSysConfig::GetBuyLink() { if (user_tag == 1) { return S_CA2W(userbuylink.c_str(), CP_UTF8); } return SStringW().Format(L"%s?email=%s&password=%s", S_CA2W(userbuylink.c_str(), CP_UTF8).GetBuffer(0), CManageNetWork::getSingletonPtr()->GetUsername(), CManageNetWork::getSingletonPtr()->GetPassWord()); } SStringW CSysConfig::GetOnlineLink() { if (user_tag == 1) { return S_CA2W(useronlinekflink.c_str(), CP_UTF8); } return SStringW().Format(L"%s?email=%s&password=%s", S_CA2W(useronlinekflink.c_str(), CP_UTF8).GetBuffer(0), CManageNetWork::getSingletonPtr()->GetUsername(), CManageNetWork::getSingletonPtr()->GetPassWord()); } SStringW CSysConfig::GetAffLink() { if (user_tag == 1) { return S_CA2W(userattrlink.c_str(), CP_UTF8); } return SStringW().Format(L"%s?email=%s&password=%s", S_CA2W(userattrlink.c_str(), CP_UTF8).GetBuffer(0), CManageNetWork::getSingletonPtr()->GetUsername(), CManageNetWork::getSingletonPtr()->GetPassWord()); } SStringW CSysConfig::GetTutorialLink() { return S_CA2W(user_tutorial.c_str(), CP_UTF8).GetBuffer(0); }