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 04832f27
authored
Apr 08, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
录音上传
1 parent
f3158552
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
88 deletions
mixin/click.js
pages/index/index.vue
utils/cache/constantData.js
mixin/click.js
View file @
04832f2
...
...
@@ -2,51 +2,61 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-08 1
3:47:00
* @LastEditTime: 2024-04-08 1
6:38:43
* @FilePath: \gl_tape\mixin\click.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const
recorderManager
=
uni
.
getRecorderManager
();
import
upload
from
"@/utils/ossUploadFile/uploadFile.js"
;
export
default
{
data
()
{
return
{
voicePath
:
""
,
timer
:
null
,
times
:
0
,
timeout
:
10
*
60
,
reaction
:
10
,
message
:
"3"
,
};
},
onShow
()
{
window
.
addEventListener
(
"devicemotion"
,
this
.
handleDeviceMotion
);
},
onHide
()
{
window
.
removeEventListener
(
"devicemotion"
,
this
.
handleDeviceMotion
);
},
//
onShow() {
//
window.addEventListener("devicemotion", this.handleDeviceMotion);
//
},
//
onHide() {
//
window.removeEventListener("devicemotion", this.handleDeviceMotion);
//
},
created
()
{
recorderManager
.
start
();
this
.
initTime
();
document
.
addEventListener
(
"visibilitychange"
,
this
.
handleVisibilityChange
);
this
.
checkVoice
();
recorderManager
.
onStop
((
res
)
=>
{
uni
.
$storage
.
set
(
"storageFile"
,
res
.
tempFilePath
);
this
.
uploadVoice
(
res
.
tempFilePath
);
});
},
methods
:
{
handleDeviceMotion
(
event
)
{
let
acceleration
=
event
.
accelerationIncludingGravity
;
let
brightness
=
Math
.
abs
(
acceleration
.
x
)
+
Math
.
abs
(
acceleration
.
y
)
+
Math
.
abs
(
acceleration
.
z
);
if
(
brightness
<
10
)
{
// 假设<10的值代表屏幕可能变暗了
console
.
log
(
"屏幕可能熄灭了"
);
// 在这里执行你需要的操作
}
checkVoice
()
{
const
file
=
uni
.
$storage
.
get
(
"storageFile"
);
if
(
file
)
this
.
uploadVoice
(
file
);
},
uploadVoice
(
tempFilePath
)
{
upload
(
tempFilePath
).
then
((
res
)
=>
{
uni
.
$storage
.
set
(
"storageFile"
,
""
);
});
},
//开始录音
start
()
{
recorderManager
.
start
();
},
//结束录音
pause
()
{
recorderManager
.
stop
();
},
//监听点击事件
initTime
()
{
this
.
timer
=
setInterval
(()
=>
{
this
.
times
++
;
console
.
log
(
this
.
times
);
if
(
this
.
times
>=
this
.
timeout
)
{
this
.
showToast
();
//
this.showToast();
}
if
(
this
.
times
>=
this
.
reaction
+
this
.
timeout
)
{
this
.
handleEnd
();
...
...
@@ -56,12 +66,13 @@ export default {
handleTouchStart
()
{
this
.
times
=
0
;
},
},
handleVisibilityChange
()
{
if
(
document
.
visibilityState
===
"hidden"
)
{
// 屏幕被关闭
console
.
log
(
"Screen closed"
);
}
handleVisibilityChange
()
{
this
.
message
=
999
;
if
(
document
.
visibilityState
===
"hidden"
)
{
// 屏幕被关闭
this
.
message
=
999
;
}
},
},
beforeCreate
()
{
clearInterval
(
this
.
timer
);
...
...
pages/index/index.vue
View file @
04832f2
<
template
>
<view
class=
"content"
>
<image
class=
"logo"
src=
"/static/logo.png"
></image>
<view
class=
"text-area"
>
<text
class=
"title"
>
uView - 多平台快速开发的UI框架
</text>
</view>
<view
class=
"button-demo"
>
<u-button
type=
"primary"
plain
@
click=
"go()"
>
登录
</u-button>
</view>
</view>
<view
class=
"content"
>
<image
class=
"logo"
src=
"/static/logo.png"
></image>
<view
class=
"text-area"
>
<text
class=
"title"
>
{{
voicePath
}}
</text>
</view>
<view
class=
"button-demo"
>
<u-button
type=
"primary"
plain
@
click=
"start()"
>
开始
</u-button>
<u-button
type=
"primary"
plain
@
click=
"go()"
>
登录
</u-button>
</view>
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
title
:
'Hello'
,
}
},
onLoad
()
{
},
methods
:
{
go
()
{
this
.
$Router
.
push
({
name
:
'login'
})
}
}
}
import
myClick
from
"@/mixin/click"
;
export
default
{
mixins
:
[
myClick
],
data
()
{
return
{
title
:
"Hello"
,
};
},
onLoad
()
{},
methods
:
{
go
()
{
uni
.
navigateTo
({
url
:
"/pages/login/login"
,
success
:
function
(
res
)
{
// success
},
fail
:
function
()
{
// fail
},
complete
:
function
()
{
// complete
},
});
},
},
};
</
script
>
<
style
lang=
"scss"
scoped
>
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
padding
:
40
rpx
;
}
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
padding
:
40
rpx
;
}
.logo
{
height
:
200
rpx
;
width
:
200
rpx
;
margin-top
:
100
rpx
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-bottom
:
50
rpx
;
}
.logo
{
height
:
200
rpx
;
width
:
200
rpx
;
margin-top
:
100
rpx
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-bottom
:
50
rpx
;
}
.text-area
{
display
:
flex
;
justify-content
:
center
;
}
.text-area
{
display
:
flex
;
justify-content
:
center
;
}
.title
{
font-size
:
28
rpx
;
color
:
$
u-content-color
;
}
.title
{
font-size
:
28
rpx
;
color
:
$
u-content-color
;
}
.button-demo
{
margin-top
:
80
rpx
;
}
.button-demo
{
margin-top
:
80
rpx
;
}
</
style
>
utils/cache/constantData.js
View file @
04832f2
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
// import util from '~/utils/util'
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/app-tape/'
export
const
IMG_URL
=
"https://img02.glsx.com.cn/weapp/resource/app-tape/"
;
// 缓存get方法为空的默认指定值
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
export
const
DEFAULT_GET_STORAGEKEY
=
[
"sessionId"
,
"merchantId"
,
"userInfo"
];
// 缓存get方法key的对应才映射值
export
const
STORAGE_OBJECTkEY
=
{
DEFAULT_GET_STORAGEKEY
,
mock_data
:
'mock_data'
}
mock_data
:
"mock_data"
,
storageFile
:
"storageFile"
,
};
// export const IMG_VERSION = async () => {
// const accountInfo = await util.getMockData()
// return accountInfo?.version || Date.now()
// }
\ No newline at end of file
// }
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