Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sedu-mobile-v2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuzhanxin
sedu-mobile-v2
Commits
32fdc1ed
Commit
32fdc1ed
authored
Jun 30, 2020
by
liuzhanxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加语音识别前端
parent
ce425d2d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
317 additions
and
7 deletions
+317
-7
recording.vue
cloudTrain/components/voice-recognition/recording.vue
+201
-0
pages.json
cloudTrain/pages.json
+6
-0
scanCode.vue
cloudTrain/pages/Intelligent-Access/scanCode.vue
+63
-3
index.vue
cloudTrain/pages/Security-Check/index.vue
+12
-4
index.vue
cloudTrain/pages/Voice/index.vue
+27
-0
main.vue
cloudTrain/pages/main/main.vue
+8
-0
recording.png
cloudTrain/static/voice-recognition/recording.png
+0
-0
No files found.
cloudTrain/components/voice-recognition/recording.vue
0 → 100644
View file @
32fdc1ed
<
template
>
<div
class=
"recording"
>
<h6
class=
"recording-title"
>
长按进行输入
</h6>
<div
class=
"recording-box"
>
<canvas
canvas-id=
"canvas"
style=
"width:100px;height:100px;"
>
<span
class=
"recording-button"
@
touchstart=
"start"
@
touchmove=
"move"
@
touchend=
"end"
></span>
</canvas>
</div>
</div>
</
template
>
<
script
>
const
recorderManager
=
uni
.
getRecorderManager
();
export
default
{
props
:{
requestURL
:{
type
:
String
}
},
data
()
{
return
{
max
:
10000
,
// 录音最大时长,单位毫秒
frame
:
50
,
// 执行绘画的频率,单位毫秒
longTag
:
false
,
// 判定长按和点击的标识
maxTiming
:
false
,
// 最长录音时间的定时器
draw
:
undefined
,
seconds
:
'00'
,
ms
:
'00'
}
},
created
()
{
// 录音结束的事件监听
let
self
=
this
;
recorderManager
.
onStop
(
function
(
res
)
{
console
.
log
(
'recorder stop'
+
JSON
.
stringify
(
res
));
self
.
voicePath
=
res
.
tempFilePath
;
self
.
uploadVoice
();
});
},
methods
:
{
start
:
function
()
{
this
.
longTag
=
setTimeout
(
this
.
recording
,
200
);
// 定义超过500ms即为长按,可自行修改
},
move
:
function
()
{
// console.log("move")
// clearTimeout(this.longTag);
// clearTimeout(this.maxTiming);
// clearInterval(this.draw);
// this.longTag = false;
},
end
:
function
()
{
clearTimeout
(
this
.
longTag
);
clearTimeout
(
this
.
maxTiming
);
clearInterval
(
this
.
draw
);
if
(
this
.
longTag
)
{
// timeout不是false证明没有触发recording或者touchmove事件
console
.
log
(
'点击事件'
);
}
this
.
longTag
=
false
;
this
.
draw
=
false
;
let
angle
=
-
0.5
;
let
context
=
uni
.
createCanvasContext
(
'canvas'
);
context
.
beginPath
();
context
.
setStrokeStyle
(
"#1296db"
);
context
.
setLineWidth
(
3
);
context
.
arc
(
50
,
50
,
25
,
-
0.5
*
Math
.
PI
,
(
angle
+=
2
/
(
this
.
max
/
this
.
frame
))
*
Math
.
PI
,
false
);
context
.
stroke
();
context
.
draw
();
// 语音转换
this
.
send
();
},
recording
:
function
()
{
let
self
=
this
;
// 开始录音
this
.
longTag
=
false
;
recorderManager
.
start
();
console
.
log
(
'录音开始'
);
// 最大录音时间10秒
this
.
maxTiming
=
setTimeout
(
function
()
{
clearInterval
(
this
.
draw
);
console
.
log
(
'时间到'
);
// 语音转换
// self.send();
},
self
.
max
);
// 录音过程圆圈动画
let
angle
=
-
0.5
;
let
context
=
uni
.
createCanvasContext
(
'canvas'
);
this
.
draw
=
setInterval
(
function
()
{
context
.
beginPath
();
context
.
setStrokeStyle
(
"#1296db"
);
context
.
setLineWidth
(
3
);
context
.
arc
(
50
,
50
,
25
,
-
0.5
*
Math
.
PI
,
(
angle
+=
2
/
(
self
.
max
/
self
.
frame
))
*
Math
.
PI
,
false
);
context
.
stroke
();
context
.
draw
();
},
self
.
frame
);
},
send
:
function
()
{
recorderManager
.
stop
();
},
timing
:
function
()
{
let
self
=
this
;
},
reset
:
function
()
{
this
.
seconds
=
'00'
;
this
.
ms
=
'00'
;
},
uploadVoice
:
function
(){
var
belongId
=
this
.
GLOBALUTIL
.
guid2
();
var
datas
=
[]
datas
.
push
({
name
:
"file"
,
uri
:
this
.
voicePath
})
uni
.
uploadFile
({
url
:
this
.
requestURL
,
files
:
datas
,
filePath
:
this
.
voicePath
,
name
:
"file"
,
formData
:
{
'belongId'
:
belongId
},
header
:{
"x-auth-token"
:
this
.
GLOBALUTIL
.
commonHeader
[
"x-auth-token"
],
},
success
:
(
res
)
=>
{
console
.
log
(
JSON
.
stringify
(
res
))
uni
.
$emit
(
"voice-recognition"
,[])
}
})
},
}
}
</
script
>
<
style
scoped
>
.recording
{
position
:
absolute
;
top
:
0
;
bottom
:
0
;
left
:
0
;
right
:
0
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
flex-end
;
background
:
#E7E7E7
;
}
.recording-content
{
flex-grow
:
1
;
padding
:
10
upx
;
font-size
:
32
upx
;
color
:
#1296DB
;
background
:
#fff
;
}
.recording-title
{
padding
:
20
upx
;
text-align
:
center
;
font-size
:
32
upx
;
color
:
#1296DB
;
}
.recording-box
{
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
}
#canvas
{
position
:
relative
;
width
:
200
upx
;
height
:
200
upx
;
z-index
:
10
;
}
.recording-button
{
position
:
absolute
;
box-sizing
:
border-box
;
top
:
50
upx
;
left
:
50
upx
;
display
:
inline-block
;
width
:
100
upx
;
height
:
100
upx
;
border
:
1px
dashed
#1296DB
;
border-radius
:
100
upx
;
background
:
url(../../static/voice-recognition/recording.png)
no-repeat
50%
50%
;
background-size
:
50%
50%
;
z-index
:
100
;
}
.recording-time
{
text-align
:
center
;
font-size
:
40
upx
;
color
:
#1296db
;
}
</
style
>
cloudTrain/pages.json
View file @
32fdc1ed
...
@@ -321,6 +321,12 @@
...
@@ -321,6 +321,12 @@
}
}
}
}
}
}
},
{
"path"
:
"pages/Voice/index"
,
"style"
:
{
"navigationBarTitleText"
:
"语音"
}
}
}
],
],
"tabBar"
:
{
"tabBar"
:
{
...
...
cloudTrain/pages/Intelligent-Access/scanCode.vue
View file @
32fdc1ed
...
@@ -6,6 +6,15 @@
...
@@ -6,6 +6,15 @@
<view
class=
"scanButton"
hover-class=
"hover"
@
click=
"getEqStatus"
>
<view
class=
"scanButton"
hover-class=
"hover"
@
click=
"getEqStatus"
>
<text>
获取锁
</text>
<text>
获取锁
</text>
</view>
</view>
<view
class=
"scanButton"
hover-class=
"hover"
@
click=
"print"
>
<text>
打印
</text>
</view>
<view
class=
"scanButton"
hover-class=
"hover"
@
click=
"startVoice"
>
<text>
开始录音
</text>
</view>
<view
class=
"scanButton"
hover-class=
"hover"
@
click=
"endVoice"
>
<text>
结束录音
</text>
</view>
<view
v-if =
"showCardStatus"
v-for=
"news in deviceinfo"
:key=
"news.deviceNo"
class=
"scanButton"
hover-class=
"hover"
>
<view
v-if =
"showCardStatus"
v-for=
"news in deviceinfo"
:key=
"news.deviceNo"
class=
"scanButton"
hover-class=
"hover"
>
<text>
班牌编码:
{{
news
.
deviceNo
}}
</text>
<text>
班牌编码:
{{
news
.
deviceNo
}}
</text>
<text>
班牌状态
{{
news
.
statusName
}}
</text>
<text>
班牌状态
{{
news
.
statusName
}}
</text>
...
@@ -34,7 +43,9 @@
...
@@ -34,7 +43,9 @@
import
MescrollBody
from
"@/components/mescroll-uni/mescroll-body.vue"
import
MescrollBody
from
"@/components/mescroll-uni/mescroll-body.vue"
import
FormAlert
from
"@/components/form-alert/h-form-alert.vue"
import
FormAlert
from
"@/components/form-alert/h-form-alert.vue"
import
PopUp
from
"@/components/popup/popup.vue"
import
PopUp
from
"@/components/popup/popup.vue"
import
WebSkt
from
"./view-websocket.js"
import
WebSkt
from
"./view-websocket.js"
import
Print
from
"./blueToothPrint.js"
const
recorderManager
=
uni
.
getRecorderManager
();
export
default
{
export
default
{
mixins
:
[
MescrollMixin
],
mixins
:
[
MescrollMixin
],
data
()
{
data
()
{
...
@@ -54,7 +65,8 @@
...
@@ -54,7 +65,8 @@
showVideo
:
false
,
showVideo
:
false
,
cameraName
:
""
,
cameraName
:
""
,
deviceinfo
:[],
deviceinfo
:[],
previewSrc
:
""
previewSrc
:
""
,
voicePath
:
""
}
}
},
},
methods
:
{
methods
:
{
...
@@ -71,7 +83,25 @@
...
@@ -71,7 +83,25 @@
{
"deviceNo"
:
"301F9A601DB7"
}
{
"deviceNo"
:
"301F9A601DB7"
}
];
];
WebSkt
.
getEquipmentStatus
(
datas
);
WebSkt
.
getEquipmentStatus
(
datas
);
},
1000
)
},
1000
)
recorderManager
.
onStop
(
function
(
res
)
{
console
.
log
(
'recorder stop'
+
JSON
.
stringify
(
res
));
that
.
voicePath
=
res
.
tempFilePath
;
that
.
uploadVoice
();
});
},
print
(){
var
printerxmlSet
=
[];
var
printerxmlSetString
=
''
;
var
printerxml
=
'<Print><Type>1001</Type><Code>'
+
"abc"
+
'</Code><Text>'
+
"def"
+
'</Text><Text>名称:'
+
"gkh"
+
'</Text><Text>编号:'
+
"ppp"
+
'</Text><Text>部门:'
+
"ccc"
+
'</Text></Print>'
printerxmlSet
.
splice
(
printerxmlSet
.
length
,
0
,
printerxml
);
printerxmlSetString
=
printerxmlSet
.
join
(
''
);
const
printer
=
uni
.
requireNativePlugin
(
'Wewin-PrintPlugin'
);
printer
.
asyncPrint
({
xml
:
'<?xml version=
\
"1.0
\
" encoding=
\
"utf-8
\
" ?><Data>'
+
printerxmlSetString
+
'</Data>'
},
result
=>
{
console
.
log
(
result
);
})
},
},
getEqStatus
(){
getEqStatus
(){
var
datas
=
[
var
datas
=
[
...
@@ -135,6 +165,36 @@
...
@@ -135,6 +165,36 @@
},
},
});
});
},
},
startVoice
(){
recorderManager
.
start
();
},
endVoice
(){
recorderManager
.
stop
();
},
uploadVoice
(){
var
belongId
=
this
.
GLOBALUTIL
.
guid2
();
var
imgs
=
[]
imgs
.
push
({
name
:
"file"
,
uri
:
this
.
voicePath
})
uni
.
uploadFile
({
url
:
this
.
GLOBALUTIL
.
url
+
'/basis/attachments/files'
,
files
:
imgs
,
filePath
:
this
.
voicePath
,
name
:
"file"
,
formData
:
{
'belongId'
:
belongId
},
header
:{
"x-auth-token"
:
this
.
GLOBALUTIL
.
commonHeader
[
"x-auth-token"
],
// 'Content-Type': 'multipart/form-data',
},
success
:
(
res
)
=>
{
console
.
log
(
JSON
.
stringify
(
res
))
}
})
},
getEuqipmentStatus
(){
getEuqipmentStatus
(){
var
deviceInfo
=
WebSkt
.
getDeviceInfo
();
var
deviceInfo
=
WebSkt
.
getDeviceInfo
();
console
.
log
(
deviceInfo
)
console
.
log
(
deviceInfo
)
...
...
cloudTrain/pages/Security-Check/index.vue
View file @
32fdc1ed
...
@@ -231,10 +231,18 @@ import uniNavBar from "@/components/uni-header/uni-nav-bar/uni-nav-bar.vue"
...
@@ -231,10 +231,18 @@ import uniNavBar from "@/components/uni-header/uni-nav-bar/uni-nav-bar.vue"
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
// var uri = JSON.parse(res.data).data;
// var uri = JSON.parse(res.data).data;
console
.
log
(
res
)
console
.
log
(
res
)
console
.
log
(
JSON
.
stringify
(
res
))
if
(
res
.
statusCode
==
200
){
imgPath
.
map
((
opt
)
=>
{
imgPath
.
map
((
opt
)
=>
{
that
.
images
.
push
(
opt
)
that
.
images
.
push
(
opt
)
})
})
}
else
{
this
.
$refs
.
popup
.
open
({
type
:
'err'
,
content
:
'图片上传失败'
,
timeout
:
1000
,
isClick
:
false
});
}
}
}
})
})
},
},
...
...
cloudTrain/pages/Voice/index.vue
0 → 100644
View file @
32fdc1ed
<
template
>
<view
>
<Voice
requestURL=
"hpts"
>
</Voice>
</view>
</
template
>
<
script
>
import
Voice
from
"../../components/voice-recognition/recording.vue"
export
default
{
onLoad
()
{
console
.
log
(
'?d'
)
},
methods
:{
},
components
:{
Voice
}
}
</
script
>
<
style
>
</
style
>
cloudTrain/pages/main/main.vue
View file @
32fdc1ed
...
@@ -37,6 +37,9 @@
...
@@ -37,6 +37,9 @@
<button
hover-class=
"submithover"
@
click=
"scanCodeOpenDoor"
class=
"submit-button"
>
<button
hover-class=
"submithover"
@
click=
"scanCodeOpenDoor"
class=
"submit-button"
>
<text
class=
"submittext"
>
扫码开门
</text>
<text
class=
"submittext"
>
扫码开门
</text>
</button>
</button>
<button
hover-class=
"submithover"
@
click=
"voiceRecognition"
class=
"submit-button"
>
<text
class=
"submittext"
>
语音
</text>
</button>
</view>
</view>
</view>
</view>
</
template
>
</
template
>
...
@@ -114,6 +117,11 @@
...
@@ -114,6 +117,11 @@
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
"../Approval/list"
url
:
"../Approval/list"
})
})
},
voiceRecognition
(){
uni
.
navigateTo
({
url
:
"../Voice/index"
})
}
}
}
}
}
}
...
...
cloudTrain/static/voice-recognition/recording.png
0 → 100644
View file @
32fdc1ed
3.34 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment