zrg
2025-10-31 06efefc91964328be8800df03cb56ed3595b74f2
utils/common.js
@@ -311,11 +311,10 @@
        data,
        method,
    }) {
        if(this.requestLock){
            console.warn("该请求被锁定,不能重复请求!!!")
        if (this.requestLock) {
            console.log("该请求被锁定,不能重复请求!!!")
            return
        }
        this.requestLock = true
        return new Promise((resolve, reject) => {
            // that = that || this;
@@ -341,6 +340,35 @@
            })
        })
    }
    async doRequest2Async({
        url,
        data,
        method,
    }) {
        return new Promise((resolve, reject) => {
            // that = that || this;
            let errorTip = null;
            uni.showLoading({
                title: '加载中...'
            })
            uni.request({
                method: method || "GET",
                url: this.serverUrl + url,
                data: data || "",
                success: (res) => {
                    resolve(res)
                },
                fail: (err) => {
                    reject(err)
                },
                complete: () => {
                    uni.hideLoading()
                }
            })
        })
    }
    stringToBoolean(str) {
        // 忽略大小写的转换
        return str?.toLowerCase() === "true";
@@ -357,14 +385,14 @@
        innerAudioContext.play(); // 播放音频
        innerAudioContext.onPlay(() => {
            console.log('开始播放');
            //console.log('开始播放');
        });
        innerAudioContext.onError((res) => {
            console.log(res.errMsg);
            console.log(res.errCode);
        });
        innerAudioContext.onPause(function() {
            console.log('播放出现错误,销毁');
            //console.log('播放暂停,销毁');
            innerAudioContext.destroy();
        })
    }
@@ -400,6 +428,29 @@
    // }
    showTips({
        type,
        message,
        title,
        duration
    }) {
        if (!message) {
            return
        }
        if (message.length < 20) {
            return uni.showToast({
                icon: type || 'none',
                title: message
            })
        }
        return uni.showModal({
            title: title,
            content: message,
            showCancel: false
        })
    }
    replaceWithFunction(str, handler) {
        return str.replace(/\{(.+?)\}/g, (match, key) => {