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 c768fdb2
authored
Jun 07, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化上传录音
1 parent
1c891cf3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
61 deletions
mixin/click.js
pages/boutique/invitation.vue
store/modules/audio.js
mixin/click.js
View file @
c768fdb
...
@@ -31,16 +31,7 @@ export default {
...
@@ -31,16 +31,7 @@ export default {
// this.checkVoice();
// this.checkVoice();
},
},
computed
:
{
computed
:
{
...
mapState
(
"audio"
,
[
...
mapState
(
"audio"
,
[
"receptionStatus"
,
"booksList"
,
"audioInfo"
]),
"isEnd"
,
"receptionStatus"
,
"endReasonType"
,
"booksList"
,
"audioList"
,
"isStart"
,
"receptionEndTime"
,
"receptionStartTime"
,
]),
...
mapState
([
"user.customerInfo"
]),
...
mapState
([
"user.customerInfo"
]),
},
},
created
()
{
created
()
{
...
@@ -68,17 +59,14 @@ export default {
...
@@ -68,17 +59,14 @@ export default {
methods
:
{
methods
:
{
...
mapMutations
(
"audio"
,
[
...
mapMutations
(
"audio"
,
[
"setReceptionStatus"
,
"setReceptionStatus"
,
"setReasonType"
,
"setAudioStart"
,
"setAudioList"
,
"setAudioEnd"
,
"setBooks"
,
"setBooks"
,
"setAudioInfo"
,
]),
]),
//关闭提示
//关闭提示
tipCancel
()
{
tipCancel
()
{
this
.
stopAudio
();
this
.
stopAudio
();
this
.
setReceptionStatus
(
0
);
this
.
setReceptionStatus
(
0
);
this
.
set
ReasonType
(
1
);
this
.
set
AudioInfo
({
endReasonType
:
1
}
);
this
.
$refs
.
tipBox
.
close
();
this
.
$refs
.
tipBox
.
close
();
let
{
sceneType
}
=
uni
.
$storage
.
get
(
"userInfo"
);
let
{
sceneType
}
=
uni
.
$storage
.
get
(
"userInfo"
);
uni
.
reLaunch
({
uni
.
reLaunch
({
...
@@ -106,17 +94,19 @@ export default {
...
@@ -106,17 +94,19 @@ export default {
sourceUrl
:
item
.
imgUrl
,
sourceUrl
:
item
.
imgUrl
,
};
};
}),
}),
{
receptionStartTime
,
receptionEndTime
,
endReasonType
}
=
this
.
audioInfo
,
params
=
{
params
=
{
carModel
,
carModel
,
endReasonType
:
this
.
endReasonType
,
//原因 1.异常 0.正常
endReasonType
,
//原因 1.异常 0.正常
customerName
,
customerName
,
phoneNumber
,
phoneNumber
,
loginPhone
:
phone
,
loginPhone
:
phone
,
salesName
:
staffName
,
salesName
:
staffName
,
salesUuid
,
salesUuid
,
receptionStatus
:
this
.
receptionStatus
,
//接待结果 1.成交 0.战败
receptionStatus
:
this
.
receptionStatus
,
//接待结果 1.成交 0.战败
receptionStartTime
:
this
.
receptionStartTime
,
receptionStartTime
,
receptionEndTime
:
this
.
receptionEndTime
,
receptionEndTime
,
receptionCustomerPaySourceList
,
//1.付款凭证文件路径 2.客户购车发票文件路径 3.客户延保合同文件路径
receptionCustomerPaySourceList
,
//1.付款凭证文件路径 2.客户购车发票文件路径 3.客户延保合同文件路径
merchantId
:
shopMerchantId
,
merchantId
:
shopMerchantId
,
bussinessType
:
sceneType
==
0
?
1
:
2
,
// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
bussinessType
:
sceneType
==
0
?
1
:
2
,
// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
...
@@ -137,9 +127,11 @@ export default {
...
@@ -137,9 +127,11 @@ export default {
sourceUrl
:
item
.
imgUrl
,
sourceUrl
:
item
.
imgUrl
,
};
};
}),
}),
{
receptionStartTime
,
receptionEndTime
,
endReasonType
}
=
this
.
audioInfo
,
params
=
{
params
=
{
carModel
,
carModel
,
endReasonType
:
this
.
endReasonType
,
//原因 1.异常 0.正常
endReasonType
,
//原因 1.异常 0.正常
customerName
,
customerName
,
phoneNumber
,
phoneNumber
,
loginPhone
:
phone
,
loginPhone
:
phone
,
...
@@ -147,8 +139,8 @@ export default {
...
@@ -147,8 +139,8 @@ export default {
salesUuid
,
salesUuid
,
receptionStatus
:
this
.
receptionStatus
,
//接待结果 1.成交 0.战败
receptionStatus
:
this
.
receptionStatus
,
//接待结果 1.成交 0.战败
recordUrlList
:
tempFilePath
,
recordUrlList
:
tempFilePath
,
receptionStartTime
:
this
.
receptionStartTime
,
receptionStartTime
,
receptionEndTime
:
this
.
receptionEndTime
,
receptionEndTime
,
receptionCustomerPaySourceList
,
//1.付款凭证文件路径 2.客户购车发票文件路径 3.客户延保合同文件路径
receptionCustomerPaySourceList
,
//1.付款凭证文件路径 2.客户购车发票文件路径 3.客户延保合同文件路径
merchantId
:
shopMerchantId
,
merchantId
:
shopMerchantId
,
bussinessType
:
sceneType
==
0
?
1
:
2
,
// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
bussinessType
:
sceneType
==
0
?
1
:
2
,
// sceneType 0延保 1精品。 bussinessType 1.延保 2.轻改
...
@@ -160,14 +152,18 @@ export default {
...
@@ -160,14 +152,18 @@ export default {
carModel
,
carModel
,
tempFilePath
tempFilePath
);
);
if
(
customerName
&&
phoneNumber
&&
salesUuid
)
if
(
customerName
&&
phoneNumber
&&
salesUuid
)
{
uni
.
$api
.
commonApi
.
saveRecCustomer
(
params
).
then
((
res
)
=>
{
uni
.
$api
.
commonApi
.
saveRecCustomer
(
params
).
then
((
res
)
=>
{
console
.
log
(
res
,
params
);
console
.
log
(
res
,
params
);
this
.
setAudioInfo
({
audioStatus
:
"finish"
});
});
});
}
else
{
this
.
setAudioInfo
({
audioStatus
:
"finish"
});
}
this
.
setBooks
([]);
this
.
setBooks
([]);
this
.
$store
.
dispatch
(
"clearCustomerInfo"
);
this
.
$store
.
dispatch
(
"clearCustomerInfo"
);
this
.
setReceptionStatus
(
1
);
this
.
setReceptionStatus
(
1
);
this
.
set
ReasonType
(
0
);
this
.
set
AudioInfo
({
endReasonType
:
0
}
);
uni
.
$storage
.
set
(
"storageFile"
,
""
);
uni
.
$storage
.
set
(
"storageFile"
,
""
);
}
catch
(
error
)
{
}
catch
(
error
)
{
this
.
$store
.
dispatch
(
"clearCustomerInfo"
);
this
.
$store
.
dispatch
(
"clearCustomerInfo"
);
...
@@ -176,10 +172,8 @@ export default {
...
@@ -176,10 +172,8 @@ export default {
},
},
//开始录音
//开始录音
async
startAudio
()
{
async
startAudio
()
{
if
(
this
.
isStart
)
return
;
if
(
this
.
audioInfo
.
audioStatus
==
"start"
)
return
;
this
.
setAudioStart
(
true
);
this
.
setAudioInfo
({
audioList
:
[],
audioStatus
:
"start"
});
this
.
setAudioList
([]);
this
.
setAudioEnd
(
false
);
this
.
initTime
();
this
.
initTime
();
recorderManager
.
start
({
recorderManager
.
start
({
duration
:
600000
,
duration
:
600000
,
...
@@ -188,7 +182,7 @@ export default {
...
@@ -188,7 +182,7 @@ export default {
});
});
recorderManager
.
onStop
(
async
(
res
)
=>
{
recorderManager
.
onStop
(
async
(
res
)
=>
{
console
.
log
(
"结束录音"
);
console
.
log
(
"结束录音"
);
if
(
!
this
.
isEnd
)
{
if
(
this
.
audioInfo
.
audioStatus
!=
"end"
)
{
uni
.
getRecorderManager
().
start
({
uni
.
getRecorderManager
().
start
({
duration
:
600000
,
duration
:
600000
,
sampleRate
:
16000
,
sampleRate
:
16000
,
...
@@ -198,7 +192,7 @@ export default {
...
@@ -198,7 +192,7 @@ export default {
// const isContinue = this.hasErrorFile();
// const isContinue = this.hasErrorFile();
// if (isContinue) {
// if (isContinue) {
// this.handleErrorFile(res.tempFilePath);
// this.handleErrorFile(res.tempFilePath);
// if (this.
isEnd
) {
// if (this.
audioInfo.audioStatus == 'end'
) {
// this.saveRecord();
// this.saveRecord();
// }
// }
// return;
// return;
...
@@ -218,11 +212,12 @@ export default {
...
@@ -218,11 +212,12 @@ export default {
}
else
{
}
else
{
// this.handleErrorFile(result, UPLOAD_STATUS.success);
// this.handleErrorFile(result, UPLOAD_STATUS.success);
}
}
const
storageFile
=
[...
this
.
audioList
,
result
];
const
storageFile
=
[...
this
.
audio
Info
.
audio
List
,
result
];
uni
.
$storage
.
set
(
"storageFile"
,
storageFile
);
uni
.
$storage
.
set
(
"storageFile"
,
storageFile
);
this
.
setAudioList
(
storageFile
);
this
.
setAudioInfo
({
audioList
:
storageFile
});
console
.
log
(
storageFile
,
this
.
isEnd
,
"this.isEnd"
);
if
(
this
.
audioInfo
.
audioStatus
!=
"end"
)
{
if
(
!
this
.
isEnd
)
return
;
return
;
}
this
.
uploadVoice
(
storageFile
);
this
.
uploadVoice
(
storageFile
);
});
});
},
},
...
@@ -297,28 +292,38 @@ export default {
...
@@ -297,28 +292,38 @@ export default {
// 返回一个错误或者进行其他操作
// 返回一个错误或者进行其他操作
return
new
Error
(
errorMsg
);
return
new
Error
(
errorMsg
);
},
},
//结束
录音
//结束
接待
stopAudio
:
utils
.
throttle
(
async
function
()
{
stopAudio
:
utils
.
throttle
(
async
function
()
{
const
result
=
await
this
.
$permision
.
requestAndroidPermission
(
// const result = await this.$permision.requestAndroidPermission(
"android.permission.RECORD_AUDIO"
// "android.permission.RECORD_AUDIO"
);
// );
if
(
result
!==
1
)
{
// if (result !== 1) {
uni
.
showToast
({
// uni.showToast({
title
:
"为了记录语音通话,请打开录音权限"
,
// title: "为了记录语音通话,请打开录音权限",
icon
:
"none"
,
// icon: "none",
// });
// return;
// }
uni
.
showLoading
({
mask
:
true
,
title
:
"处理中请稍后..."
,
});
});
return
;
let
finish_timer
=
null
;
}
this
.
setAudioInfo
({
audioStatus
:
"end"
});
this
.
setAudioStart
(
false
);
this
.
setAudioEnd
(
true
);
this
.
times
=
0
;
this
.
times
=
0
;
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
this
.
timer
=
null
;
this
.
timer
=
null
;
recorderManager
.
stop
();
recorderManager
.
stop
();
finish_timer
=
setInterval
(()
=>
{
if
(
this
.
audioInfo
.
audioStatus
==
"finish"
)
{
uni
.
hideLoading
();
clearInterval
(
finish_timer
);
}
},
1000
);
},
1500
),
},
1500
),
//监听点击事件
//监听点击事件
initTime
()
{
initTime
()
{
if
(
!
this
.
isStart
)
return
;
if
(
!
this
.
audioInfo
.
audioStatus
==
"start"
)
return
;
this
.
timer
=
setInterval
(()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
times
++
;
this
.
times
++
;
if
(
this
.
times
>=
this
.
timeout
)
{
if
(
this
.
times
>=
this
.
timeout
)
{
...
...
pages/boutique/invitation.vue
View file @
c768fdb
...
@@ -112,6 +112,7 @@ export default {
...
@@ -112,6 +112,7 @@ export default {
show
:{
show
:{
handler
()
{
handler
()
{
this
.
init
()
this
.
init
()
this
.
srefs
.
receptionTips
?.
close
()
},
},
immediate
:
true
immediate
:
true
}
}
...
...
store/modules/audio.js
View file @
c768fdb
...
@@ -16,37 +16,35 @@ export default {
...
@@ -16,37 +16,35 @@ export default {
return
{
return
{
booksList
:
[],
booksList
:
[],
audioList
:
[],
audioList
:
[],
isStart
:
false
,
receptionStatus
:
1
,
receptionStatus
:
1
,
endReasonType
:
0
,
endReasonType
:
0
,
isEnd
:
false
,
audioInfo
:
{
audioStatus
:
""
,
endReasonType
:
0
,
receptionStartTime
:
""
,
receptionStartTime
:
""
,
receptionEndTime
:
""
,
receptionEndTime
:
""
,
},
};
};
},
},
mutations
:
{
mutations
:
{
setAudioInfo
(
state
,
data
)
{
if
(
data
.
audioStatus
==
"start"
)
{
data
.
receptionStartTime
=
utils
.
convertDateTimeFormat
(
new
Date
(),
"/"
);
}
if
(
data
.
audioStatus
==
"end"
)
{
data
.
receptionEndTime
=
utils
.
convertDateTimeFormat
(
new
Date
(),
"/"
);
}
state
.
audioInfo
=
Object
.
assign
(
state
.
audioInfo
,
data
);
},
setReceptionStatus
(
state
,
data
)
{
setReceptionStatus
(
state
,
data
)
{
state
.
receptionStatus
=
data
;
state
.
receptionStatus
=
data
;
},
},
setReasonType
(
state
,
data
)
{
state
.
endReasonType
=
data
;
},
setAudioList
(
state
,
data
)
{
setAudioList
(
state
,
data
)
{
state
.
audioList
=
data
;
state
.
audioList
=
data
;
},
},
setBooks
(
state
,
data
)
{
setBooks
(
state
,
data
)
{
state
.
booksList
=
data
;
state
.
booksList
=
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
(),
"/"
);
},
},
},
actions
:
{
actions
:
{
// startAudio({ commit, state, dispatch }) {
// startAudio({ commit, state, dispatch }) {
...
...
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