From 3df9a404ec00528b956d69fcad4446ea55b70783 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 2 Mar 2022 21:32:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=A4=B1=E8=B4=A5=E6=8F=90=E7=A4=BA=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/common/js/request/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mobile/src/common/js/request/index.js b/mobile/src/common/js/request/index.js index 904452cfa4..075b89dbea 100644 --- a/mobile/src/common/js/request/index.js +++ b/mobile/src/common/js/request/index.js @@ -1,6 +1,6 @@ import axios from 'axios' import Config from '@/settings' -import { getToken, setToken, setUserInfo } from '@/common/utils' +import { getToken, setToken, setUserInfo, parseLanguage } from '@/common/utils' const TokenKey = Config.TokenKey const RefreshTokenKey = Config.RefreshTokenKey const white_list = Config.WHITE_LIST @@ -15,6 +15,17 @@ let service = axios.create({ // request interceptor service.interceptors.request.use( config => { + + let lang = parseLanguage() || uni.getLocale() + if (lang === 'en') { + config.headers['Accept-Language'] = 'en-US' + }else if(lang === 'zh-Hant'){ + config.headers['Accept-Language'] = 'zh-TW' + }else { + config.headers['Accept-Language'] = 'zh-CN' + } + + if (white_list.includes(config.url)) { return config }