| | |
| | | <view class="flex a-center j-between"> |
| | | <text class="w-108 fs-27 font-bold mr-85">问题描述</text> |
| | | <view class="flex a-center" @click="voiceInput"> |
| | | |
| | | <image src="/static/Appeal/yuyin.png" class="w-30 h-30 mr-11" mode=""></image> |
| | | <text class="fs-23 red">语音输入</text> |
| | | </view> |
| | | </view> |
| | |
| | | import config from '@/config/index.js' |
| | | import voiceInputPopup from '@/components/voiceInputPopup.vue' |
| | | import { |
| | | mapActions, |
| | | mapState |
| | | } from "vuex"; |
| | | mapActions, |
| | | mapState |
| | | } from "vuex"; |
| | | |
| | | export default { |
| | | components: { |
| | |
| | | detailedAddress: '', |
| | | descriptionTitle: '', |
| | | descriptionContent: '', |
| | | videoContent: [ |
| | | { url: 'xxx1', playing: false }, |
| | | { url: 'xxx2', playing: false } |
| | | ], |
| | | videoContent: [], |
| | | latitude: '', |
| | | longitude: '', |
| | | images: [], |
| | | videos: [], |
| | | voiceFile: '',//语音文件多个逗号拼接 |
| | | userInfo: uni.getStorageSync('userInfo'), //个人信息 |
| | | voiceInputShow: false, |
| | | }; |
| | |
| | | this.getproblem() |
| | | this.time = dayjs().format('YYYY-MM-DD') |
| | | }, |
| | | |
| | | |
| | | methods: { |
| | | ...mapActions(["playRecording", "pausePlaying"]), |
| | | onPlayRecording(index) { |
| | |
| | | this.voiceInputShow = false; |
| | | }, |
| | | submitVoiceInput(e) { |
| | | this.videoContent.push(e); |
| | | console.log('eeeeeeeeeeeeeeeeeee', e) |
| | | this.videoContent.push({ url: e.url, data: e.data, playing: false }); |
| | | this.voiceInputShow = false; |
| | | }, |
| | | previewImage(index) { |
| | |
| | | })] |
| | | })) |
| | | }, |
| | | submit(type) { |
| | | async submit(type) { |
| | | if (this.videoContent.length > 0) { |
| | | uni.showLoading({ |
| | | title: '正在上传语音文件...' |
| | | }); |
| | | |
| | | const uploadPromises = this.videoContent.map(item => { |
| | | return new Promise((resolve, reject) => { |
| | | console.log('item.data', item.data) |
| | | uni.uploadFile({ |
| | | url: config.imageUrl, |
| | | file: item.data, |
| | | name: 'file', |
| | | // fileType: 'audio/mpeg', |
| | | // filePath: item.url, |
| | | // name: 'file', |
| | | header: { |
| | | 'Content-Type': 'multipart/form-data', |
| | | 'Authorization': uni.getStorageSync('token') |
| | | }, |
| | | success: (uploadFileRes) => { |
| | | const response = JSON.parse(uploadFileRes.data); |
| | | if (response.code === 200) { |
| | | resolve(response.data); |
| | | } else { |
| | | reject(new Error('上传失败')); |
| | | } |
| | | }, |
| | | fail: (error) => { |
| | | reject(error); |
| | | } |
| | | }); |
| | | }); |
| | | }); |
| | | |
| | | try { |
| | | const uploadedUrls = await Promise.all(uploadPromises); |
| | | this.voiceFile = uploadedUrls.join(','); |
| | | console.log('this.voiceFile', this.voiceFile) |
| | | uni.hideLoading(); |
| | | } catch (error) { |
| | | uni.hideLoading(); |
| | | uni.showToast({ |
| | | title: '语音文件上传失败', |
| | | icon: 'error' |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | const preciseRegex = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; |
| | | if (!this.time) { |
| | | uni.showToast({ |
| | |
| | | }) |
| | | return |
| | | } |
| | | |
| | | const data = { |
| | | time: this.time, |
| | | problemType: this.problemType, |
| | |
| | | descriptionContent: this.descriptionContent, |
| | | images: this.images.join(','), |
| | | videos: this.videos.join(','), |
| | | voiceFile: this.voiceFile, |
| | | } |
| | | // 问题上报 |
| | | if (type == 1) { |
| | |
| | | success: (res) => { |
| | | |
| | | uni.showLoading() |
| | | console.log('res.tempFilePaths[0]', res.tempFilePaths[0]) |
| | | uni.uploadFile({ |
| | | url: config.imageUrl, |
| | | filePath: res.tempFilePaths[0], |