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 c91354d1
authored
Apr 09, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
录音分段
1 parent
f5a85a2a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
41 deletions
mixin/click.js
store/index.js
store/modules/audio.js
mixin/click.js
View file @
c91354d
...
@@ -2,20 +2,16 @@
...
@@ -2,20 +2,16 @@
* @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-0
8 19:00:44
* @LastEditTime: 2024-04-0
9 13:36:48
* @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
*/
*/
const
recorderManager
=
uni
.
getRecorderManager
();
const
recorderManager
=
uni
.
getRecorderManager
();
let
recording
=
false
,
receptionStartTime
,
receptionEndTime
;
//是否录音中
import
upload
from
"@/utils/ossUploadFile/uploadFile.js"
;
import
upload
from
"@/utils/ossUploadFile/uploadFile.js"
;
import
utils
from
"@/utils/utils
"
;
import
{
mapMutations
,
mapState
}
from
"vuex
"
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
isStart
:
false
,
voicePath
:
""
,
voicePath
:
""
,
timer
:
null
,
timer
:
null
,
times
:
0
,
times
:
0
,
...
@@ -24,60 +20,72 @@ export default {
...
@@ -24,60 +20,72 @@ export default {
message
:
"3"
,
message
:
"3"
,
};
};
},
},
// onShow() {
mounted
()
{
// window.addEventListener("devicemotion", this.handleDeviceMotion);
// },
// onHide() {
// window.removeEventListener("devicemotion", this.handleDeviceMotion);
// },
created
()
{
this
.
initTime
();
this
.
initTime
();
this
.
checkVoice
();
this
.
checkVoice
();
recorderManager
.
onStop
((
res
)
=>
{
},
recording
=
false
;
computed
:
{
receptionEndTime
=
utils
.
convertDateTimeFormat
(
new
Date
(),
"/"
);
...
mapState
(
"audio"
,
[
uni
.
$storage
.
set
(
"storageFile"
,
res
.
tempFilePath
);
"isEnd"
,
this
.
uploadVoice
(
res
.
tempFilePath
);
"audioList"
,
});
"isStart"
,
recorderManager
.
onStart
(()
=>
{
"receptionEndTime"
,
recording
=
true
;
"receptionStartTime"
,
receptionStartTime
=
utils
.
convertDateTimeFormat
(
new
Date
(),
"/"
);
]),
});
if
(
recording
)
this
.
isStart
=
true
;
},
},
methods
:
{
methods
:
{
...
mapMutations
(
"audio"
,
[
"setAudioStart"
,
"setAudioList"
,
"setAudioEnd"
]),
//检查缓存录音
checkVoice
()
{
checkVoice
()
{
const
file
=
uni
.
$storage
.
get
(
"storageFile"
);
const
file
=
uni
.
$storage
.
get
(
"storageFile"
);
if
(
file
)
this
.
uploadVoice
(
file
);
if
(
file
)
this
.
uploadVoice
(
file
);
},
},
//保存录音记录及其他信息
async
uploadVoice
(
tempFilePath
)
{
async
uploadVoice
(
tempFilePath
)
{
console
.
log
(
88888
,
99
);
const
{
phone
,
merchantId
,
uuid
,
name
}
=
uni
.
$storage
.
get
(
"userInfo"
),
const
result
=
await
upload
(
tempFilePath
),
params
=
{
{
phone
,
merchantId
,
uuid
,
name
}
=
uni
.
$storage
.
get
(
"userInfo"
);
uni
.
$api
.
commonApi
.
saveRecCustomer
({
carModel
:
"问界"
,
carModel
:
"问界"
,
customerName
:
name
,
customerName
:
name
,
phoneNumber
:
phone
,
phoneNumber
:
phone
,
loginPhone
:
phone
,
loginPhone
:
phone
,
salesUuid
:
uuid
,
salesUuid
:
uuid
,
recordUrl
:
result
,
recordUrl
List
:
tempFilePath
,
receptionStartTime
,
receptionStartTime
:
this
.
receptionEndTime
,
receptionEndTime
,
receptionEndTime
:
this
.
receptionEndTime
,
merchantId
,
merchantId
,
})
};
.
then
((
res
)
=>
{
console
.
log
(
params
,
"params"
);
uni
.
$api
.
commonApi
.
saveRecCustomer
(
params
).
then
((
res
)
=>
{
console
.
log
(
res
);
console
.
log
(
res
);
});
});
uni
.
$storage
.
set
(
"storageFile"
,
""
);
uni
.
$storage
.
set
(
"storageFile"
,
""
);
},
},
//开始录音
//开始录音
startAudio
()
{
startAudio
()
{
if
(
recording
)
true
;
if
(
this
.
isStart
)
return
;
recorderManager
.
start
();
this
.
setAudioStart
(
true
);
this
.
setAudioList
([]);
this
.
setAudioEnd
(
false
);
recorderManager
.
start
({
duration
:
600000
,
});
recorderManager
.
onStop
(
async
(
res
)
=>
{
if
(
!
this
.
isEnd
)
{
recorderManager
.
start
({
duration
:
600000
,
});
}
const
result
=
await
upload
(
res
.
tempFilePath
);
const
storageFile
=
[...
this
.
audioList
,
result
];
uni
.
$storage
.
set
(
"storageFile"
,
storageFile
);
this
.
setAudioList
(
storageFile
);
if
(
this
.
isEnd
)
this
.
uploadVoice
(
storageFile
);
});
},
},
//结束录音
//结束录音
stopAudio
()
{
stopAudio
()
{
this
.
setAudioStart
(
false
);
this
.
setAudioEnd
(
true
);
recorderManager
.
stop
();
recorderManager
.
stop
();
},
},
//监听点击事件
//监听点击事件
...
...
store/index.js
View file @
c91354d
import
Vue
from
'vue'
;
/*
import
Vuex
from
'vuex'
;
* @Author: 前端 qianduan01@didihu.com.cn
import
getters
from
'./getters'
;
* @Date: 2024-04-07 17:09:50
import
user
from
'./modules/user'
;
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-09 10:08:11
* @FilePath: \gl_tape\store\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import
Vue
from
"vue"
;
import
Vuex
from
"vuex"
;
import
getters
from
"./getters"
;
import
user
from
"./modules/user"
;
import
audio
from
"./modules/audio"
;
Vue
.
use
(
Vuex
);
Vue
.
use
(
Vuex
);
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
modules
:
{
modules
:
{
user
,
user
,
audio
,
},
},
getters
,
getters
,
});
});
...
...
store/modules/audio.js
0 → 100644
View file @
c91354d
/*
* @Description:
* @Author: huyue
* @Date: 2024-04-07 18:15:11
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-04-09 11:31:38
*/
// import { setToken, getToken, removeToken } from '@/utils/token';;
import
utils
from
"@/utils/utils"
;
export
default
{
namespaced
:
true
,
state
()
{
return
{
audioList
:
[],
isStart
:
false
,
isEnd
:
false
,
receptionStartTime
:
""
,
receptionEndTime
:
""
,
};
},
mutations
:
{
setAudioList
(
state
,
data
)
{
state
.
audioList
=
data
;
},
setAudioStart
(
state
,
data
)
{
state
.
isStart
=
data
;
if
(
data
)
state
.
receptionStartTime
=
utils
.
convertDateTimeFormat
(
new
Date
(),
"/"
);
},
setAudioEnd
(
state
,
data
)
{
state
.
isEnd
=
data
;
if
(
data
)
state
.
receptionEndTime
=
utils
.
convertDateTimeFormat
(
new
Date
(),
"/"
);
},
},
};
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