2023-04-19 11:07:51 +08:00
|
|
|
|
<template>
|
2023-04-21 20:22:11 +08:00
|
|
|
|
<div>
|
2023-04-19 11:07:51 +08:00
|
|
|
|
<el-row>
|
2023-04-21 20:22:11 +08:00
|
|
|
|
<el-input v-model="reply.title" class="input-margin-bottom" placeholder="请输入标题" />
|
|
|
|
|
<el-input class="input-margin-bottom" v-model="reply.description" placeholder="请输入描述" />
|
2023-04-19 11:07:51 +08:00
|
|
|
|
<el-row class="ope-row" justify="center">
|
2023-04-21 20:22:11 +08:00
|
|
|
|
<WxVideoPlayer v-if="reply.url" :url="reply.url" />
|
2023-04-19 11:07:51 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
<el-col>
|
|
|
|
|
<el-row style="text-align: center" align="middle">
|
|
|
|
|
<!-- 选择素材 -->
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<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
|
|
|
|
|
>
|
2023-04-21 20:22:11 +08:00
|
|
|
|
<WxMaterialSelect
|
|
|
|
|
type="video"
|
|
|
|
|
:account-id="reply.accountId"
|
|
|
|
|
@select-material="selectMaterial"
|
|
|
|
|
/>
|
2023-04-19 11:07:51 +08:00
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-col>
|
|
|
|
|
<!-- 文件上传 -->
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-upload
|
|
|
|
|
:action="UPLOAD_URL"
|
|
|
|
|
:headers="HEADERS"
|
|
|
|
|
multiple
|
|
|
|
|
:limit="1"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:data="uploadData"
|
|
|
|
|
:before-upload="beforeVideoUpload"
|
|
|
|
|
:on-success="onUploadSuccess"
|
|
|
|
|
>
|
|
|
|
|
<el-button type="primary">新建视频 <Icon icon="ep:upload" /></el-button>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
2023-04-21 20:22:11 +08:00
|
|
|
|
</div>
|
2023-04-19 11:07:51 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
2023-06-21 19:35:11 +08:00
|
|
|
|
<script lang="ts" setup>
|
2023-04-21 20:22:11 +08:00
|
|
|
|
import WxVideoPlayer from '@/views/mp/components/wx-video-play'
|
|
|
|
|
import WxMaterialSelect from '@/views/mp/components/wx-material-select'
|
2023-04-19 11:07:51 +08:00
|
|
|
|
import type { UploadRawFile } from 'element-plus'
|
2023-04-21 20:22:11 +08:00
|
|
|
|
import { UploadType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
|
2023-04-19 11:07:51 +08:00
|
|
|
|
import { getAccessToken } from '@/utils/auth'
|
2023-04-21 20:22:11 +08:00
|
|
|
|
import { Reply } from './types'
|
2023-04-19 11:07:51 +08:00
|
|
|
|
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
|
2024-04-24 21:50:21 +08:00
|
|
|
|
const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-temporary'
|
2023-04-19 11:07:51 +08:00
|
|
|
|
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() }
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
2023-04-21 20:22:11 +08:00
|
|
|
|
modelValue: Reply
|
2023-04-19 11:07:51 +08:00
|
|
|
|
}>()
|
|
|
|
|
const emit = defineEmits<{
|
2023-04-21 20:22:11 +08:00
|
|
|
|
(e: 'update:modelValue', v: Reply)
|
2023-04-19 11:07:51 +08:00
|
|
|
|
}>()
|
2023-04-21 20:22:11 +08:00
|
|
|
|
const reply = computed<Reply>({
|
2023-04-19 11:07:51 +08:00
|
|
|
|
get: () => props.modelValue,
|
|
|
|
|
set: (val) => emit('update:modelValue', val)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const showDialog = ref(false)
|
|
|
|
|
const fileList = ref([])
|
|
|
|
|
const uploadData = reactive({
|
2023-04-21 20:22:11 +08:00
|
|
|
|
accountId: reply.value.accountId,
|
2023-04-19 11:07:51 +08:00
|
|
|
|
type: 'video',
|
|
|
|
|
title: '',
|
|
|
|
|
introduction: ''
|
|
|
|
|
})
|
|
|
|
|
|
2023-04-21 20:22:11 +08:00
|
|
|
|
const beforeVideoUpload = (rawFile: UploadRawFile) => useBeforeUpload(UploadType.Video, 10)(rawFile)
|
2023-04-19 11:07:51 +08:00
|
|
|
|
|
|
|
|
|
const onUploadSuccess = (res: any) => {
|
|
|
|
|
if (res.code !== 0) {
|
|
|
|
|
message.error('上传出错:' + res.msg)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 清空上传时的各种数据
|
|
|
|
|
fileList.value = []
|
|
|
|
|
uploadData.title = ''
|
|
|
|
|
uploadData.introduction = ''
|
|
|
|
|
|
|
|
|
|
selectMaterial(res.data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 选择素材后设置 */
|
|
|
|
|
const selectMaterial = (item: any) => {
|
|
|
|
|
showDialog.value = false
|
|
|
|
|
|
2023-04-21 20:22:11 +08:00
|
|
|
|
reply.value.mediaId = item.mediaId
|
|
|
|
|
reply.value.url = item.url
|
|
|
|
|
reply.value.name = item.name
|
2023-04-19 11:07:51 +08:00
|
|
|
|
|
|
|
|
|
// title、introduction:从 item 到 tempObjItem,因为素材里有 title、introduction
|
|
|
|
|
if (item.title) {
|
2023-04-21 20:22:11 +08:00
|
|
|
|
reply.value.title = item.title || ''
|
2023-04-19 11:07:51 +08:00
|
|
|
|
}
|
|
|
|
|
if (item.introduction) {
|
2023-04-21 20:22:11 +08:00
|
|
|
|
reply.value.description = item.introduction || ''
|
2023-04-19 11:07:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.input-margin-bottom {
|
|
|
|
|
margin-bottom: 2%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ope-row {
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding-top: 10px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|