From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/mp/components/wx-reply/components/TabVoice.vue | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 160 insertions(+), 0 deletions(-)
diff --git a/src/views/mp/components/wx-reply/components/TabVoice.vue b/src/views/mp/components/wx-reply/components/TabVoice.vue
new file mode 100644
index 0000000..5dbe9a0
--- /dev/null
+++ b/src/views/mp/components/wx-reply/components/TabVoice.vue
@@ -0,0 +1,160 @@
+<template>
+ <div>
+ <div class="select-item2" v-if="reply.url">
+ <p class="item-name">{{ reply.name }}</p>
+ <el-row class="ope-row" justify="center">
+ <WxVoicePlayer :url="reply.url" />
+ </el-row>
+ <el-row class="ope-row" justify="center">
+ <el-button type="danger" circle @click="onDelete"><Icon icon="ep:delete" /></el-button>
+ </el-row>
+ </div>
+ <el-row v-else style="text-align: center">
+ <!-- 閫夋嫨绱犳潗 -->
+ <el-col :span="12" class="col-select">
+ <el-button type="success" @click="showDialog = true">
+ 绱犳潗搴撻�夋嫨<Icon icon="ep:circle-check" />
+ </el-button>
+ <el-dialog
+ title="閫夋嫨璇煶"
+ v-model="showDialog"
+ width="90%"
+ append-to-body
+ destroy-on-close
+ >
+ <WxMaterialSelect
+ type="voice"
+ :account-id="reply.accountId"
+ @select-material="selectMaterial"
+ />
+ </el-dialog>
+ </el-col>
+ <!-- 鏂囦欢涓婁紶 -->
+ <el-col :span="12" class="col-add">
+ <el-upload
+ :action="UPLOAD_URL"
+ :headers="HEADERS"
+ multiple
+ :limit="1"
+ :file-list="fileList"
+ :data="uploadData"
+ :before-upload="beforeVoiceUpload"
+ :on-success="onUploadSuccess"
+ >
+ <el-button type="primary">鐐瑰嚮涓婁紶</el-button>
+ <template #tip>
+ <div class="el-upload__tip">
+ 鏍煎紡鏀寔 mp3/wma/wav/amr锛屾枃浠跺ぇ灏忎笉瓒呰繃 2M锛屾挱鏀鹃暱搴︿笉瓒呰繃 60s
+ </div>
+ </template>
+ </el-upload>
+ </el-col>
+ </el-row>
+ </div>
+</template>
+<script lang="ts" setup>
+import WxMaterialSelect from '@/views/mp/components/wx-material-select'
+import WxVoicePlayer from '@/views/mp/components/wx-voice-play'
+import { UploadType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
+import type { UploadRawFile } from 'element-plus'
+import { getAccessToken } from '@/utils/auth'
+import { Reply } from './types'
+const message = useMessage()
+
+const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-temporary'
+const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+
+const props = defineProps<{
+ modelValue: Reply
+}>()
+const emit = defineEmits<{
+ (e: 'update:modelValue', v: Reply)
+}>()
+const reply = computed<Reply>({
+ get: () => props.modelValue,
+ set: (val) => emit('update:modelValue', val)
+})
+
+const showDialog = ref(false)
+const fileList = ref([])
+const uploadData = reactive({
+ accountId: reply.value.accountId,
+ type: 'voice',
+ title: '',
+ introduction: ''
+})
+
+const beforeVoiceUpload = (rawFile: UploadRawFile) => useBeforeUpload(UploadType.Voice, 10)(rawFile)
+
+const onUploadSuccess = (res: any) => {
+ if (res.code !== 0) {
+ message.error('涓婁紶鍑洪敊锛�' + res.msg)
+ return false
+ }
+
+ // 娓呯┖涓婁紶鏃剁殑鍚勭鏁版嵁
+ fileList.value = []
+ uploadData.title = ''
+ uploadData.introduction = ''
+
+ // 涓婁紶濂界殑鏂囦欢锛屾湰璐ㄦ槸涓礌鏉愶紝鎵�浠ュ彲浠ヨ繘琛岄�変腑
+ selectMaterial(res.data)
+}
+
+const onDelete = () => {
+ reply.value.mediaId = null
+ reply.value.url = null
+ reply.value.name = null
+}
+
+const selectMaterial = (item: Reply) => {
+ showDialog.value = false
+
+ // reply.value.type = ReplyType.Voice
+ reply.value.mediaId = item.mediaId
+ reply.value.url = item.url
+ reply.value.name = item.name
+}
+</script>
+
+<style lang="scss" scoped>
+.select-item2 {
+ padding: 10px;
+ margin: 0 auto 10px;
+ border: 1px solid #eaeaea;
+
+ .item-name {
+ overflow: hidden;
+ font-size: 12px;
+ text-align: center;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ .ope-row {
+ width: 100%;
+ padding-top: 10px;
+ text-align: center;
+ }
+ }
+
+ .col-select {
+ width: 49.5%;
+ height: 160px;
+ padding: 50px 0;
+ border: 1px solid rgb(234 234 234);
+ }
+
+ .col-add {
+ float: right;
+ width: 49.5%;
+ height: 160px;
+ padding: 50px 0;
+ border: 1px solid rgb(234 234 234);
+
+ .el-upload__tip {
+ line-height: 18px;
+ text-align: center;
+ }
+ }
+}
+</style>
--
Gitblit v1.8.0