pyt
2 天以前 20e32587ecbab27e4436f2f64a15faa3c89e4f41
H5/pages/Appeal/Appeal.vue
@@ -62,7 +62,7 @@
            <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>
@@ -154,9 +154,9 @@
import config from '@/config/index.js'
import voiceInputPopup from '@/components/voiceInputPopup.vue'
import {
      mapActions,
      mapState
   } from "vuex";
   mapActions,
   mapState
} from "vuex";
export default {
   components: {
@@ -178,14 +178,12 @@
         detailedAddress: '',
         descriptionTitle: '',
         descriptionContent: '',
         videoContent: [
            { url: 'xxx1', playing: false },
            { url: 'xxx2', playing: false }
         ],
         videoContent: [],
         latitude: '',
         longitude: '',
         images: [],
         videos: [],
         voiceFile: '',//语音文件多个逗号拼接
         userInfo: uni.getStorageSync('userInfo'), //个人信息
         voiceInputShow: false,
      };
@@ -202,7 +200,7 @@
      this.getproblem()
      this.time = dayjs().format('YYYY-MM-DD')
   },
   methods: {
      ...mapActions(["playRecording", "pausePlaying"]),
      onPlayRecording(index) {
@@ -224,7 +222,8 @@
         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) {
@@ -262,7 +261,55 @@
            })]
         }))
      },
      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({
@@ -308,6 +355,7 @@
            })
            return
         }
         const data = {
            time: this.time,
            problemType: this.problemType,
@@ -320,6 +368,7 @@
            descriptionContent: this.descriptionContent,
            images: this.images.join(','),
            videos: this.videos.join(','),
            voiceFile: this.voiceFile,
         }
         // 问题上报
         if (type == 1) {
@@ -382,6 +431,7 @@
            success: (res) => {
               uni.showLoading()
               console.log('res.tempFilePaths[0]', res.tempFilePaths[0])
               uni.uploadFile({
                  url: config.imageUrl,
                  filePath: res.tempFilePaths[0],