2023-03-27 03:18:25 +08:00
|
|
|
|
<!--
|
|
|
|
|
- Copyright (C) 2018-2019
|
|
|
|
|
- All rights reserved, Designed By www.joolun.com
|
|
|
|
|
芋道源码:
|
|
|
|
|
① 移除多余的 rep 为前缀的变量,让 message 消息更简单
|
|
|
|
|
② 代码优化,补充注释,提升阅读性
|
|
|
|
|
③ 优化消息的临时缓存策略,发送消息时,只清理被发送消息的 tab,不会强制切回到 text 输入
|
|
|
|
|
④ 支持发送【视频】消息时,支持新建视频
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-tabs type="border-card" v-model="objDataRef.type" @tab-click="handleClick">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<!-- 类型 1:文本 -->
|
|
|
|
|
<el-tab-pane name="text">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<template #label>
|
|
|
|
|
<el-row align="middle">
|
|
|
|
|
<icon icon="ep:document" />
|
|
|
|
|
文本
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-input
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="5"
|
|
|
|
|
placeholder="请输入内容"
|
2023-03-28 01:18:37 +08:00
|
|
|
|
v-model="objDataRef.content"
|
2023-03-27 03:18:25 +08:00
|
|
|
|
@input="inputContent"
|
|
|
|
|
/>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
<!-- 类型 2:图片 -->
|
|
|
|
|
<el-tab-pane name="image">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<template #label>
|
|
|
|
|
<el-row align="middle">
|
|
|
|
|
<icon icon="ep:picture" class="mr-5px" />
|
|
|
|
|
图片
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 情况一:已经选择好素材、或者上传好图片 -->
|
|
|
|
|
<div class="select-item" v-if="objDataRef.url">
|
|
|
|
|
<img class="material-img" :src="objDataRef.url" />
|
|
|
|
|
<p class="item-name" v-if="objDataRef.name">{{ objDataRef.name }}</p>
|
|
|
|
|
<el-row class="ope-row">
|
|
|
|
|
<el-button type="danger" circle @click="deleteObj">
|
|
|
|
|
<icon icon="ep:delete" />
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-row>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 情况二:未做完上述操作 -->
|
|
|
|
|
<el-row v-else style="text-align: center" align="middle">
|
|
|
|
|
<!-- 选择素材 -->
|
|
|
|
|
<el-col :span="12" class="col-select">
|
|
|
|
|
<el-button type="success" @click="openMaterial">
|
|
|
|
|
素材库选择
|
|
|
|
|
<icon icon="ep:circle-check" />
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-dialog title="选择图片" v-model="dialogImageVisible" width="90%" append-to-body>
|
|
|
|
|
<wx-material-select :obj-data="objDataRef" @selectMaterial="selectMaterial" />
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-col>
|
|
|
|
|
<!-- 文件上传 -->
|
|
|
|
|
<el-col :span="12" class="col-add">
|
|
|
|
|
<el-upload
|
|
|
|
|
:action="actionUrl"
|
|
|
|
|
:headers="headers"
|
|
|
|
|
multiple
|
|
|
|
|
:limit="1"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:data="uploadData"
|
|
|
|
|
:before-upload="beforeImageUpload"
|
|
|
|
|
:on-success="handleUploadSuccess"
|
|
|
|
|
>
|
|
|
|
|
<el-button type="primary">上传图片</el-button>
|
|
|
|
|
<template #tip>
|
|
|
|
|
<span>
|
|
|
|
|
<div class="el-upload__tip"
|
2023-03-27 03:18:25 +08:00
|
|
|
|
>支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M</div
|
2023-03-28 01:18:37 +08:00
|
|
|
|
></span
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-col>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
<!-- 类型 3:语音 -->
|
|
|
|
|
<el-tab-pane name="voice">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<template #label>
|
|
|
|
|
<el-row align="middle">
|
|
|
|
|
<icon icon="ep:phone" />
|
|
|
|
|
语音
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<div class="select-item2" v-if="objDataRef.url">
|
|
|
|
|
<p class="item-name">{{ objDataRef.name }}</p>
|
|
|
|
|
<div class="item-infos">
|
|
|
|
|
<wx-voice-player :url="objDataRef.url" />
|
|
|
|
|
</div>
|
|
|
|
|
<el-row class="ope-row">
|
|
|
|
|
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj" />
|
|
|
|
|
</el-row>
|
|
|
|
|
</div>
|
|
|
|
|
<el-row v-else style="text-align: center">
|
|
|
|
|
<!-- 选择素材 -->
|
|
|
|
|
<el-col :span="12" class="col-select">
|
|
|
|
|
<el-button type="success" @click="openMaterial">
|
|
|
|
|
素材库选择<i class="el-icon-circle-check el-icon--right"></i>
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-dialog title="选择语音" v-model="dialogVoiceVisible" width="90%" append-to-body>
|
|
|
|
|
<WxMaterialSelect :objData="objData" @selectMaterial="selectMaterial" />
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-col>
|
|
|
|
|
<!-- 文件上传 -->
|
|
|
|
|
<el-col :span="12" class="col-add">
|
|
|
|
|
<el-upload
|
|
|
|
|
:action="actionUrl"
|
|
|
|
|
:headers="headers"
|
|
|
|
|
multiple
|
|
|
|
|
:limit="1"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:data="uploadData"
|
|
|
|
|
:before-upload="beforeVoiceUpload"
|
|
|
|
|
:on-success="handleUploadSuccess"
|
|
|
|
|
>
|
|
|
|
|
<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>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
<!-- 类型 4:视频 -->
|
|
|
|
|
<el-tab-pane name="video">
|
|
|
|
|
<template #label>
|
|
|
|
|
<el-row align="middle">
|
|
|
|
|
<icon icon="ep:share" />
|
|
|
|
|
视频
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-row>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-input
|
|
|
|
|
v-model="objDataRef.title"
|
|
|
|
|
class="input-margin-bottom"
|
|
|
|
|
placeholder="请输入标题"
|
|
|
|
|
@input="inputContent"
|
|
|
|
|
/>
|
|
|
|
|
<el-input
|
|
|
|
|
class="input-margin-bottom"
|
|
|
|
|
v-model="objDataRef.description"
|
|
|
|
|
placeholder="请输入描述"
|
|
|
|
|
@input="inputContent"
|
|
|
|
|
/>
|
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
<wx-video-player v-if="objDataRef.url" :url="objDataRef.url" />
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</div>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-col>
|
|
|
|
|
<el-row style="text-align: center" align="middle">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<!-- 选择素材 -->
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-col :span="12">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-button type="success" @click="openMaterial">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
素材库选择
|
|
|
|
|
<icon icon="ep:circle-check" />
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-button>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-dialog title="选择视频" v-model="dialogVideoVisible" width="90%" append-to-body>
|
|
|
|
|
<wx-material-select :objData="objDataRef" @selectMaterial="selectMaterial" />
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-col>
|
|
|
|
|
<!-- 文件上传 -->
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-col :span="12">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-upload
|
|
|
|
|
:action="actionUrl"
|
|
|
|
|
:headers="headers"
|
|
|
|
|
multiple
|
|
|
|
|
:limit="1"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:data="uploadData"
|
2023-03-28 01:18:37 +08:00
|
|
|
|
:before-upload="beforeVideoUpload"
|
2023-03-27 03:18:25 +08:00
|
|
|
|
:on-success="handleUploadSuccess"
|
|
|
|
|
>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-button type="primary"
|
|
|
|
|
>新建视频
|
|
|
|
|
<icon icon="ep:upload" />
|
|
|
|
|
</el-button>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-upload>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
</el-col>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
<!-- 类型 5:图文 -->
|
|
|
|
|
<el-tab-pane name="news">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<template #label>
|
|
|
|
|
<el-row align="middle">
|
|
|
|
|
<icon icon="ep:reading" />
|
|
|
|
|
图文
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-row>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<div class="select-item" v-if="objDataRef.articles.size > 0">
|
|
|
|
|
<wx-news :articles="objDataRef.articles" />
|
|
|
|
|
<el-col class="ope-row">
|
|
|
|
|
<el-button type="danger" circle @click="deleteObj">
|
|
|
|
|
<icon icon="ep:delete" />
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</div>
|
|
|
|
|
<!-- 选择素材 -->
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-col :span="24" v-if="!objDataRef.content">
|
|
|
|
|
<el-row style="text-align: center" align="middle">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-button type="success" @click="openMaterial"
|
2023-03-28 01:18:37 +08:00
|
|
|
|
>{{ newsType === '1' ? '选择已发布图文' : '选择草稿箱图文' }}
|
|
|
|
|
<icon icon="ep:circle-check" />
|
|
|
|
|
</el-button>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
<el-dialog title="选择图文" v-model="dialogNewsVisible" width="90%" append-to-body>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<wx-material-select
|
2023-03-28 01:18:37 +08:00
|
|
|
|
:objData="objDataRef"
|
2023-03-27 03:18:25 +08:00
|
|
|
|
@selectMaterial="selectMaterial"
|
|
|
|
|
:newsType="newsType"
|
|
|
|
|
/>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
<!-- 类型 6:音乐 -->
|
|
|
|
|
<el-tab-pane name="music">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<template #label>
|
|
|
|
|
<el-row align="middle">
|
|
|
|
|
<icon icon="ep:service" />
|
|
|
|
|
音乐
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
<el-row align="middle" justify="center">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<el-col :span="6">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-row align="middle" justify="center" class="thumb-div">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-row align="middle" justify="center">
|
|
|
|
|
<img
|
|
|
|
|
style="width: 100px"
|
|
|
|
|
v-if="objDataRef.thumbMediaUrl"
|
|
|
|
|
:src="objDataRef.thumbMediaUrl"
|
|
|
|
|
/>
|
|
|
|
|
<icon v-else icon="ep:plus" />
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row align="middle" justify="center" style="margin-top: 2%">
|
|
|
|
|
<div class="thumb-but">
|
|
|
|
|
<el-upload
|
|
|
|
|
:action="actionUrl"
|
|
|
|
|
:headers="headers"
|
|
|
|
|
multiple
|
|
|
|
|
:limit="1"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:data="uploadData"
|
|
|
|
|
:before-upload="beforeThumbImageUpload"
|
|
|
|
|
:on-success="handleUploadSuccess"
|
|
|
|
|
>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<el-button type="text">本地上传</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
<el-button type="text" @click="openMaterial" style="margin-left: 5px"
|
|
|
|
|
>素材库选择
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</div>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-dialog title="选择图片" v-model="dialogThumbVisible" width="80%" append-to-body>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<wx-material-select
|
2023-03-28 01:18:37 +08:00
|
|
|
|
:objData="{ type: 'image', accountId: objDataRef.accountId }"
|
2023-03-27 03:18:25 +08:00
|
|
|
|
@selectMaterial="selectMaterial"
|
|
|
|
|
/>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="18">
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-input v-model="objDataRef.title" placeholder="请输入标题" @input="inputContent" />
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<div style="margin: 20px 0"></div>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-input
|
|
|
|
|
v-model="objDataRef.description"
|
|
|
|
|
placeholder="请输入描述"
|
|
|
|
|
@input="inputContent"
|
|
|
|
|
/>
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<div style="margin: 20px 0"></div>
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<el-input v-model="objDataRef.musicUrl" placeholder="请输入音乐链接" @input="inputContent" />
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<div style="margin: 20px 0"></div>
|
|
|
|
|
<el-input
|
2023-03-28 01:18:37 +08:00
|
|
|
|
v-model="objDataRef.hqMusicUrl"
|
2023-03-27 03:18:25 +08:00
|
|
|
|
placeholder="请输入高质量音乐链接"
|
|
|
|
|
@input="inputContent"
|
|
|
|
|
/>
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
</el-tabs>
|
|
|
|
|
</template>
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-28 01:18:37 +08:00
|
|
|
|
<script lang="ts" name="WxReplySelect">
|
2023-03-27 03:18:25 +08:00
|
|
|
|
import WxNews from '@/views/mp/components/wx-news/main.vue'
|
|
|
|
|
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
|
|
|
|
|
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
|
|
|
|
|
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
import { getAccessToken } from '@/utils/auth'
|
2023-03-28 01:18:37 +08:00
|
|
|
|
import { defineComponent } from 'vue'
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-28 01:18:37 +08:00
|
|
|
|
export default defineComponent({
|
2023-03-27 03:18:25 +08:00
|
|
|
|
components: {
|
|
|
|
|
WxNews,
|
|
|
|
|
WxMaterialSelect,
|
|
|
|
|
WxVoicePlayer,
|
|
|
|
|
WxVideoPlayer
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
objData: {
|
|
|
|
|
// 消息对象。
|
|
|
|
|
type: Object, // 设置为 Object 的原因,方便属性的传递
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
newsType: {
|
|
|
|
|
// 图文类型:1、已发布图文;2、草稿箱图文
|
|
|
|
|
type: String,
|
|
|
|
|
default: '1'
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-03-28 01:18:37 +08:00
|
|
|
|
setup(props) {
|
|
|
|
|
const objDataRef = reactive(props.objData)
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
const tempObj = new Map().set(objDataRef.type, Object.assign({}, objDataRef))
|
|
|
|
|
// ========== 素材选择的弹窗,是否可见 ==========
|
|
|
|
|
const dialogNewsVisible = ref(false) // 图文
|
|
|
|
|
const dialogImageVisible = ref(false) // 图片
|
|
|
|
|
const dialogVoiceVisible = ref(false) // 语音
|
|
|
|
|
const dialogVideoVisible = ref(false) // 视频
|
|
|
|
|
const dialogThumbVisible = ref(false) // 缩略图
|
|
|
|
|
// ========== 文件上传(图片、语音、视频) ==========
|
|
|
|
|
const fileList = ref([])
|
|
|
|
|
const uploadData = reactive({
|
|
|
|
|
accountId: undefined,
|
|
|
|
|
type: objDataRef.type,
|
|
|
|
|
title: '',
|
|
|
|
|
introduction: ''
|
|
|
|
|
})
|
|
|
|
|
const actionUrl = ref(
|
|
|
|
|
import.meta.env.VITE_API_BASEPATH + '/admin-api/mp/material/upload-temporary'
|
|
|
|
|
)
|
|
|
|
|
const headers = ref({ Authorization: 'Bearer ' + getAccessToken() }) // 设置上传的请求头部
|
|
|
|
|
const beforeThumbImageUpload = (file) => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
const isType =
|
|
|
|
|
file.type === 'image/jpeg' ||
|
|
|
|
|
file.type === 'image/png' ||
|
|
|
|
|
file.type === 'image/gif' ||
|
|
|
|
|
file.type === 'image/bmp' ||
|
|
|
|
|
file.type === 'image/jpg'
|
|
|
|
|
if (!isType) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传图片格式不对!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
const isLt = file.size / 1024 / 1024 < 2
|
|
|
|
|
if (!isLt) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传图片大小不能超过 2M!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
uploadData.accountId = objDataRef.accountId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return true
|
2023-03-28 01:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
const beforeVoiceUpload = (file) => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 校验格式
|
|
|
|
|
const isType =
|
|
|
|
|
file.type === 'audio/mp3' ||
|
|
|
|
|
file.type === 'audio/mpeg' ||
|
|
|
|
|
file.type === 'audio/wma' ||
|
|
|
|
|
file.type === 'audio/wav' ||
|
|
|
|
|
file.type === 'audio/amr'
|
|
|
|
|
if (!isType) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传语音格式不对!' + file.type)
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
// 校验大小
|
|
|
|
|
const isLt = file.size / 1024 / 1024 < 2
|
|
|
|
|
if (!isLt) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传语音大小不能超过 2M!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
uploadData.accountId = objDataRef.accountId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return true
|
2023-03-28 01:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
const beforeImageUpload = (file) => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 校验格式
|
|
|
|
|
const isType =
|
|
|
|
|
file.type === 'image/jpeg' ||
|
|
|
|
|
file.type === 'image/png' ||
|
|
|
|
|
file.type === 'image/gif' ||
|
|
|
|
|
file.type === 'image/bmp' ||
|
|
|
|
|
file.type === 'image/jpg'
|
|
|
|
|
if (!isType) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传图片格式不对!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
// 校验大小
|
|
|
|
|
const isLt = file.size / 1024 / 1024 < 2
|
|
|
|
|
if (!isLt) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传图片大小不能超过 2M!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
uploadData.accountId = objDataRef.accountId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return true
|
2023-03-28 01:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
const beforeVideoUpload = (file) => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 校验格式
|
|
|
|
|
const isType = file.type === 'video/mp4'
|
|
|
|
|
if (!isType) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传视频格式不对!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
// 校验大小
|
|
|
|
|
const isLt = file.size / 1024 / 1024 < 10
|
|
|
|
|
if (!isLt) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传视频大小不能超过 10M!')
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
uploadData.accountId = objDataRef.accountId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return true
|
2023-03-28 01:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
const handleUploadSuccess = (response) => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
if (response.code !== 0) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
message.error('上传出错:' + response.msg)
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 清空上传时的各种数据
|
2023-03-28 01:18:37 +08:00
|
|
|
|
fileList.value = []
|
|
|
|
|
uploadData.title = ''
|
|
|
|
|
uploadData.introduction = ''
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 上传好的文件,本质是个素材,所以可以进行选中
|
|
|
|
|
let item = response.data
|
2023-03-28 01:18:37 +08:00
|
|
|
|
selectMaterial(item)
|
|
|
|
|
}
|
2023-03-27 03:18:25 +08:00
|
|
|
|
/**
|
|
|
|
|
* 切换消息类型的 tab
|
|
|
|
|
*
|
2023-03-28 01:18:37 +08:00
|
|
|
|
* @param tab tab 没用 暂时删了tab
|
2023-03-27 03:18:25 +08:00
|
|
|
|
*/
|
2023-03-28 01:18:37 +08:00
|
|
|
|
const handleClick = () => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 设置后续文件上传的文件类型
|
2023-03-28 01:18:37 +08:00
|
|
|
|
uploadData.type = objDataRef.type
|
|
|
|
|
if (uploadData.type === 'music') {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 【音乐】上传的是缩略图
|
2023-03-28 01:18:37 +08:00
|
|
|
|
uploadData.type = 'thumb'
|
2023-03-27 03:18:25 +08:00
|
|
|
|
}
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-28 01:18:37 +08:00
|
|
|
|
// 从 tempObj 临时缓存中,获取对应的数据,并设置回 objDataRef
|
|
|
|
|
let tempObjItem = tempObj.get(objDataRef.type)
|
2023-03-27 03:18:25 +08:00
|
|
|
|
if (tempObjItem) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.content = tempObjItem.content ? tempObjItem.content : null
|
|
|
|
|
objDataRef.mediaId = tempObjItem.mediaId ? tempObjItem.mediaId : null
|
|
|
|
|
objDataRef.url = tempObjItem.url ? tempObjItem.url : null
|
|
|
|
|
objDataRef.name = tempObjItem.url ? tempObjItem.name : null
|
|
|
|
|
objDataRef.title = tempObjItem.title ? tempObjItem.title : null
|
|
|
|
|
objDataRef.description = tempObjItem.description ? tempObjItem.description : null
|
2023-03-27 03:18:25 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
// 如果获取不到,需要把 objDataRef 复原
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 必须使用 $set 赋值,不然 input 无法输入内容
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.content = ''
|
|
|
|
|
objDataRef.mediaId = ''
|
|
|
|
|
objDataRef.url = ''
|
|
|
|
|
objDataRef.title = ''
|
|
|
|
|
objDataRef.description = ''
|
|
|
|
|
}
|
2023-03-27 03:18:25 +08:00
|
|
|
|
/**
|
2023-03-28 01:18:37 +08:00
|
|
|
|
* 选择素材,将设置设置到 objDataRef 变量
|
2023-03-27 03:18:25 +08:00
|
|
|
|
*
|
|
|
|
|
* @param item 素材
|
|
|
|
|
*/
|
2023-03-28 01:18:37 +08:00
|
|
|
|
const selectMaterial = (item) => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 选择好素材,所以隐藏弹窗
|
2023-03-28 01:18:37 +08:00
|
|
|
|
closeMaterial()
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 创建 tempObjItem 对象,并设置对应的值
|
2023-03-28 01:18:37 +08:00
|
|
|
|
let tempObjItem = {
|
|
|
|
|
type: '',
|
|
|
|
|
articles: '',
|
|
|
|
|
thumbMediaId: '',
|
|
|
|
|
thumbMediaUrl: '',
|
|
|
|
|
introduction: '',
|
|
|
|
|
title: '',
|
|
|
|
|
musicUrl: '',
|
|
|
|
|
hqMusicUrl: '',
|
|
|
|
|
mediaId: '',
|
|
|
|
|
url: '',
|
|
|
|
|
name: '',
|
|
|
|
|
description: ''
|
|
|
|
|
}
|
|
|
|
|
tempObjItem.type = objDataRef.type
|
|
|
|
|
if (objDataRef.type === 'news') {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.articles = item.content.newsItem
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.articles = item.content.newsItem
|
|
|
|
|
} else if (objDataRef.type === 'music') {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 音乐需要特殊处理,因为选择的是图片的缩略图
|
|
|
|
|
tempObjItem.thumbMediaId = item.mediaId
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.thumbMediaId = item.mediaId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.thumbMediaUrl = item.url
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.thumbMediaUrl = item.url
|
|
|
|
|
// title、introduction、musicUrl、hqMusicUrl:从 objDataRef 到 tempObjItem,避免上传素材后,被覆盖掉
|
|
|
|
|
tempObjItem.title = objDataRef.title || ''
|
|
|
|
|
tempObjItem.introduction = objDataRef.introduction || ''
|
|
|
|
|
tempObjItem.musicUrl = objDataRef.musicUrl || ''
|
|
|
|
|
tempObjItem.hqMusicUrl = objDataRef.hqMusicUrl || ''
|
|
|
|
|
} else if (objDataRef.type === 'image' || objDataRef.type === 'voice') {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.mediaId = item.mediaId
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.mediaId = item.mediaId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.url = item.url
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.url = item.url
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.name = item.name
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.name = item.name
|
|
|
|
|
} else if (objDataRef.type === 'video') {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.mediaId = item.mediaId
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.mediaId = item.mediaId
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.url = item.url
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.url = item.url
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.name = item.name
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.name = item.name
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// title、introduction:从 item 到 tempObjItem,因为素材里有 title、introduction
|
|
|
|
|
if (item.title) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.title = item.title || ''
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.title = item.title || ''
|
|
|
|
|
}
|
|
|
|
|
if (item.introduction) {
|
2023-03-28 01:18:37 +08:00
|
|
|
|
objDataRef.description = item.introduction || '' // 消息使用的是 description,素材使用的是 introduction,所以转换下
|
2023-03-27 03:18:25 +08:00
|
|
|
|
tempObjItem.description = item.introduction || ''
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
} else if (objDataRef.type === 'text') {
|
|
|
|
|
objDataRef.content = item.content || ''
|
2023-03-27 03:18:25 +08:00
|
|
|
|
}
|
|
|
|
|
// 最终设置到临时缓存
|
2023-03-28 01:18:37 +08:00
|
|
|
|
tempObj.set(objDataRef.type, tempObjItem)
|
|
|
|
|
}
|
|
|
|
|
const openMaterial = () => {
|
|
|
|
|
if (objDataRef.type === 'news') {
|
|
|
|
|
dialogNewsVisible.value = true
|
|
|
|
|
} else if (objDataRef.type === 'image') {
|
|
|
|
|
dialogImageVisible.value = true
|
|
|
|
|
} else if (objDataRef.type === 'voice') {
|
|
|
|
|
dialogVoiceVisible.value = true
|
|
|
|
|
} else if (objDataRef.type === 'video') {
|
|
|
|
|
dialogVideoVisible.value = true
|
|
|
|
|
} else if (objDataRef.type === 'music') {
|
|
|
|
|
dialogThumbVisible.value = true
|
2023-03-27 03:18:25 +08:00
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
const closeMaterial = () => {
|
|
|
|
|
dialogNewsVisible.value = false
|
|
|
|
|
dialogImageVisible.value = false
|
|
|
|
|
dialogVoiceVisible.value = false
|
|
|
|
|
dialogVideoVisible.value = false
|
|
|
|
|
dialogThumbVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
const deleteObj = () => {
|
|
|
|
|
if (objDataRef.type === 'news') {
|
|
|
|
|
objDataRef.articles = ''
|
|
|
|
|
} else if (objDataRef.type === 'image') {
|
|
|
|
|
objDataRef.mediaId = null
|
|
|
|
|
objDataRef.url = null
|
|
|
|
|
objDataRef.name = null
|
|
|
|
|
} else if (objDataRef.type === 'voice') {
|
|
|
|
|
objDataRef.mediaId = null
|
|
|
|
|
objDataRef.url = null
|
|
|
|
|
objDataRef.name = null
|
|
|
|
|
} else if (objDataRef.type === 'video') {
|
|
|
|
|
objDataRef.mediaId = null
|
|
|
|
|
objDataRef.url = null
|
|
|
|
|
objDataRef.name = null
|
|
|
|
|
objDataRef.title = null
|
|
|
|
|
objDataRef.description = null
|
|
|
|
|
} else if (objDataRef.type === 'music') {
|
|
|
|
|
objDataRef.thumbMediaId = null
|
|
|
|
|
objDataRef.thumbMediaUrl = null
|
|
|
|
|
objDataRef.title = null
|
|
|
|
|
objDataRef.description = null
|
|
|
|
|
objDataRef.musicUrl = null
|
|
|
|
|
objDataRef.hqMusicUrl = null
|
|
|
|
|
} else if (objDataRef.type === 'text') {
|
|
|
|
|
objDataRef.content = null
|
2023-03-27 03:18:25 +08:00
|
|
|
|
}
|
|
|
|
|
// 覆盖缓存
|
2023-03-28 01:18:37 +08:00
|
|
|
|
tempObj.set(objDataRef.type, Object.assign({}, objDataRef))
|
|
|
|
|
}
|
2023-03-27 03:18:25 +08:00
|
|
|
|
/**
|
2023-03-28 01:18:37 +08:00
|
|
|
|
* 输入时,缓存每次 objDataRef 到 tempObj 中
|
2023-03-27 03:18:25 +08:00
|
|
|
|
*
|
2023-03-28 01:18:37 +08:00
|
|
|
|
* why?不确定为什么 v-model="objDataRef.content" 不能自动缓存,所以通过这样的方式
|
2023-03-27 03:18:25 +08:00
|
|
|
|
*/
|
2023-03-28 01:18:37 +08:00
|
|
|
|
const inputContent = () => {
|
2023-03-27 03:18:25 +08:00
|
|
|
|
// 覆盖缓存
|
2023-03-28 01:18:37 +08:00
|
|
|
|
tempObj.set(objDataRef.type, Object.assign({}, objDataRef))
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
inputContent,
|
|
|
|
|
dialogNewsVisible,
|
|
|
|
|
deleteObj,
|
|
|
|
|
openMaterial,
|
|
|
|
|
handleClick,
|
|
|
|
|
beforeImageUpload,
|
|
|
|
|
beforeVoiceUpload,
|
|
|
|
|
handleUploadSuccess,
|
|
|
|
|
beforeVideoUpload,
|
|
|
|
|
selectMaterial,
|
|
|
|
|
dialogImageVisible,
|
|
|
|
|
dialogVoiceVisible,
|
|
|
|
|
dialogThumbVisible,
|
|
|
|
|
actionUrl,
|
|
|
|
|
objDataRef,
|
|
|
|
|
headers,
|
|
|
|
|
fileList,
|
|
|
|
|
beforeThumbImageUpload,
|
|
|
|
|
uploadData,
|
|
|
|
|
dialogVideoVisible
|
2023-03-27 03:18:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
})
|
2023-03-27 03:18:25 +08:00
|
|
|
|
</script>
|
2023-03-26 04:25:34 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.public-account-management {
|
|
|
|
|
.el-input {
|
|
|
|
|
width: 70%;
|
|
|
|
|
margin-right: 2%;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.pagination {
|
|
|
|
|
text-align: right;
|
|
|
|
|
margin-right: 25px;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.select-item {
|
|
|
|
|
width: 280px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
margin: 0 auto 10px auto;
|
|
|
|
|
border: 1px solid #eaeaea;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.select-item2 {
|
|
|
|
|
padding: 10px;
|
|
|
|
|
margin: 0 auto 10px auto;
|
|
|
|
|
border: 1px solid #eaeaea;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.ope-row {
|
|
|
|
|
padding-top: 10px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
|
|
|
|
.input-margin-bottom {
|
|
|
|
|
margin-bottom: 2%;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.item-name {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.el-form-item__content {
|
|
|
|
|
line-height: unset !important;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.col-select {
|
|
|
|
|
border: 1px solid rgb(234, 234, 234);
|
|
|
|
|
padding: 50px 0px;
|
|
|
|
|
height: 160px;
|
|
|
|
|
width: 49.5%;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.col-select2 {
|
|
|
|
|
border: 1px solid rgb(234, 234, 234);
|
|
|
|
|
padding: 50px 0px;
|
|
|
|
|
height: 160px;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.col-add {
|
|
|
|
|
border: 1px solid rgb(234, 234, 234);
|
|
|
|
|
padding: 50px 0px;
|
|
|
|
|
height: 160px;
|
|
|
|
|
width: 49.5%;
|
|
|
|
|
float: right;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.avatar-uploader-icon {
|
|
|
|
|
border: 1px solid #d9d9d9;
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
color: #8c939d;
|
|
|
|
|
width: 100px !important;
|
|
|
|
|
height: 100px !important;
|
|
|
|
|
line-height: 100px !important;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.material-img {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.thumb-div {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2023-03-28 01:18:37 +08:00
|
|
|
|
|
2023-03-27 03:18:25 +08:00
|
|
|
|
.item-infos {
|
|
|
|
|
width: 30%;
|
|
|
|
|
margin: auto;
|
|
|
|
|
}
|
|
|
|
|
</style>
|