import APP from "@/services"; import { getSelectedAccountId, getUserId } from "@/services/bus/account"; import { ErmcpContractOperateApplyReq } from "@/services/proto/contract/interface"; import { buildProtoReq50, parseProtoRsp50 } from "@/services/socket/protobuf/buildReq"; import { getUUID } from "@/utils/qt/common"; import { Callback } from "@/utils/websocket"; /** * 合同 * @param param */ export const operationContractReq = (param: ErmcpContractOperateApplyReq): Promise => { const OperateSrc = 2; const UserID = getUserId() const ClientTicket = getUUID() const OperateApplyID = getUUID() return new Promise((resolve, reject) => { const params = { protobufName: 'ErmcpContractOperateApplyReq', funCodeName: 'ErmcpContractOperateApplyReq', reqParams: { OperateApplyID, OperateSrc, UserID, ClientTicket, ...param }, msgHeadParams: { AccountID: getSelectedAccountId(), MarketID: 18, GoodsID: 0, } }; const package50 = buildProtoReq50(params); APP.sendTradingServer(package50, undefined, { onSuccess: (res) => { const { isSuccess, result } = parseProtoRsp50(res, 'ErmcpContractOperateApplyRsp'); if (isSuccess) { resolve(result); } else { reject(result); } }, onFail: (err) => reject(err.message) } as Callback); }); }