From e491cdb48129752324c4e3764f99bd9203c56dec Mon Sep 17 00:00:00 2001
From: lgq <1015864684@qq.com>
Date: 星期二, 31 三月 2026 09:48:44 +0800
Subject: [PATCH] 1.新增VF205门禁机代码

---
 vf205_access/dxmodules/dxHttp.js |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 155 insertions(+), 0 deletions(-)

diff --git a/vf205_access/dxmodules/dxHttp.js b/vf205_access/dxmodules/dxHttp.js
new file mode 100644
index 0000000..f94b6d1
--- /dev/null
+++ b/vf205_access/dxmodules/dxHttp.js
@@ -0,0 +1,155 @@
+// http瀹㈡埛绔粍浠�
+import { httpClass } from './libvbar-m-dxhttp.so'
+
+const httpObj = new httpClass();
+
+const http = {
+
+    HTTP_METHOD : {
+        GET: "GET",
+        POST: "POST",
+        PUT: "PUT",
+        DELETE: "DELETE",
+        HEAD: "HEAD",
+        OPTIONS: "OPTIONS",
+        PATCH: "PATCH"
+    },
+    HTTP_FORMAT : {
+        JSON: "JSON",
+        FORM: "FORM",
+        URLENCODE: "URLENCODE"
+    },
+    HTTP_FORM_TYPE : {
+        STRING: "STRING",
+        FILE: "FILE"
+    },
+    /**
+     * get璇锋眰
+     * @param {string} url 
+     * @param {array} headers 闈炲繀濉紝浼氭湁榛樿濉厖 request headers
+     * @param {number} timeout 闈炲繀濉紝 瓒呮椂鏃堕棿
+     * @returns 
+     */
+    get: function (url, headers, timeout) {
+        if (!url) {
+            throw new Error("url should not be null or empty")
+        }
+        return httpObj.request({ method: 0, url: url, headers: headers, timeout: timeout})
+    },
+    /**
+     * post璇锋眰,data涓簀son/form琛ㄥ崟鏁扮粍鏍煎紡
+     * @param {string} url 
+     * @param {array} data
+     * @param {array} headers 闈炲繀濉紝浼氭湁榛樿濉厖 request headers 
+     * @param {number} timeout 闈炲繀濉紝 瓒呮椂鏃堕棿
+     * @returns 
+     */
+    post: function (url, data, headers, timeout, format = "JSON") {
+        if (!url) {
+            throw new Error("url should not be null or empty")
+        }
+        if (!data) {
+            throw new Error("data should not be null or empty")
+        }
+        if (typeof data != 'string' && format != "FORM") {
+            data = JSON.stringify(data)
+        }
+        if(format == "JSON"){
+            return httpObj.request({ method: 1, url: url, data: data, headers: headers, timeout: timeout})
+        }else{
+            return httpObj.request({ method: 1, url: url, formData: data, headers: headers, timeout: timeout})
+        }
+    },
+    /**
+     * put璇锋眰,data涓簀son/form琛ㄥ崟鏁扮粍鏍煎紡
+     * @param {string} url 
+     * @param {array} data
+     * @param {array} headers 闈炲繀濉紝浼氭湁榛樿濉厖 request headers 
+     * @param {number} timeout 闈炲繀濉紝 瓒呮椂鏃堕棿
+     * @returns 
+     */
+    put: function (url, data, headers, timeout, format = "JSON") {
+        if (!url) {
+            throw new Error("url should not be null or empty")
+        }
+        if (!data) {
+            throw new Error("data should not be null or empty")
+        }
+        if (typeof data != 'string' && format != "FORM") {
+            data = JSON.stringify(data)
+        }
+        if(format == "JSON"){
+            return httpObj.request({ method: 2, url: url, data: data, headers: headers, timeout: timeout})
+        }else{
+            return httpObj.request({ method: 2, url: url, formData: data, headers: headers, timeout: timeout})
+        }
+    },
+    /**
+     * delete璇锋眰
+     * @param {string} url 
+     * @param {array} headers 闈炲繀濉紝浼氭湁榛樿濉厖 request headers
+     * @param {number} timeout 闈炲繀濉紝 瓒呮椂鏃堕棿
+     * @returns 
+     */
+    delete: function (url, headers, timeout) {
+        if (!url) {
+            throw new Error("url should not be null or empty")
+        }
+        return httpObj.request({ method: 3, url: url, headers: headers, timeout: timeout})
+    },
+    /**
+     * 涓嬭浇鏂囦欢锛屾湰璐ㄦ槸get璇锋眰
+     * @param {string} url 
+     * @param {string} path 鐩爣璺緞(缁濆璺緞)
+     * @param {array} headers 闈炲繀濉紝浼氭湁榛樿濉厖 request headers
+     * @param {number} timeout 闈炲繀濉紝 瓒呮椂鏃堕棿
+     * @returns 涓嬭浇鏂囦欢鏈夊彲鑳借繑鍥瀗ull锛屼絾鏄笅杞芥槸鎴愬姛鐨�
+     */
+    download: function (url, path, headers, timeout) {
+        if (!url) {
+            throw new Error("url should not be null or empty")
+        }
+        if (!path) {
+            throw new Error("path should not be null or empty")
+        }
+        return httpObj.request({ method: 0, url: url, headers: headers, download: path, timeout: timeout })
+    },
+
+    /**
+     * 涓婁紶鏂囦欢锛屾湰璐ㄦ槸post璇锋眰
+     * @param {string} url 
+     * @param {string} path 婧愯矾寰�(缁濆璺緞)
+     * @returns 
+     */
+    upload: function (url, path) {
+        if (!url) {
+            throw new Error("url should not be null or empty")
+        }
+        if (!path) {
+            throw new Error("path should not be null or empty")
+        }
+        return httpObj.request({
+            method: 1,
+            url: url,
+            headers: ["application/x-www-form-urlencoded; charset=UTF-8"],
+            upload: path
+        })
+    },
+    /**
+     * 鍘熺敓鏂瑰紡
+     * 蹇呭~鍙傛暟锛歮ethod锛�0锛歡et璇锋眰锛�1锛歱ost璇锋眰锛夈�乽rl
+     * 鍙�夊弬鏁帮細headers(瀛楃涓叉暟缁勶紝瑕嗙洊榛樿header)銆乨ownload锛堟枃浠朵笅杞藉湴鍧�锛夈�乨ata(璇锋眰鎶ユ枃锛宲ost璇锋眰蹇呭~)銆乼imeout(瓒呮椂鏃堕棿/ms,缂虹渷:5000)銆乨ns(缂虹渷:"114.114.114.114,8.8.8.8")銆乽pload
+     * 榛樿header锛欰ccept-Charset:utf-8銆丆ontent-Type:application/json;charset=utf-8銆丆onnection:close
+     * @param {object} param json
+     *  濡傦細let param={
+                method:0,
+                url:"http://192.168.10.122:8000/DW200_1_0.zip",
+                download:"/testNet/aaa"
+            }
+     * @returns 
+     */
+    request: function (param) {
+        return httpObj.request(param)
+    }
+}
+export default http;

--
Gitblit v1.9.3