diff --git a/common/untool.js b/common/untool.js index f29b454..f3e2102 100644 --- a/common/untool.js +++ b/common/untool.js @@ -199,6 +199,39 @@ const canvasGetImageData = (params = {})=> { }) } +const uniPromiseApi = (name, options = {}, extObj = { })=> { + return new Promise((resolve, reject)=> { + if(!(uni?.[name])) { + console.error(`uni.${name} api不存在 `) + return reject(`uni.${name} api不存在`) + } + uni?.[name]?.({ + ...options, + success(res){ + console.error(`uni.${name} -execResult:success====`, res) + resolve({ res }) + if(extObj.successText) { + showToast(successText) + } + }, + fail(err){ + console.error(`uni.${name} -execResult:fail====`, err) + resolve({ err }) + if(extObj.failText) { + showToast(failText) + } + } + }) + }) +} + +const promiseTimeout = (time) => { + return new Promise((resolve, reject)=> { + setTimeout(()=> { + resolve() + }, time) + }) +} export { reLaunch, @@ -216,5 +249,7 @@ export { saveFile, getImageTempFilePath, canvasGetImageData, - getImageInfo + getImageInfo, + uniPromiseApi, + promiseTimeout, } diff --git a/common/util.js b/common/util.js index 147f76b..1020bd3 100644 --- a/common/util.js +++ b/common/util.js @@ -179,6 +179,7 @@ const textDecoder = (input)=> { return decodeURIComponent(escape(String.fromCharCode(...[input]))); } + export { getAddressDetail, setAddresModalParam, @@ -190,5 +191,5 @@ export { debounce, throttle, textEncoder, - textDecoder + textDecoder, } diff --git a/components/tpx-bluetooth/tpx-bluetooth.vue b/components/tpx-bluetooth/tpx-bluetooth.vue index 017741c..6b3c4f4 100644 --- a/components/tpx-bluetooth/tpx-bluetooth.vue +++ b/components/tpx-bluetooth/tpx-bluetooth.vue @@ -98,7 +98,7 @@