提交 4da226d9 作者: wk

汇筑代码集成

父级 fae7cee3
{
"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
},
/* 模块配置 */
"modules" : {},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"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\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios打包配置 */
"ios" : {},
/* SDK配置 */
"sdkConfigs" : {}
}
},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "wxa38e989a4ba04775",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true,
"permission" : {
"scope.userLocation" : {
"desc" : "获取当前位置,以便查询天气情况"
}
}
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2"
"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
},
/* 模块配置 */
"modules": {},
/* 应用发布信息 */
"distribute": {
/* android打包配置 */
"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\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios打包配置 */
"ios": {},
/* SDK配置 */
"sdkConfigs": {}
}
},
/* 快应用特有相关 */
"quickapp": {},
/* 小程序特有相关 */
"mp-weixin": {
"appid": "wxa38e989a4ba04775",
"setting": {
"urlCheck": false
},
"usingComponents": true,
"permission": {
"scope.userLocation": {
"desc": "获取当前位置,以便查询天气情况"
}
},
"plugins": {
"WechatSI": {
"version": "0.3.1",
"provider": "wx069ba97219f66d99"
}
}
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "2"
}
<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: 60rpx;
height: 60rpx;
position: absolute;
bottom: 20rpx;
right: 20rpx;
}
}
.bottom-button {
......@@ -243,4 +428,58 @@
font-size: 32rpx;
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: 30rpx;
width: 200rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
color: #fff;
border: 1px solid #fff;
border-radius: 10rpx;
margin-top: 20rpx;
}
.record-body-content {
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
.img-recording {
width: 400rpx;
height: 400rpx;
}
}
}
.voice-body {
width: 200rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: flex-start;
background: #A0EA6F;
border-radius: 8rpx;
padding-left: 10rpx;
.voice-img {
width: 40rpx;
height: 40rpx;
}
text {
margin-left: 10rpx;
}
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment