respgetrecommendseg.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "respgetrecommendseg.h"
  2. #include <QScriptValue>
  3. #include <QScriptEngine>
  4. #include <QScriptValueIterator>
  5. RespGetRecommendSeg::RespGetRecommendSeg(QString json)
  6. {
  7. this->json = json;
  8. QScriptEngine engine;
  9. QScriptValue sv = engine.evaluate("value = " + this->json);
  10. QScriptValueIterator it(sv);
  11. if(json.isEmpty())
  12. {
  13. rtnCode = RTNCODE_NETWORK_NOTAVAILABLE;
  14. rtnMemo = RTNMEMO_NETWORK_NOTAVAILABLE;
  15. }
  16. else if(json=="ABORT")
  17. {
  18. rtnCode = RTNCODE_NETWORK_ABORT;
  19. rtnMemo = RTNMEMO_NETWORK_ABORT;
  20. }
  21. else
  22. {
  23. rtnCode = RTNCODE_INVALID_FORMAT;
  24. rtnMemo = RTNMEMO_INVALID_FORMAT;
  25. while (it.hasNext())
  26. {
  27. it.next();
  28. if(it.name()=="rtnCode")
  29. {
  30. this->rtnCode = it.value().toInt32();
  31. }
  32. else if(it.name()=="rtnMemo")
  33. {
  34. this->rtnMemo = it.value().toString();
  35. }
  36. else if(it.name()=="segInfo")
  37. {
  38. this->segInfo = it.value().toString();
  39. }
  40. else if(it.name()=="fcEncryptParam")
  41. {
  42. this->fcEncryptParam = it.value().toString();
  43. }
  44. }
  45. }
  46. }
  47. int RespGetRecommendSeg::getRtnCode()
  48. {
  49. return this->rtnCode;
  50. }
  51. QString RespGetRecommendSeg::getRtnMemo()
  52. {
  53. return this->rtnMemo;
  54. }
  55. QString RespGetRecommendSeg::getSegRecInfo()
  56. {
  57. return this->segInfo;
  58. }
  59. QString RespGetRecommendSeg::getFcEncryptParam()
  60. {
  61. return this->fcEncryptParam;
  62. }