yusijie
2026-03-30 21c2a7c125a5d07ad87fd7a266a697f61d0fdefd
utils/common.js
@@ -211,6 +211,7 @@
            method: method || "GET",
            url: this.serverUrl + url,
            data: data || "",
            // header: this.getHeader(),
            success: (res) => {
                if (typeof resFunction === 'function') {
                    resFunction.call(that, res)
@@ -266,6 +267,7 @@
            method: method || "GET",
            url: this.serverUrl + url,
            data: data || "",
            // header: this.getHeader(),
            success: (res) => {
                if (typeof resFunction === 'function') {
                    resFunction.call(that, res)
@@ -326,6 +328,7 @@
                method: method || "GET",
                url: this.serverUrl + url,
                data: data || "",
                // header: this.getHeader(),
                success: (res) => {
                    resolve(res)
                },
@@ -345,17 +348,22 @@
        url,
        data,
        method,
        showLoading = true,
    }) {
        return new Promise((resolve, reject) => {
            // that = that || this;
            let errorTip = null;
            if (showLoading) {
            uni.showLoading({
                title: '加载中...'
            })
            }
            uni.request({
                method: method || "GET",
                url: this.serverUrl + url,
                data: data || "",
                // header: this.getHeader(),
                success: (res) => {
                    resolve(res)
                },
@@ -363,7 +371,9 @@
                    reject(err)
                },
                complete: () => {
                    if (showLoading) {
                    uni.hideLoading()
                    }
                }
            })
        })
@@ -460,7 +470,11 @@
        });
    }
    
    fieldListFilterRole({FieldList, ExcludeKeys = [] ,RoleList = null}) {
    fieldListFilterRole({
        FieldList,
        ExcludeKeys = [],
        RoleList = null
    }) {
        if(!RoleList) {
            RoleList = [
                /^[a-zA-Z]+$/,
@@ -515,7 +529,16 @@
        return httpUrl
    }
    
    getHeader() {
        let header = {}
        let Token = uni.getStorageSync("Token")
    
        if (Token) {
            header['Authorization'] = `Bearer ${uni.getStorageSync("Token")}`
        }
        return header
    }
}
export const CommonUtils = new commonUtils()