index.ts 1.2 KB

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