Commit 993b317a by 前端

优化定时器

1 parent 35318a16
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-11 22:13:22
* @LastEditTime: 2024-04-16 10:17:34
* @FilePath: \gl_tape\mixin\click.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -17,8 +17,8 @@ export default {
voicePath: "",
timer: null,
times: 0,
timeout: 590, //十分钟提示
reaction: 10,
timeout: 59,
reaction: 1,
};
},
mounted() {
......@@ -117,7 +117,13 @@ export default {
uni.$storage.set("storageFile", "");
},
//开始录音
startAudio() {
async startAudio() {
const result = await permision.requestAndroidPermission(
"android.permission.RECORD_AUDIO"
);
if (result !== 1) {
return;
}
if (this.isStart) return;
this.setAudioStart(true);
this.setAudioList([]);
......@@ -161,11 +167,12 @@ export default {
this.tipCancel();
clearInterval(this.timer);
}
}, 1000);
}, 1000 * 10);
},
handleTouchStart() {
handleTouchStart: utils.debounce(function () {
this.times = 0;
},
console.log(1111);
}, 1000 * 10),
},
beforeCreate() {
clearInterval(this.timer);
......
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 17:16:46
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-11 16:34:33
* @LastEditTime: 2024-04-16 10:13:29
* @FilePath: \gl_tape\utils\utils.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -51,42 +51,23 @@ function accDiv(arg1, arg2) {
r2 = Number(arg2.toString().replace(".", ""));
return (r1 / r2) * Math.pow(10, t2 - t1);
}
function requestAndroidPermission() {
return new Promise((resolve, reject) => {
plus.android.requestPermissions(
["android.permission.RECORD", "android.permission.CAMERA"], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
function (resultObj) {
for (var i = 0; i < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i];
result = 1;
console.log("已获取的权限:" + result);
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
var deniedPresentPermission = resultObj.deniedPresent[i];
result = 0;
console.log("拒绝本次申请的权限:" + result);
}
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
var deniedAlwaysPermission = resultObj.deniedAlways[i];
result = -1;
console.log("永久拒绝申请的权限:" + result);
}
resolve(result);
// 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
},
function (error) {
console.log("申请权限错误:" + error.code + " = " + error.message);
resolve({
code: error.code,
message: error.message,
});
}
);
});
function debounce(fn, timer) {
var t = null
return function () {
if (t) {
clearTimeout(t)
}
if (t == null) {
fn.apply(this, arguments)
}
t = setTimeout(() => {
t = null
}, timer)
}
}
export default {
convertDateTimeFormat,
deepClone,
accDiv,
requestAndroidPermission,
debounce,
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!