加解密支持

This commit is contained in:
尹吉欢
2018-05-28 17:34:20 +08:00
parent c73704dde2
commit 195ddf2f77
42 changed files with 6256 additions and 19 deletions
+8
View File
@@ -11,6 +11,10 @@ document.addEventListener('plusready', function() {
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
// 对所有POST请加密,必须是json数据提交,不支持表单
if (config.method == "post") {
config.data = EncryptData(JSON.stringify(config.data));
}
var token = localStorage.getItem("user_token");
config.headers.Authorization = token;
config.headers.appVersion = localVersion;
@@ -26,6 +30,10 @@ axios.interceptors.response.use(function (response) {
}catch(e){
}
// 返回字符串表示需要解密操作
if(typeof(response.data) == "string"){
response.data = DecryptData(response.data);
}
return response;
}, function (error) {
try {