Browse Source

下证相关

徐勤民 2 months ago
parent
commit
b46ca97553

+ 4 - 11
src/main/ets/http/HttpHelper.ts

@@ -2,6 +2,7 @@ import { ArrayList, HashMap } from '@kit.ArkTS';
 import http from '@ohos.net.http';
 import { SZYXLocalStorageHelper } from '../utils/SZYXLocalStorageHelper';
 import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys';
+import { ToolsHelperForTS } from '../utils/ToolsHelperForTS';
 
 
 type HttpParamsGet = {
@@ -311,7 +312,7 @@ export class HttpHelper {
     if (query) {
       let q = query
       if (typeof query === 'object') {
-        q = this.classToRecord(query)
+        q = ToolsHelperForTS.classToRecord(query)
       }
       u = `${u}${u.indexOf('?') < 0 ? '?' : u.endsWith('$') ? '' : '&'}`
       Object.entries(q).forEach((row) => {
@@ -331,7 +332,7 @@ export class HttpHelper {
     let u = ''
     let q = data
     if (typeof data === 'object') {
-      q = this.classToRecord(data)
+      q = ToolsHelperForTS.classToRecord(data)
     }
     Object.entries(q).forEach((row) => {
       if (row[1]) {
@@ -342,13 +343,5 @@ export class HttpHelper {
     return u
   }
 
-  private classToRecord(obj: Object): Record<string, string> {
-    const record: Record<string, string> = {} as Record<string, string>;
-    for (const key in obj) {
-      if (obj.hasOwnProperty(key)) {
-        record[key] = obj[key];
-      }
-    }
-    return record;
-  }
+
 }

+ 1 - 0
src/main/ets/utils/ToolsHelper.ets

@@ -334,4 +334,5 @@ export class ToolsHelper {
     }
     return ToolsHelper.uniqueIdMap.get(fun)!;
   }
+
 }

+ 10 - 0
src/main/ets/utils/ToolsHelperForTS.ts

@@ -17,4 +17,14 @@ export class ToolsHelperForTS {
     }
     return myMap;
   }
+
+  public static  classToRecord(obj: Object): Record<string, string> {
+    const record: Record<string, string> = {} as Record<string, string>;
+    for (const key in obj) {
+      if (obj.hasOwnProperty(key)) {
+        record[key] = obj[key];
+      }
+    }
+    return record;
+  }
 }