Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 993b317a
authored
Apr 16, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化定时器
1 parent
35318a16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
41 deletions
mixin/click.js
utils/utils.js
mixin/click.js
View file @
993b317
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-1
1 22:13:22
* @LastEditTime: 2024-04-1
6 10:17:34
* @FilePath: \gl_tape\mixin\click.js
* @FilePath: \gl_tape\mixin\click.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -17,8 +17,8 @@ export default {
...
@@ -17,8 +17,8 @@ export default {
voicePath
:
""
,
voicePath
:
""
,
timer
:
null
,
timer
:
null
,
times
:
0
,
times
:
0
,
timeout
:
59
0
,
//十分钟提示
timeout
:
59
,
reaction
:
1
0
,
reaction
:
1
,
};
};
},
},
mounted
()
{
mounted
()
{
...
@@ -117,7 +117,13 @@ export default {
...
@@ -117,7 +117,13 @@ export default {
uni
.
$storage
.
set
(
"storageFile"
,
""
);
uni
.
$storage
.
set
(
"storageFile"
,
""
);
},
},
//开始录音
//开始录音
startAudio
()
{
async
startAudio
()
{
const
result
=
await
permision
.
requestAndroidPermission
(
"android.permission.RECORD_AUDIO"
);
if
(
result
!==
1
)
{
return
;
}
if
(
this
.
isStart
)
return
;
if
(
this
.
isStart
)
return
;
this
.
setAudioStart
(
true
);
this
.
setAudioStart
(
true
);
this
.
setAudioList
([]);
this
.
setAudioList
([]);
...
@@ -161,11 +167,12 @@ export default {
...
@@ -161,11 +167,12 @@ export default {
this
.
tipCancel
();
this
.
tipCancel
();
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
}
}
},
1000
);
},
1000
*
10
);
},
},
handleTouchStart
()
{
handleTouchStart
:
utils
.
debounce
(
function
()
{
this
.
times
=
0
;
this
.
times
=
0
;
},
console
.
log
(
1111
);
},
1000
*
10
),
},
},
beforeCreate
()
{
beforeCreate
()
{
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
...
...
utils/utils.js
View file @
993b317
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 17:16:46
* @Date: 2024-04-08 17:16:46
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-1
1 16:34:33
* @LastEditTime: 2024-04-1
6 10:13:29
* @FilePath: \gl_tape\utils\utils.js
* @FilePath: \gl_tape\utils\utils.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -51,42 +51,23 @@ function accDiv(arg1, arg2) {
...
@@ -51,42 +51,23 @@ function accDiv(arg1, arg2) {
r2
=
Number
(
arg2
.
toString
().
replace
(
"."
,
""
));
r2
=
Number
(
arg2
.
toString
().
replace
(
"."
,
""
));
return
(
r1
/
r2
)
*
Math
.
pow
(
10
,
t2
-
t1
);
return
(
r1
/
r2
)
*
Math
.
pow
(
10
,
t2
-
t1
);
}
}
function
requestAndroidPermission
()
{
function
debounce
(
fn
,
timer
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
t
=
null
plus
.
android
.
requestPermissions
(
return
function
()
{
[
"android.permission.RECORD"
,
"android.permission.CAMERA"
],
// 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
if
(
t
)
{
function
(
resultObj
)
{
clearTimeout
(
t
)
for
(
var
i
=
0
;
i
<
resultObj
.
granted
.
length
;
i
++
)
{
}
var
grantedPermission
=
resultObj
.
granted
[
i
];
if
(
t
==
null
)
{
result
=
1
;
fn
.
apply
(
this
,
arguments
)
console
.
log
(
"已获取的权限:"
+
result
);
}
}
t
=
setTimeout
(()
=>
{
for
(
var
i
=
0
;
i
<
resultObj
.
deniedPresent
.
length
;
i
++
)
{
t
=
null
var
deniedPresentPermission
=
resultObj
.
deniedPresent
[
i
];
},
timer
)
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
,
});
}
);
});
}
}
export
default
{
export
default
{
convertDateTimeFormat
,
convertDateTimeFormat
,
deepClone
,
deepClone
,
accDiv
,
accDiv
,
requestAndroidPermission
,
debounce
,
};
};
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment