From 64670054fd983315a8d9399b03ce0dcbd3a512ac Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Mon, 13 May 2024 16:03:12 +0800 Subject: [PATCH] =?UTF-8?q?uu=E3=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/untool.js | 37 +++- common/util.js | 3 +- components/tpx-bluetooth/tpx-bluetooth.vue | 214 ++++++++------------- 3 files changed, 118 insertions(+), 136 deletions(-) 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 @@