index.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import APP from "@/services";
  2. import { getSelectedAccountId, getUserId } from "@/services/bus/account";
  3. import { ErmcpContractOperateApplyReq } from "@/services/proto/contract/interface";
  4. import { buildProtoReq50, parseProtoRsp50 } from "@/services/socket/protobuf/buildReq";
  5. import { getUUID } from "@/utils/qt/common";
  6. import { Callback } from "@/utils/websocket";
  7. /**
  8. * 合同
  9. * @param param
  10. */
  11. export const operationContractReq = (param: ErmcpContractOperateApplyReq): Promise<any> => {
  12. const OperateSrc = 2;
  13. const UserID = getUserId()
  14. const ClientTicket = getUUID()
  15. const OperateApplyID = getUUID()
  16. return new Promise((resolve, reject) => {
  17. const params = {
  18. protobufName: 'ErmcpContractOperateApplyReq',
  19. funCodeName: 'ErmcpContractOperateApplyReq',
  20. reqParams: { OperateApplyID, OperateSrc, UserID, ClientTicket, ...param },
  21. msgHeadParams: {
  22. AccountID: getSelectedAccountId(),
  23. MarketID: 18,
  24. GoodsID: 0,
  25. }
  26. };
  27. const package50 = buildProtoReq50(params);
  28. APP.sendTradingServer(package50, undefined, {
  29. onSuccess: (res) => {
  30. const { isSuccess, result } = parseProtoRsp50(res, 'ErmcpContractOperateApplyRsp');
  31. if (isSuccess) {
  32. resolve(result);
  33. } else {
  34. reject(result);
  35. }
  36. },
  37. onFail: (err) => reject(err.message)
  38. } as Callback);
  39. });
  40. }