!70 微信组件按照vue3的方式重写了一遍

Merge pull request !70 from &wxr/dev
This commit is contained in:
芋道源码 2023-03-28 16:02:31 +00:00 committed by Gitee
commit e3bcfa50e9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 1287 additions and 893 deletions

View File

@ -29,6 +29,7 @@
"@form-create/designer": "^3.1.0", "@form-create/designer": "^3.1.0",
"@form-create/element-ui": "^3.1.17", "@form-create/element-ui": "^3.1.17",
"@iconify/iconify": "^3.1.0", "@iconify/iconify": "^3.1.0",
"@videojs-player/vue": "^1.0.0",
"@vueuse/core": "^9.13.0", "@vueuse/core": "^9.13.0",
"@wangeditor/editor": "^5.1.23", "@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.10", "@wangeditor/editor-for-vue": "^5.1.10",
@ -58,6 +59,7 @@
"qs": "^6.11.1", "qs": "^6.11.1",
"steady-xml": "^0.1.0", "steady-xml": "^0.1.0",
"url": "^0.11.0", "url": "^0.11.0",
"video.js": "^8.0.4",
"vue": "3.2.47", "vue": "3.2.47",
"vue-i18n": "9.2.2", "vue-i18n": "9.2.2",
"vue-router": "^4.1.6", "vue-router": "^4.1.6",

BIN
src/assets/imgs/profile.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
src/assets/imgs/wechat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,302 @@
<!--
- Copyright (C) 2018-2019
- All rights reserved, Designed By www.joolun.com
芋道源码
移除 avue 组件使用 ElementUI 原生组件
-->
<template>
<!-- 类型图片 -->
<div v-if="objData.type === 'image'">
<div class="waterfall" v-loading="loading">
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
<img class="material-img" :src="item.url" />
<p class="item-name">{{ item.name }}</p>
<el-row class="ope-row">
<el-button type="success" @click="selectMaterialFun(item)"
>选择
<i class="el-icon-circle-check el-icon--right"></i>
</el-button>
</el-row>
</div>
</div>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getMaterialPageFun"
/>
</div>
<!-- 类型语音 -->
<div v-else-if="objData.type === 'voice'">
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="mediaId" />
<el-table-column label="文件名" align="center" prop="name" />
<el-table-column label="语音" align="center">
<template #default="scope">
<wx-voice-player :url="scope.row.url" />
</template>
</el-table-column>
<el-table-column label="上传时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
fixed="right"
class-name="small-padding fixed-width"
>
<template #default="scope">
<el-button type="text" icon="el-icon-circle-plus" @click="selectMaterialFun(scope.row)"
>选择
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getPage"
/>
</div>
<div v-else-if="objData.type === 'video'">
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="mediaId" />
<el-table-column label="文件名" align="center" prop="name" />
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="介绍" align="center" prop="introduction" />
<el-table-column label="视频" align="center">
<template #default="scope">
<wx-video-player :url="scope.row.url" />
</template>
</el-table-column>
<el-table-column label="上传时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
fixed="right"
class-name="small-padding fixed-width"
>
<template #default="scope">
<el-button type="text" icon="el-icon-circle-plus" @click="selectMaterialFun(scope.row)"
>选择
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getMaterialPageFun"
/>
</div>
<div v-else-if="objData.type === 'news'">
<div class="waterfall" v-loading="loading">
<div class="waterfall-item" v-for="item in list" :key="item.mediaId">
<div v-if="item.content && item.content.newsItem">
<wx-news :articles="item.content.newsItem" />
<el-row class="ope-row">
<el-button type="success" @click="selectMaterialFun(item)">
选择<i class="el-icon-circle-check el-icon--right"></i>
</el-button>
</el-row>
</div>
</div>
</div>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getMaterialPageFun"
/>
</div>
</template>
<script lang="ts" name="WxMaterialSelect">
import WxNews from '@/views/mp/components/wx-news/main.vue'
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
import { getMaterialPage } from '@/api/mp/material'
import { getFreePublishPage } from '@/api/mp/freePublish'
import { getDraftPage } from '@/api/mp/draft'
import { dateFormatter, parseTime } from '@/utils/formatTime'
import { defineComponent, PropType } from 'vue'
export default defineComponent({
components: {
WxNews,
WxVoicePlayer,
WxVideoPlayer
},
props: {
objData: {
type: Object, // type - accountId -
required: true
},
newsType: {
// 12稿
type: String as PropType<string>,
default: '1'
}
},
setup(props, ctx) {
//
const loading = ref(false)
//
const total = ref(0)
//
const list = ref([])
//
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
accountId: props.objData.accountId
})
const objDataRef = reactive(props.objData)
const newsTypeRef = ref(props.newsType)
const selectMaterialFun = (item) => {
ctx.emit('selectMaterial', item)
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getPage()
}
const getPage = () => {
loading.value = true
if (objDataRef.type === 'news' && newsTypeRef.value === '1') {
// +
getFreePublishPageFun()
} else if (objDataRef.type === 'news' && newsTypeRef.value === '2') {
// + 稿
getDraftPageFun()
} else {
//
getMaterialPageFun()
}
}
const getMaterialPageFun = async () => {
let data = await getMaterialPage({
...queryParams,
type: objDataRef.type
})
list.value = data.list
total.value = data.total
loading.value = false
}
const getFreePublishPageFun = async () => {
let data = await getFreePublishPage(queryParams)
data.list.foreach((item) => {
const newsItem = item.content.newsItem
newsItem.forEach((article) => {
article.picUrl = article.thumbUrl
})
})
list.value = data.list
total.value = data.total
loading.value = false
}
const getDraftPageFun = async () => {
let data = await getDraftPage(queryParams)
data.list.forEach((item) => {
const newsItem = item.content.newsItem
newsItem.forEach((article) => {
article.picUrl = article.thumbUrl
})
})
list.value = data.list
total.value = data.total
loading.value = false
}
onMounted(async () => {
getPage()
})
return {
handleQuery,
dateFormatter,
selectMaterialFun,
getMaterialPageFun,
getPage,
parseTime,
newsTypeRef,
queryParams,
objDataRef,
list,
total,
loading
}
}
})
</script>
<style lang="scss" scoped>
/*瀑布流样式*/
.waterfall {
width: 100%;
column-gap: 10px;
column-count: 5;
margin: 0 auto;
}
.waterfall-item {
padding: 10px;
margin-bottom: 10px;
break-inside: avoid;
border: 1px solid #eaeaea;
}
.material-img {
width: 100%;
}
p {
line-height: 30px;
}
@media (min-width: 992px) and (max-width: 1300px) {
.waterfall {
column-count: 3;
}
p {
color: red;
}
}
@media (min-width: 768px) and (max-width: 991px) {
.waterfall {
column-count: 2;
}
p {
color: orange;
}
}
@media (max-width: 767px) {
.waterfall {
column-count: 1;
}
}
/*瀑布流样式*/
</style>

View File

@ -6,7 +6,7 @@
代码优化补充注释提升阅读性 代码优化补充注释提升阅读性
--> -->
<template> <template>
<div class="msg-main"> <ContentWrap>
<div class="msg-div" :id="'msg-div' + nowStr"> <div class="msg-div" :id="'msg-div' + nowStr">
<!-- 加载更多 --> <!-- 加载更多 -->
<div v-loading="loading"></div> <div v-loading="loading"></div>
@ -26,9 +26,9 @@
:src="item.sendFrom === 1 ? user.avatar : mp.avatar" :src="item.sendFrom === 1 ? user.avatar : mp.avatar"
class="avue-comment__avatar" class="avue-comment__avatar"
/> />
<div class="avue-comment__author">{{ <div class="avue-comment__author"
item.sendFrom === 1 ? user.nickname : mp.nickname >{{ item.sendFrom === 1 ? user.nickname : mp.nickname }}
}}</div> </div>
</div> </div>
<div class="avue-comment__main"> <div class="avue-comment__main">
<div class="avue-comment__header"> <div class="avue-comment__header">
@ -40,37 +40,41 @@
> >
<!-- 事件区域 --> <!-- 事件区域 -->
<div v-if="item.type === 'event' && item.event === 'subscribe'"> <div v-if="item.type === 'event' && item.event === 'subscribe'">
<el-tag type="success" size="mini">关注</el-tag> <el-tag type="success">关注</el-tag>
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'unsubscribe'"> <div v-else-if="item.type === 'event' && item.event === 'unsubscribe'">
<el-tag type="danger" size="mini">取消关注</el-tag> <el-tag type="danger">取消关注</el-tag>
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'CLICK'"> <div v-else-if="item.type === 'event' && item.event === 'CLICK'">
<el-tag size="mini">点击菜单</el-tag>{{ item.eventKey }} <el-tag>点击菜单</el-tag>
{{ item.eventKey }}
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'VIEW'"> <div v-else-if="item.type === 'event' && item.event === 'VIEW'">
<el-tag size="mini">点击菜单链接</el-tag>{{ item.eventKey }} <el-tag>点击菜单链接</el-tag>
{{ item.eventKey }}
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'scancode_waitmsg'"> <div v-else-if="item.type === 'event' && item.event === 'scancode_waitmsg'">
<el-tag size="mini">扫码结果</el-tag>{{ item.eventKey }} <el-tag>扫码结果</el-tag>
{{ item.eventKey }}
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'scancode_push'"> <div v-else-if="item.type === 'event' && item.event === 'scancode_push'">
<el-tag size="mini">扫码结果</el-tag>{{ item.eventKey }} <el-tag>扫码结果</el-tag>
{{ item.eventKey }}
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'pic_sysphoto'"> <div v-else-if="item.type === 'event' && item.event === 'pic_sysphoto'">
<el-tag size="mini">系统拍照发图</el-tag> <el-tag>系统拍照发图</el-tag>
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'pic_photo_or_album'"> <div v-else-if="item.type === 'event' && item.event === 'pic_photo_or_album'">
<el-tag size="mini">拍照或者相册</el-tag> <el-tag>拍照或者相册</el-tag>
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'pic_weixin'"> <div v-else-if="item.type === 'event' && item.event === 'pic_weixin'">
<el-tag size="mini">微信相册</el-tag> <el-tag>微信相册</el-tag>
</div> </div>
<div v-else-if="item.type === 'event' && item.event === 'location_select'"> <div v-else-if="item.type === 'event' && item.event === 'location_select'">
<el-tag size="mini">选择地理位置</el-tag> <el-tag>选择地理位置</el-tag>
</div> </div>
<div v-else-if="item.type === 'event'"> <div v-else-if="item.type === 'event'">
<el-tag type="danger" size="mini">未知事件类型</el-tag> <el-tag type="danger">未知事件类型</el-tag>
</div> </div>
<!-- 消息区域 --> <!-- 消息区域 -->
<div v-else-if="item.type === 'text'">{{ item.content }}</div> <div v-else-if="item.type === 'text'">{{ item.content }}</div>
@ -124,10 +128,10 @@
<wx-reply-select ref="replySelect" :objData="objData" /> <wx-reply-select ref="replySelect" :objData="objData" />
<el-button type="success" size="small" class="send-but" @click="sendMsg">发送(S)</el-button> <el-button type="success" size="small" class="send-but" @click="sendMsg">发送(S)</el-button>
</div> </div>
</div> </ContentWrap>
</template> </template>
<script> <script lang="ts" name="WxMsg">
import { getMessagePage, sendMessage } from '@/api/mp/message' import { getMessagePage, sendMessage } from '@/api/mp/message'
import WxReplySelect from '@/views/mp/components/wx-reply/main.vue' import WxReplySelect from '@/views/mp/components/wx-reply/main.vue'
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue' import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
@ -136,9 +140,14 @@ import WxNews from '@/views/mp/components/wx-news/main.vue'
import WxLocation from '@/views/mp/components/wx-location/main.vue' import WxLocation from '@/views/mp/components/wx-location/main.vue'
import WxMusic from '@/views/mp/components/wx-music/main.vue' import WxMusic from '@/views/mp/components/wx-music/main.vue'
import { getUser } from '@/api/mp/mpuser' import { getUser } from '@/api/mp/mpuser'
import { defineComponent } from 'vue'
export default { const message = useMessage() //
name: 'WxMsg', import profile from '@/assets/imgs/profile.jpg'
import wechat from '@/assets/imgs/wechat.png'
import { parseTime } from '@/utils/formatTime'
export default defineComponent({
components: { components: {
WxReplySelect, WxReplySelect,
WxVideoPlayer, WxVideoPlayer,
@ -153,160 +162,144 @@ export default {
required: true required: true
} }
}, },
data() { setup(props) {
return { const nowStr = ref(new Date().getTime()) // :id="'msg-div' + nowStr"
nowStr: new Date().getTime(), // :id="'msg-div' + nowStr" const loading = ref(false) //
loading: false, // const loadMore = ref(true) //
loadMore: true, // const list = ref<any[]>([]) //
list: [], // const queryParams = reactive({
queryParams: { pageNo: 1, //
pageNo: 1, // pageSize: 14, //
pageSize: 14, // accountId: undefined
accountId: undefined
},
user: {
// 使
nickname: '用户',
avatar: require('@/assets/images/profile.jpg'),
accountId: 0 //
},
mp: {
nickname: '公众号',
avatar: require('@/assets/images/wechat.png')
},
// ========= =========
sendLoading: false, //
objData: {
//
type: 'text'
}
}
},
created() {
//
getUser(this.userId).then((response) => {
this.user.nickname =
response.data.nickname && response.data.nickname.length > 0
? response.data.nickname
: this.user.nickname
this.user.avatar =
response.data.avatar && this.user.avatar.length > 0
? response.data.avatar
: this.user.avatar
this.user.accountId = response.data.accountId
//
this.queryParams.accountId = response.data.accountId
this.objData.accountId = response.data.accountId
//
console.log(this.queryParams)
this.refreshChange()
}) })
}, const user = reactive({
methods: { // 使
sendMsg() { nickname: '用户',
if (!this.objData) { avatar: profile,
accountId: 0 //
})
const mp = reactive({
nickname: '公众号',
avatar: wechat
})
// ========= =========
const sendLoading = ref(false) //
const objData = reactive({
//
type: 'text',
accountId: null,
articles: []
})
const replySelect = ref(null)
//
const sendMsg = async () => {
if (!objData) {
return return
} }
// // //
if (this.objData.type === 'news' && this.objData.articles.length > 1) { if (objData.type === 'news' && objData.articles.length > 1) {
this.objData.articles = [this.objData.articles[0]] objData.articles = [objData.articles[0]]
this.$message({ message.success('图文消息条数限制在 1 条以内,已默认发送第一条')
showClose: true,
message: '图文消息条数限制在 1 条以内,已默认发送第一条',
type: 'success'
})
} }
let data = await sendMessage(Object.assign({ userId: props.userId }, { ...objData }))
// sendLoading.value = false
this.sendLoading = true list.value = [...list.value, ...[data]]
sendMessage( scrollToBottom()
Object.assign( //ts
{ // tab
userId: this.userId const deleteObj = (replySelect.value as any).deleteObj
}, if (deleteObj) {
{ deleteObj()
...this.objData }
} }
) const loadingMore = () => {
) queryParams.pageNo++
.then((response) => { getPage(queryParams, null)
this.sendLoading = false }
// const getPage = async (page, params) => {
this.list = [...this.list, ...[response.data]] loading.value = true
this.scrollToBottom() let dataTemp = await getMessagePage(
// objData
this.$refs['replySelect'].deleteObj() // tab
})
.catch(() => {
this.sendLoading = false
})
},
loadingMore() {
this.queryParams.pageNo++
this.getPage(this.queryParams)
},
getPage(page, params) {
this.loading = true
getMessagePage(
Object.assign( Object.assign(
{ {
pageNo: page.pageNo, pageNo: page.pageNo,
pageSize: page.pageSize, pageSize: page.pageSize,
userId: this.userId, userId: props.userId,
accountId: page.accountId accountId: page.accountId
}, },
params params
) )
).then((response) => { )
// const msgDiv = document.getElementById('msg-div' + nowStr.value)
const msgDiv = document.getElementById('msg-div' + this.nowStr) let scrollHeight = 0
let scrollHeight = 0 if (msgDiv) {
if (msgDiv) { scrollHeight = msgDiv.scrollHeight
scrollHeight = msgDiv.scrollHeight }
} //
let data = dataTemp.list.reverse()
// list.value = [...data, ...list.value]
const data = response.data.list.reverse() loading.value = false
this.list = [...data, ...this.list] if (data.length < queryParams.pageSize || data.length === 0) {
this.loading = false loadMore.value = false
if (data.length < this.queryParams.pageSize || data.length === 0) { }
this.loadMore = false queryParams.pageNo = page.pageNo
} queryParams.pageSize = page.pageSize
this.queryParams.pageNo = page.pageNo //
this.queryParams.pageSize = page.pageSize if (queryParams.pageNo === 1) {
//
// scrollToBottom()
if (this.queryParams.pageNo === 1) { } else if (data.length !== 0) {
// //
this.scrollToBottom() await nextTick(() => {
} else if (data.length !== 0) { if (scrollHeight !== 0) {
// let div = document.getElementById('msg-div' + nowStr.value)
this.$nextTick(() => { if (div && msgDiv) {
if (scrollHeight !== 0) { msgDiv.scrollTop = div.scrollHeight - scrollHeight - 100
msgDiv.scrollTop =
document.getElementById('msg-div' + this.nowStr).scrollHeight - scrollHeight - 100
} }
}) }
} })
}) }
}, }
/** const refreshChange = () => {
* 刷新回调 getPage(queryParams, null)
*/ }
refreshChange() {
this.getPage(this.queryParams)
},
/** 定位到消息底部 */ /** 定位到消息底部 */
scrollToBottom: function () { const scrollToBottom = () => {
this.$nextTick(() => { nextTick(() => {
let div = document.getElementById('msg-div' + this.nowStr) let div = document.getElementById('msg-div' + nowStr.value)
div.scrollTop = div.scrollHeight if (div) {
div.scrollTop = div.scrollHeight
}
}) })
} }
onMounted(async () => {
let data = await getUser(props.userId)
user.nickname = data.nickname && data.nickname.length > 0 ? data.nickname : user.nickname
user.avatar = data.avatar && user.avatar.length > 0 ? data.avatar : user.avatar
user.accountId = data.accountId
queryParams.accountId = data.accountId
objData.accountId = data.accountId
refreshChange()
})
return {
sendMsg,
loadingMore,
parseTime,
scrollToBottom,
objData,
mp,
user,
queryParams,
list,
loadMore,
loading,
nowStr,
sendLoading
}
} }
} })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/* 因为 joolun 实现依赖 avue 组件,该页面使用了 comment.scss、card.scc */ /* 因为 joolun 实现依赖 avue 组件,该页面使用了 comment.scss、card.scc */
@ -317,6 +310,7 @@ export default {
margin-top: -30px; margin-top: -30px;
padding: 10px; padding: 10px;
} }
.msg-div { .msg-div {
height: 50vh; height: 50vh;
overflow: auto; overflow: auto;
@ -324,13 +318,16 @@ export default {
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
} }
.msg-send { .msg-send {
padding: 10px; padding: 10px;
} }
.avatar-div { .avatar-div {
text-align: center; text-align: center;
width: 80px; width: 80px;
} }
.send-but { .send-but {
float: right; float: right;
margin-top: 8px !important; margin-top: 8px !important;

File diff suppressed because it is too large Load Diff

View File

@ -8,110 +8,78 @@
存在的问题mediaId 有效期是 3 超过时间后无法播放 存在的问题mediaId 有效期是 3 超过时间后无法播放
2重构后的做法后端接收到微信公众号的视频消息后将视频消息的 media_id 的文件内容保存到文件服务器中这样前端可以直接使用 URL 播放 2重构后的做法后端接收到微信公众号的视频消息后将视频消息的 media_id 的文件内容保存到文件服务器中这样前端可以直接使用 URL 播放
体验优化弹窗关闭后自动暂停视频的播放 体验优化弹窗关闭后自动暂停视频的播放
--> -->
<template> <template>
<div> <div @click="playVideo()">
<!-- 提示 --> <!-- 提示 -->
<div @click="playVideo()"> <div>
<el-icon> <Icon icon="ep:video-play" class="mr-5px" />
<VideoPlay />
</el-icon>
<p>点击播放视频</p> <p>点击播放视频</p>
</div> </div>
<!-- 弹窗播放 --> <!-- 弹窗播放 -->
<el-dialog <el-dialog v-model="dialogVideo" title="视频播放" width="40%" append-to-body>
title="视频播放" <template #footer>
v-model:visible="dialogVideo" <video-player
width="40%" v-if="dialogVideo"
append-to-body class="video-player vjs-big-play-centered"
@close="closeDialog" :src="url"
> poster=""
<video-player crossorigin="anonymous"
v-if="playerOptions.sources[0].src" playsinline
class="video-player vjs-custom-skin" controls
ref="videoPlayerRef" :volume="0.6"
:playsinline="true" :height="320"
:options="playerOptions" :playback-rates="[0.7, 1.0, 1.5, 2.0]"
@play="onPlayerPlay($event)" />
@pause="onPlayerPause($event)" </template>
/> <!-- 事件暫時沒用
@mounted="handleMounted"-->
<!-- @ready="handleEvent($event)"-->
<!-- @play="handleEvent($event)"-->
<!-- @pause="handleEvent($event)"-->
<!-- @ended="handleEvent($event)"-->
<!-- @loadeddata="handleEvent($event)"-->
<!-- @waiting="handleEvent($event)"-->
<!-- @playing="handleEvent($event)"-->
<!-- @canplay="handleEvent($event)"-->
<!-- @canplaythrough="handleEvent($event)"-->
<!-- @timeupdate="handleEvent(player?.currentTime())"-->
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup lang="ts" name="WxVideoPlayer"> <script lang="ts" name="WxVideoPlayer">
// videoPlayer https://juejin.cn/post/6923056942281654285 //videojs6.0,6.0
import { videoPlayer } from 'vue-video-player' import 'video.js/dist/video-js.css'
import { defineComponent } from 'vue'
import { VideoPlayer } from '@videojs-player/vue'
import 'video.js/dist/video-js.css' import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
import { VideoPlay } from '@element-plus/icons-vue'
const props = defineProps({ export default defineComponent({
url: { components: {
// https://www.iocoder.cn/xxx.mp4 VideoPlayer
type: String, },
required: true props: {
} url: {
}) // https://vjs.zencdn.net/v/oceans.mp4
const videoPlayerRef = ref() type: String,
const dialogVideo = ref(false) required: true
const playerOptions = reactive({
playbackRates: [0.5, 1.0, 1.5, 2.0], //
autoplay: false, // true,
muted: false, //
loop: false, //
preload: 'auto', // <video> auto ,
language: 'zh-CN',
aspectRatio: '16:9', // 使 - "16:9""4:3"
fluid: true, // trueVideo.js player
sources: [
{
type: 'video/mp4',
src: '' //
} }
], },
poster: '', // setup() {
width: document.documentElement.clientWidth, // const videoPlayerRef = ref(null)
notSupportedMessage: '此视频暂无法播放,请稍后再试', // Video.js const dialogVideo = ref(false)
controlBar: {
timeDivider: true, const handleEvent = (log) => {
durationDisplay: true, console.log('Basic player event', log)
remainingTimeDisplay: false, }
fullscreenToggle: true // const playVideo = () => {
dialogVideo.value = true
}
return { handleEvent, playVideo, dialogVideo }
} }
}) })
const playVideo = () => {
dialogVideo.value = true
playerOptions.sources[0].src = props.url
}
const closeDialog = () => {
//
// videoPlayerRef.player.pause()
}
// onPlayerPlay(player) {},
// // // eslint-disable-next-line @typescript-eslint/no-unused-vars
// // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
// onPlayerPause(player) {}
// methods: {
// playVideo() {
// this.dialogVideo = true
// //
// this.playerOptions.sources[0]['src'] = this.url
// },
// closeDialog() {
// //
// this.$refs.videoPlayer.player.pause()
// },
//
// //todo player
//
// // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
// onPlayerPlay(player) {},
// // // eslint-disable-next-line @typescript-eslint/no-unused-vars
// // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
// onPlayerPause(player) {}
// }
</script> </script>

View File

@ -25,6 +25,7 @@
<script setup lang="ts" name="WxVoicePlayer"> <script setup lang="ts" name="WxVoicePlayer">
// amr amr https://www.npmjs.com/package/benz-amr-recorder // amr amr https://www.npmjs.com/package/benz-amr-recorder
import BenzAMRRecorder from 'benz-amr-recorder' import BenzAMRRecorder from 'benz-amr-recorder'
const props = defineProps({ const props = defineProps({

View File

@ -19,8 +19,14 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery">
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> <Icon icon="ep:search" class="mr-5px" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" />
重置
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</content-wrap> </content-wrap>
@ -63,12 +69,19 @@
import { getFreePublishPage, deleteFreePublish } from '@/api/mp/freePublish' import { getFreePublishPage, deleteFreePublish } from '@/api/mp/freePublish'
import * as MpAccountApi from '@/api/mp/account' import * as MpAccountApi from '@/api/mp/account'
import WxNews from '@/views/mp/components/wx-news/main.vue' import WxNews from '@/views/mp/components/wx-news/main.vue'
const message = useMessage() // const message = useMessage() //
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryParams = reactive({ interface QueryParams {
currentPage: number | undefined | string
pageNo: number | undefined | string
accountId: number | undefined | string
}
const queryParams: QueryParams = reactive({
currentPage: 1, // currentPage: 1, //
pageNo: 1, // pageNo: 1, //
accountId: undefined // accountId: undefined //
@ -115,7 +128,6 @@ const resetQuery = () => {
queryFormRef.value.resetFields() queryFormRef.value.resetFields()
// //
if (accountList.value.length > 0) { if (accountList.value.length > 0) {
// @ts-ignore
queryParams.accountId = accountList.value[0].id queryParams.accountId = accountList.value[0].id
} }
handleQuery() handleQuery()
@ -144,7 +156,6 @@ onMounted(async () => {
accountList.value = await MpAccountApi.getSimpleAccountList() accountList.value = await MpAccountApi.getSimpleAccountList()
// //
if (accountList.value.length > 0) { if (accountList.value.length > 0) {
// @ts-ignore
queryParams.accountId = accountList.value[0].id queryParams.accountId = accountList.value[0].id
} }
await getList() await getList()

View File

@ -51,8 +51,14 @@
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery">
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> <Icon icon="ep:search" class="mr-5px" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" />
重置
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</ContentWrap> </ContentWrap>
@ -85,16 +91,20 @@
<el-tag type="danger">取消关注</el-tag> <el-tag type="danger">取消关注</el-tag>
</div> </div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'CLICK'"> <div v-else-if="scope.row.type === 'event' && scope.row.event === 'CLICK'">
<el-tag>点击菜单</el-tag>{{ scope.row.eventKey }} <el-tag>点击菜单</el-tag>
{{ scope.row.eventKey }}
</div> </div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'VIEW'"> <div v-else-if="scope.row.type === 'event' && scope.row.event === 'VIEW'">
<el-tag>点击菜单链接</el-tag>{{ scope.row.eventKey }} <el-tag>点击菜单链接</el-tag>
{{ scope.row.eventKey }}
</div> </div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_waitmsg'"> <div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_waitmsg'">
<el-tag>扫码结果</el-tag>{{ scope.row.eventKey }} <el-tag>扫码结果</el-tag>
{{ scope.row.eventKey }}
</div> </div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_push'"> <div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_push'">
<el-tag>扫码结果</el-tag>{{ scope.row.eventKey }} <el-tag>扫码结果</el-tag>
{{ scope.row.eventKey }}
</div> </div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_sysphoto'"> <div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_sysphoto'">
<el-tag>系统拍照发图</el-tag> <el-tag>系统拍照发图</el-tag>
@ -125,7 +135,8 @@
<wx-video-player :url="scope.row.mediaUrl" style="margin-top: 10px" /> <wx-video-player :url="scope.row.mediaUrl" style="margin-top: 10px" />
</div> </div>
<div v-else-if="scope.row.type === 'link'"> <div v-else-if="scope.row.type === 'link'">
<el-tag>链接</el-tag> <el-tag>链接</el-tag>
<a :href="scope.row.url" target="_blank">{{ scope.row.title }}</a> <a :href="scope.row.url" target="_blank">{{ scope.row.title }}</a>
</div> </div>
<div v-else-if="scope.row.type === 'location'"> <div v-else-if="scope.row.type === 'location'">
@ -175,23 +186,26 @@
/> />
<!-- 发送消息的弹窗 --> <!-- 发送消息的弹窗 -->
<el-dialog title="粉丝消息列表" v-model:visible="open" width="50%"> <el-dialog title="粉丝消息列表" v-model="open" @click="openDialog()" width="50%">
<wx-msg :user-id="userId" v-if="open" /> <template #footer>
<wx-msg :user-id="userId" v-if="open" />
</template>
</el-dialog> </el-dialog>
</ContentWrap> </ContentWrap>
</template> </template>
<script setup lang="ts" name="MpMessage"> <script setup lang="ts" name="MpMessage">
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
import { dateFormatter } from '@/utils/formatTime'
// import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue' import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
// import WxMsg from '@/views/mp/components/wx-msg/main.vue' import WxMsg from '@/views/mp/components/wx-msg/main.vue'
import WxLocation from '@/views/mp/components/wx-location/main.vue' import WxLocation from '@/views/mp/components/wx-location/main.vue'
// import WxMusic from '@/views/mp/components/wx-music/main.vue' import WxMusic from '@/views/mp/components/wx-music/main.vue'
// import WxNews from '@/views/mp/components/wx-news/main.vue' import WxNews from '@/views/mp/components/wx-news/main.vue'
import * as MpAccountApi from '@/api/mp/account' import * as MpAccountApi from '@/api/mp/account'
import * as MpMessageApi from '@/api/mp/message' import * as MpMessageApi from '@/api/mp/message'
const message = useMessage() // const message = useMessage() //
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
@ -248,6 +262,13 @@ const handleSend = async (row) => {
open.value = true open.value = true
} }
const openDialog = () => {
open.value = true
}
// const closeDiaLog = () => {
// open.value = false
// }
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
accountList.value = await MpAccountApi.getSimpleAccountList() accountList.value = await MpAccountApi.getSimpleAccountList()

View File

@ -28,13 +28,21 @@
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery">
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> <Icon icon="ep:search" class="mr-5px" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" />
重置
</el-button>
<el-button type="primary" plain @click="openForm('create')" v-hasPermi="['mp:tag:create']"> <el-button type="primary" plain @click="openForm('create')" v-hasPermi="['mp:tag:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增 <Icon icon="ep:plus" class="mr-5px" />
新增
</el-button> </el-button>
<el-button type="success" plain @click="handleSync" v-hasPermi="['mp:tag:sync']"> <el-button type="success" plain @click="handleSync" v-hasPermi="['mp:tag:sync']">
<Icon icon="ep:refresh" class="mr-5px" /> 同步 <Icon icon="ep:refresh" class="mr-5px" />
同步
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -91,6 +99,7 @@ import { dateFormatter } from '@/utils/formatTime'
import * as MpTagApi from '@/api/mp/tag' import * as MpTagApi from '@/api/mp/tag'
import * as MpAccountApi from '@/api/mp/account' import * as MpAccountApi from '@/api/mp/account'
import TagForm from './TagForm.vue' import TagForm from './TagForm.vue'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //