diff --git a/sheep/request/index.js b/sheep/request/index.js index 50ac2dea..492f08c9 100644 --- a/sheep/request/index.js +++ b/sheep/request/index.js @@ -9,7 +9,7 @@ import $store from '@/sheep/store'; import $platform from '@/sheep/platform'; import { showAuthModal } from '@/sheep/hooks/useModal'; import AuthUtil from '@/sheep/api/member/auth'; -import { getTerminalEnumByUniPlatform } from '@/sheep/util/const'; +import { getTerminal } from '@/sheep/util/const'; const options = { // 显示操作成功消息 默认不显示 @@ -94,9 +94,7 @@ http.interceptors.request.use( if (token) { config.header['Authorization'] = token; } - - const terminalType = uni.getSystemInfoSync().uniPlatform - config.header['terminal'] = getTerminalEnumByUniPlatform(terminalType); + config.header['terminal'] = getTerminal(); config.header['Accept'] = '*/*'; config.header['tenant-id'] = tenantId; diff --git a/sheep/util/const.js b/sheep/util/const.js index 4339ef90..9cf98bf3 100644 --- a/sheep/util/const.js +++ b/sheep/util/const.js @@ -12,26 +12,23 @@ export const TerminalEnum = { }; /** - * 将Uniapp提供的平台转换为后端所需的Terminal值 - * @param platformType Uniapp提供的平台类型 + * 将 uni-app 提供的平台转换为后端所需的 terminal值 + * + * @return 终端 */ -export const getTerminalEnumByUniPlatform = (platformType) => { - let terminal; +export const getTerminal = () => { + const platformType = uni.getSystemInfoSync().uniPlatform; // 与后端terminal枚举一一对应 switch (platformType) { case 'app': - terminal = TerminalEnum.APP; - break; + return TerminalEnum.APP; case 'web': - terminal = TerminalEnum.H5; - break; + return TerminalEnum.H5; case 'mp-weixin': - terminal = TerminalEnum.WECHAT_MINI_PROGRAM; - break; + return TerminalEnum.WECHAT_MINI_PROGRAM; default: - terminal = TerminalEnum.UNKNOWN; + return TerminalEnum.UNKNOWN; } - return terminal; }; // ========== MALL - 营销模块 ==========