Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
Sign in / Register
Toggle navigation
S
site-uniapp
概览
Overview
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
王柯
site-uniapp
Commits
4da226d9
提交
4da226d9
authored
2月 23, 2023
作者:
wk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
汇筑代码集成
父级
fae7cee3
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
295 行增加
和
50 行删除
+295
-50
manifest.json
+45
-39
pages/questionAdd/questionAdd.vue
+250
-11
没有找到文件。
manifest.json
View file @
4da226d9
{
"name"
:
"site-uniapp"
,
"appid"
:
"__UNI__EB20610"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
"name"
:
"site-uniapp"
,
"appid"
:
"__UNI__EB20610"
,
"description"
:
""
,
"versionName"
:
"1.0.0"
,
"versionCode"
:
"100"
,
"transformPx"
:
false
,
/*
5
+App特有相关
*/
"app-plus"
:
{
"usingComponents"
:
true
,
"nvueStyleCompiler"
:
"uni-app"
,
"compilerVersion"
:
3
,
"splashscreen"
:
{
"alwaysShowBeforeRender"
:
true
,
"waiting"
:
true
,
"autoclose"
:
true
,
"delay"
:
0
"app-plus"
:
{
"usingComponents"
:
true
,
"nvueStyleCompiler"
:
"uni-app"
,
"compilerVersion"
:
3
,
"splashscreen"
:
{
"alwaysShowBeforeRender"
:
true
,
"waiting"
:
true
,
"autoclose"
:
true
,
"delay"
:
0
},
/*
模块配置
*/
"modules"
:
{},
"modules"
:
{},
/*
应用发布信息
*/
"distribute"
:
{
"distribute"
:
{
/*
android打包配置
*/
"android"
:
{
"permissions"
:
[
"android"
:
{
"permissions"
:
[
"<uses-permission android:name=
\"
android.permission.CHANGE_NETWORK_STATE
\"
/>"
,
"<uses-permission android:name=
\"
android.permission.MOUNT_UNMOUNT_FILESYSTEMS
\"
/>"
,
"<uses-permission android:name=
\"
android.permission.VIBRATE
\"
/>"
,
...
...
@@ -41,37 +41,43 @@
]
},
/*
ios打包配置
*/
"ios"
:
{},
"ios"
:
{},
/*
SDK配置
*/
"sdkConfigs"
:
{}
"sdkConfigs"
:
{}
}
},
/*
快应用特有相关
*/
"quickapp"
:
{},
"quickapp"
:
{},
/*
小程序特有相关
*/
"mp-weixin"
:
{
"appid"
:
"wxa38e989a4ba04775"
,
"setting"
:
{
"urlCheck"
:
false
"mp-weixin"
:
{
"appid"
:
"wxa38e989a4ba04775"
,
"setting"
:
{
"urlCheck"
:
false
},
"usingComponents"
:
true
,
"permission"
:
{
"scope.userLocation"
:
{
"desc"
:
"获取当前位置,以便查询天气情况"
"usingComponents"
:
true
,
"permission"
:
{
"scope.userLocation"
:
{
"desc"
:
"获取当前位置,以便查询天气情况"
}
},
"plugins"
:
{
"WechatSI"
:
{
"version"
:
"0.3.1"
,
"provider"
:
"wx069ba97219f66d99"
}
}
},
"mp-alipay"
:
{
"usingComponents"
:
true
"mp-alipay"
:
{
"usingComponents"
:
true
},
"mp-baidu"
:
{
"usingComponents"
:
true
"mp-baidu"
:
{
"usingComponents"
:
true
},
"mp-toutiao"
:
{
"usingComponents"
:
true
"mp-toutiao"
:
{
"usingComponents"
:
true
},
"uniStatistics"
:
{
"enable"
:
false
"uniStatistics"
:
{
"enable"
:
false
},
"vueVersion"
:
"2"
"vueVersion"
:
"2"
}
pages/questionAdd/questionAdd.vue
View file @
4da226d9
<
template
>
<view>
<view
class=
"info-box"
>
<
!--
<
view
class=
"info-box"
>
<view
class=
"flex-between"
>
<view
class=
"title"
><span
class=
"red"
>
*
</span>
问题标签
</view>
<picker
@
change=
"bindPickerChange"
:value=
"index"
:range=
"labelData"
range-key=
"labelMsg"
>
<view
class=
"uni-input"
>
{{
labelData
[
index
]
?
labelData
[
index
].
labelMsg
:
'请选择问题标签'
}}
</view>
</picker>
</view>
</view>
</view>
-->
<view
class=
"info-box"
>
<view
class=
"flex-between"
>
<view
class=
"title"
><span
class=
"red"
>
*
</span>
标题
</view>
<input
class=
"mar-top-10"
placeholder=
"请输入标题"
v-model=
"title"
/>
<!--
<view
class=
"flex-between"
>
<view
class=
"title"
><span
class=
"red"
>
*
</span>
标题
</view>
<input
class=
"text-right"
placeholder=
"请输入标题"
v-model=
"title"
/>
</view>
</view>
-->
</view>
<view
class=
"info-box"
>
<view
class=
"title"
><span
class=
"red"
>
*
</span>
内容
</view>
<textarea
class=
"mar-top-10"
v-model=
"content"
placeholder=
"请输入内容"
/>
<image
class=
"icon-voice"
@
click=
"handleStart()"
src=
"https://project-gdt.oss-cn-hangzhou.aliyuncs.com/upload/20230219/2b252eaaa2f47814bd007b1a4368f915.png"
mode=
""
></image>
<view
class=
"voice-body"
v-if=
"contentSound"
@
click=
"handlePlay"
>
<image
v-if=
"playing"
class=
"voice-img"
src=
"https://project-cmp.oss-cn-huhehaote.aliyuncs.com/upload/20230223/934d27455088b72134f4bd8c085a2d9c.gif"
mode=
""
></image>
<image
v-else
class=
"voice-img"
src=
"https://project-cmp.oss-cn-huhehaote.aliyuncs.com/upload/20230223/fa954427b431f647d5246591572f16fa.png"
mode=
""
></image>
<text>
{{
voiceTime
}}
s
</text>
</view>
</view>
<view
class=
"info-box"
>
...
...
@@ -34,11 +42,26 @@
</view>
</view>
<view
class=
"bottom-button"
@
click=
"handleSave"
>
提交
</view>
<view
class=
"bottom-button"
@
click=
"handleSave()"
>
提交
</view>
<!-- 录音弹窗 -->
<view
class=
"record-body"
v-if=
"showRecord"
>
<view
class=
"record-body-content"
>
<image
class=
"img-recording"
src=
"https://project-gdt.oss-cn-hangzhou.aliyuncs.com/upload/20230219/f0d612e583a60331b022b63817bed3c1.gif"
mode=
""
></image>
<text
class=
"text-count"
>
录音倒计时:
{{
count
}}
s
</text>
<view
class=
"button-close"
@
click=
"handleEnd()"
>
结束录音
</view>
</view>
</view>
</view>
</
template
>
<
script
>
var
plugin
=
requirePlugin
(
"WechatSI"
)
let
manager
=
plugin
.
getRecordRecognitionManager
();
const
innerAudioContext
=
uni
.
createInnerAudioContext
();
export
default
{
data
()
{
return
{
...
...
@@ -52,6 +75,13 @@
content
:
''
,
attath
:
[],
fileList
:
[],
showRecord
:
false
,
count
:
0
,
contentSound
:
''
,
contentSoundTemp
:
''
,
voiceState
:
''
,
playing
:
false
,
voiceTime
:
0
,
}
},
onLoad
(
option
)
{
...
...
@@ -60,9 +90,105 @@
this
.
projectId
=
projectId
this
.
token
=
token
this
.
getLabelData
()
this
.
getLabelData
();
this
.
initRecord
();
},
watch
:
{
contentSound
:
{
handler
(
newName
,
oldName
)
{
console
.
log
(
'contentSound'
,
newName
)
this
.
initAudio
(
newName
)
},
}
},
methods
:
{
/**
* 初始化语音识别回调
* 绑定语音播放开始事件
*/
initRecord
:
function
()
{
manager
.
onStart
=
function
(
res
)
{
this
.
voiceState
=
"onStart:"
+
res
.
msg
+
"正在录音"
};
//有新的识别内容返回,则会调用此事件
manager
.
onRecognize
=
(
res
)
=>
{
this
.
voiceState
=
"onRecognize"
+
res
.
result
;
}
// 识别结束事件
manager
.
onStop
=
(
res
)
=>
{
console
.
log
(
'manager.onStop'
,
res
)
const
{
result
,
tempFilePath
}
=
res
this
.
content
=
`
${
this
.
content
}${
res
.
result
}
`
this
.
contentSoundTemp
=
tempFilePath
uni
.
uploadFile
({
url
:
`
${
this
.
baseUrl
}
/macro-resource/filesys/upload`
,
filePath
:
tempFilePath
,
name
:
'file'
,
formData
:
{
'user'
:
'test'
},
header
:
{
'Macro-Auth'
:
this
.
token
//自定义请求头信息
},
success
:
(
uploadFileRes
)
=>
{
console
.
log
(
uploadFileRes
);
const
data
=
JSON
.
parse
(
uploadFileRes
.
data
).
data
this
.
contentSound
=
data
.
fileUrl
}
});
}
// 识别错误事件
manager
.
onError
=
(
res
)
=>
{
this
.
voiceState
=
"onError"
+
res
.
msg
;
}
},
initAudio
:
function
(
url
)
{
console
.
log
(
'initAudio'
,
url
)
innerAudioContext
.
obeyMuteSwitch
=
false
;
innerAudioContext
.
src
=
url
;
innerAudioContext
.
onPlay
(()
=>
{
console
.
log
(
'开始播放'
);
this
.
playing
=
true
});
innerAudioContext
.
onCanplay
(()
=>
{
// setTimeout(() => {
// console.log('onCanplay', innerAudioContext.duration);
// }, 500);
let
intervalID
=
setInterval
(()
=>
{
console
.
log
(
'onCanplay'
,
innerAudioContext
);
if
(
innerAudioContext
.
duration
!==
0
)
{
// console.log('onCanplay', innerAudioContext);
clearInterval
(
intervalID
);
}
},
500
)
});
innerAudioContext
.
onEnded
((
res
)
=>
{
console
.
log
(
'onEnded'
,
res
);
this
.
playing
=
false
});
innerAudioContext
.
onPause
((
res
)
=>
{
console
.
log
(
'onPause'
,
res
);
this
.
playing
=
false
});
innerAudioContext
.
onStop
((
res
)
=>
{
console
.
log
(
'onStop'
,
res
);
this
.
playing
=
false
});
innerAudioContext
.
onTimeUpdate
(()
=>
{
const
{
currentTime
,
duration
,
buffered
}
=
innerAudioContext
;
//进度条最大值
this
.
sliderMax
=
duration
;
console
.
log
(
duration
,
"音频时长"
)
//就是这个时长的bug
console
.
log
(
buffered
,
"音频缓冲"
)
});
},
getLabelData
:
function
()
{
uni
.
request
({
url
:
`
${
this
.
baseUrl
}
/macro-cwcd/problemLabel/setting/list`
,
...
...
@@ -116,25 +242,26 @@
},
handleSave
:
function
()
{
const
label
=
this
.
labelData
[
this
.
index
]
?
this
.
labelData
[
this
.
index
].
label
:
''
//
const label = this.labelData[this.index] ? this.labelData[this.index].label : ''
const
attach
=
this
.
fileList
.
map
(
item
=>
item
.
id
)
if
(
!
label
||
!
this
.
title
||
!
this
.
content
)
{
if
(
!
this
.
title
||
!
this
.
content
)
{
uni
.
showToast
({
title
:
'请完善信息!'
,
icon
:
'error'
})
return
}
console
.
log
(
'label'
,
label
)
//
console.log('label', label)
uni
.
request
({
url
:
`
${
this
.
baseUrl
}
/macro-cwcd/problemFeedback/worker/create`
,
method
:
'POST'
,
data
:
{
label
:
parseInt
(
label
),
// label: parseInt(label),
contentSound
:
this
.
contentSound
,
title
:
this
.
title
,
content
:
this
.
content
,
attach
:
attach
.
join
(
','
),
projectId
:
this
.
projectId
projectId
:
this
.
projectId
,
},
header
:
{
'Macro-Auth'
:
this
.
token
//自定义请求头信息
...
...
@@ -151,7 +278,58 @@
}
}
});
},
handleStart
:
function
()
{
const
_this
=
this
uni
.
authorize
({
scope
:
'scope.record'
,
success
()
{
_this
.
showRecord
=
true
;
_this
.
count
=
59
;
_this
.
handleVolumeTimer
();
manager
.
start
({
duration
:
60000
,
lang
:
"zh_CN"
});
},
fail
()
{
uni
.
showToast
({
title
:
'请在设置里打开录音权限!'
})
}
})
},
handleEnd
:
function
()
{
manager
.
stop
();
this
.
showRecord
=
false
;
this
.
voiceTime
=
60
-
this
.
count
clearInterval
(
this
.
timer
)
},
handleCloseRecord
:
function
()
{
this
.
showRecord
=
false
;
},
handleVolumeTimer
:
function
()
{
this
.
timer
=
setInterval
(()
=>
{
if
(
this
.
count
==
0
)
{
this
.
handleEnd
()
}
else
{
this
.
count
=
this
.
count
-
1
}
},
1000
);
},
handlePlay
()
{
if
(
this
.
playing
)
{
innerAudioContext
.
pause
()
}
else
{
innerAudioContext
.
play
()
}
}
}
...
...
@@ -229,6 +407,13 @@
}
}
}
.icon-voice
{
width
:
60
rpx
;
height
:
60
rpx
;
position
:
absolute
;
bottom
:
20
rpx
;
right
:
20
rpx
;
}
}
.bottom-button
{
...
...
@@ -243,4 +428,58 @@
font-size
:
32
rpx
;
left
:
0
;
}
.record-body
{
position
:
fixed
;
width
:
100%
;
height
:
100%
;
top
:
0px
;
left
:
0px
;
background
:
rgba
(
0
,
0
,
0
,
0.5
);
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
.button-close
{
font-size
:
30
rpx
;
width
:
200
rpx
;
height
:
80
rpx
;
line-height
:
80
rpx
;
text-align
:
center
;
color
:
#fff
;
border
:
1px
solid
#fff
;
border-radius
:
10
rpx
;
margin-top
:
20
rpx
;
}
.record-body-content
{
text-align
:
center
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
color
:
#fff
;
.img-recording
{
width
:
400
rpx
;
height
:
400
rpx
;
}
}
}
.voice-body
{
width
:
200
rpx
;
height
:
80
rpx
;
display
:
flex
;
align-items
:
center
;
justify-content
:
flex-start
;
background
:
#A0EA6F
;
border-radius
:
8
rpx
;
padding-left
:
10
rpx
;
.voice-img
{
width
:
40
rpx
;
height
:
40
rpx
;
}
text
{
margin-left
:
10
rpx
;
}
}
</
style
>
Write
Preview
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
Please
register
or
sign in
to comment