| | |
| | | data, |
| | | method, |
| | | }) { |
| | | if(this.requestLock){ |
| | | console.warn("该请求被锁定,不能重复请求!!!") |
| | | if (this.requestLock) { |
| | | console.log("该请求被锁定,不能重复请求!!!") |
| | | return |
| | | } |
| | | |
| | | this.requestLock = true |
| | | return new Promise((resolve, reject) => { |
| | | // that = that || this; |
| | |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | 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"; |
| | |
| | | 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(); |
| | | }) |
| | | } |
| | |
| | | // } |
| | | |
| | | |
| | | 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) => { |