Browse Source

上传头像解密

Karsa 2 years ago
parent
commit
b538b81867
1 changed files with 3 additions and 1 deletions
  1. 3 1
      utils/upload.js

+ 3 - 1
utils/upload.js

@@ -5,11 +5,13 @@
 import uniAsync from "@/utils/uni-async.js"; // uni api async 化
 import {baseApiUrl} from './config.js'
 import store from '@/store/index.js'
+import CryptoJS from './crypto.js'
 
 /**
  * 上传文件到服务器
  */
 export const uploadToServer = async (tempFilePath) => {
+	const { envVersion } = uni.getAccountInfoSync().miniProgram
   const temres = await uniAsync.uploadFile({
     url: baseApiUrl + "/public/upload",
     filePath: tempFilePath,
@@ -18,7 +20,7 @@ export const uploadToServer = async (tempFilePath) => {
       Authorization: store.state.user.token,
     },
   });
-  const res = JSON.parse(temres.data);
+  const res =  envVersion === 'release' ? JSON.parse(CryptoJS.Des3Decrypt(temres.data)) :  JSON.parse(temres.data);
   if (res.code === 200) {
     return res.data;
   }