| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import {TradeMode} from "@/common/constants/enumCommon";
- import {getSelectedAccountId, getUserId} from "@/services/bus/account";
- import {getMarketByTradeMode} from "@/services/bus/market";
- import {funCode} from "@/services/funcode";
- import {v4 as uuidv4} from 'uuid';
- import {IMessageHead} from "./proto";
- export enum HeadEnum {
- common, // funcode uuid userID
- AccountID, // funcode uuid userID AccountID
- MarketID18_GoodsID0, // funcode uuid userID, MarketID:18, GoodsID: 0
- MarketID15101,
- MarketID69201,
- MarketID45201,
- tradeMode17,
- tradeMode45
- }
- /**
- * // 站在 用户角度
- *
- * 设置 proto header 参数
- * @param funCodeName funCodeName
- * @param type HeadEnum
- */
- export function getProtoHeadParam(funCodeName: string, type: HeadEnum = 0): IMessageHead {
- const code = funCode[funCodeName];
- if (!code) console.error('没有找到对应的funCode值,请配置');
- let result: IMessageHead = {
- FunCode: code,
- UUID: uuidv4(),
- UserID: getUserId(),
- }
- switch (type) {
- case HeadEnum.common:
- break
- case HeadEnum.AccountID:
- result = Object.assign(result, {AccountID: getSelectedAccountId()})
- break
- case HeadEnum.MarketID18_GoodsID0:
- result = Object.assign(result, {
- MarketID: 18,
- GoodsID: 0,
- })
- break
- case HeadEnum.MarketID15101:
- result = Object.assign(result, {MarketID: 15101})
- break;
- case HeadEnum.MarketID69201:
- result = Object.assign(result, {MarketID: getMarketByTradeMode(TradeMode.Platinum)?.marketid,})
- break;
- case HeadEnum.tradeMode17:
- result = Object.assign(result, {MarketID: getMarketByTradeMode(TradeMode.WarehouseReceiptTrade)?.marketid,})
- break;
- case HeadEnum.tradeMode45:
- result = Object.assign(result, {MarketID: getMarketByTradeMode(TradeMode.Wrtrade)?.marketid,})
- break;
- case HeadEnum.MarketID45201:
- result = Object.assign(result, {MarketID: 45201})
- break;
- }
- return result
- }
|