Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3536077a
authored
Apr 12, 2023
by
dhb52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: MP消息管理 ts重构
parent
357a4789
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
73 deletions
+78
-73
src/views/mp/components/wx-msg/main.vue
+0
-0
src/views/mp/components/wx-msg/types.ts
+11
-0
src/views/mp/message/index.vue
+67
-73
No files found.
src/views/mp/components/wx-msg/main.vue
View file @
3536077a
This diff is collapsed.
Click to expand it.
src/views/mp/components/wx-msg/types.ts
0 → 100644
View file @
3536077a
export
enum
MsgType
{
Event
=
'event'
,
Text
=
'text'
,
Voice
=
'voice'
,
Image
=
'image'
,
Video
=
'video'
,
Link
=
'link'
,
Location
=
'location'
,
Music
=
'music'
,
News
=
'news'
}
src/views/mp/message/index.vue
View file @
3536077a
...
...
@@ -9,14 +9,7 @@
label-width=
"68px"
>
<el-form-item
label=
"公众号"
prop=
"accountId"
>
<el-select
v-model=
"queryParams.accountId"
placeholder=
"请选择公众号"
class=
"!w-240px"
>
<el-option
v-for=
"item in accountList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
/>
</el-select>
<WxMpSelect
@
change=
"onAccountChanged"
/>
</el-form-item>
<el-form-item
label=
"消息类型"
prop=
"type"
>
<el-select
v-model=
"queryParams.type"
placeholder=
"请选择消息类型"
class=
"!w-240px"
>
...
...
@@ -84,70 +77,76 @@
<el-table-column
label=
"内容"
prop=
"content"
>
<
template
#
default=
"scope"
>
<!-- 【事件】区域 -->
<div
v-if=
"scope.row.type ===
'event'
&& scope.row.event === 'subscribe'"
>
<div
v-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'subscribe'"
>
<el-tag
type=
"success"
>
关注
</el-tag>
</div>
<div
v-else-if=
"scope.row.type ===
'event'
&& scope.row.event === 'unsubscribe'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'unsubscribe'"
>
<el-tag
type=
"danger"
>
取消关注
</el-tag>
</div>
<div
v-else-if=
"scope.row.type ===
'event'
&& scope.row.event === 'CLICK'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'CLICK'"
>
<el-tag>
点击菜单
</el-tag>
【
{{
scope
.
row
.
eventKey
}}
】
</div>
<div
v-else-if=
"scope.row.type ===
'event'
&& scope.row.event === 'VIEW'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'VIEW'"
>
<el-tag>
点击菜单链接
</el-tag>
【
{{
scope
.
row
.
eventKey
}}
】
</div>
<div
v-else-if=
"scope.row.type === 'event' && scope.row.event === 'scancode_waitmsg'"
>
<div
v-else-if=
"scope.row.type === MsgType.Event && scope.row.event === 'scancode_waitmsg'"
>
<el-tag>
扫码结果
</el-tag>
【
{{
scope
.
row
.
eventKey
}}
】
</div>
<div
v-else-if=
"scope.row.type ===
'event'
&& scope.row.event === 'scancode_push'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'scancode_push'"
>
<el-tag>
扫码结果
</el-tag>
【
{{
scope
.
row
.
eventKey
}}
】
</div>
<div
v-else-if=
"scope.row.type ===
'event'
&& scope.row.event === 'pic_sysphoto'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'pic_sysphoto'"
>
<el-tag>
系统拍照发图
</el-tag>
</div>
<div
v-else-if=
"scope.row.type === 'event' && scope.row.event === 'pic_photo_or_album'"
>
<div
v-else-if=
"scope.row.type === MsgType.Event && scope.row.event === 'pic_photo_or_album'"
>
<el-tag>
拍照或者相册
</el-tag>
</div>
<div
v-else-if=
"scope.row.type ===
'event'
&& scope.row.event === 'pic_weixin'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
&& scope.row.event === 'pic_weixin'"
>
<el-tag>
微信相册
</el-tag>
</div>
<div
v-else-if=
"scope.row.type === 'event' && scope.row.event === 'location_select'"
>
<div
v-else-if=
"scope.row.type === MsgType.Event && scope.row.event === 'location_select'"
>
<el-tag>
选择地理位置
</el-tag>
</div>
<div
v-else-if=
"scope.row.type ===
'event'
"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Event
"
>
<el-tag
type=
"danger"
>
未知事件类型
</el-tag>
</div>
<!-- 【消息】区域 -->
<div
v-else-if=
"scope.row.type ===
'text'
"
>
{{
scope
.
row
.
content
}}
</div>
<div
v-else-if=
"scope.row.type ===
'voice'
"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Text
"
>
{{
scope
.
row
.
content
}}
</div>
<div
v-else-if=
"scope.row.type ===
MsgType.Voice
"
>
<wx-voice-player
:url=
"scope.row.mediaUrl"
:content=
"scope.row.recognition"
/>
</div>
<div
v-else-if=
"scope.row.type ===
'image'
"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Image
"
>
<a
target=
"_blank"
:href=
"scope.row.mediaUrl"
>
<img
:src=
"scope.row.mediaUrl"
style=
"width: 100px"
/>
</a>
</div>
<div
v-else-if=
"scope.row.type ===
'video'
|| scope.row.type === 'shortvideo'"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Video
|| scope.row.type === 'shortvideo'"
>
<wx-video-player
:url=
"scope.row.mediaUrl"
style=
"margin-top: 10px"
/>
</div>
<div
v-else-if=
"scope.row.type ===
'link'
"
>
<div
v-else-if=
"scope.row.type ===
MsgType.Link
"
>
<el-tag>
链接
</el-tag>
:
<a
:href=
"scope.row.url"
target=
"_blank"
>
{{
scope
.
row
.
title
}}
</a>
</div>
<div
v-else-if=
"scope.row.type ===
'location'
"
>
<
wx-l
ocation
<div
v-else-if=
"scope.row.type ===
MsgType.Location
"
>
<
WxL
ocation
:label=
"scope.row.label"
:location-y=
"scope.row.locationY"
:location-x=
"scope.row.locationX"
/>
</div>
<div
v-else-if=
"scope.row.type ===
'music'
"
>
<
wx-m
usic
<div
v-else-if=
"scope.row.type ===
MsgType.Music
"
>
<
WxM
usic
:title=
"scope.row.title"
:description=
"scope.row.description"
:thumb-media-url=
"scope.row.thumbMediaUrl"
...
...
@@ -155,8 +154,8 @@
:hq-music-url=
"scope.row.hqMusicUrl"
/>
</div>
<div
v-else-if=
"scope.row.type ===
'news'
"
>
<
wx-n
ews
:articles=
"scope.row.articles"
/>
<div
v-else-if=
"scope.row.type ===
MsgType.News
"
>
<
WxN
ews
:articles=
"scope.row.articles"
/>
</div>
<div
v-else
>
<el-tag
type=
"danger"
>
未知消息类型
</el-tag>
...
...
@@ -177,7 +176,7 @@
</el-table-column>
</el-table>
<!-- 分页组件 -->
<
p
agination
<
P
agination
v-show=
"total > 0"
:total=
"total"
v-model:page=
"queryParams.pageNo"
...
...
@@ -186,9 +185,14 @@
/>
<!-- 发送消息的弹窗 -->
<el-dialog
title=
"粉丝消息列表"
v-model=
"open"
@
click=
"openDialog()"
width=
"50%"
>
<el-dialog
title=
"粉丝消息列表"
v-model=
"showMessageBox"
@
click=
"showMessageBox = true"
width=
"50%"
>
<
template
#
footer
>
<
wx-msg
:user-id=
"userId"
v-if=
"open
"
/>
<
WxMsg
:user-id=
"userId"
v-if=
"showMessageBox
"
/>
</
template
>
</el-dialog>
</ContentWrap>
...
...
@@ -200,17 +204,27 @@ import WxMsg from '@/views/mp/components/wx-msg/main.vue'
import
WxLocation
from
'@/views/mp/components/wx-location/main.vue'
import
WxMusic
from
'@/views/mp/components/wx-music/main.vue'
import
WxNews
from
'@/views/mp/components/wx-news/main.vue'
import
*
as
MpAccountApi
from
'@/api/mp/account
'
import
WxMpSelect
from
'@/views/mp/components/WxMpSelect.vue
'
import
*
as
MpMessageApi
from
'@/api/mp/message'
const
message
=
useMessage
()
// 消息弹窗
import
{
DICT_TYPE
,
getStrDictOptions
}
from
'@/utils/dict'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
MsgType
}
from
'@/views/mp/components/wx-msg/types'
import
type
{
FormInstance
}
from
'element-plus'
const
loading
=
ref
(
true
)
// 列表的加载中
const
total
=
ref
(
0
)
// 列表的总页数
const
list
=
ref
([])
// 列表的数据
const
queryParams
=
reactive
({
const
list
=
ref
<
any
[]
>
([])
// 列表的数据
// 搜索参数
interface
QueryParams
{
pageNo
:
number
pageSize
:
number
openid
:
string
|
null
accountId
:
number
|
null
type
:
MsgType
|
null
createTime
:
string
[]
|
[]
}
const
queryParams
:
QueryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
,
openid
:
null
,
...
...
@@ -218,19 +232,18 @@ const queryParams = reactive({
type
:
null
,
createTime
:
[]
})
const
queryFormRef
=
ref
()
// 搜索的表单
// TODO 芋艿:下面应该移除
const
open
=
ref
(
false
)
// 是否显示弹出层
const
queryFormRef
=
ref
<
FormInstance
|
null
>
(
null
)
// 搜索的表单
const
showMessageBox
=
ref
(
false
)
// 是否显示弹出层
const
userId
=
ref
(
0
)
// 操作的用户编号
const
accountList
=
ref
<
MpAccountApi
.
AccountVO
[]
>
([])
// 公众号账号列表
/** 侦听accountId */
const
onAccountChanged
=
(
id
?:
number
)
=>
{
queryParams
.
accountId
=
id
as
number
handleQuery
()
}
/** 查询列表 */
const
getList
=
async
()
=>
{
// 如果没有选中公众号账号,则进行提示。
if
(
!
queryParams
.
accountId
)
{
await
message
.
error
(
'未选中公众号,无法查询消息'
)
return
}
try
{
loading
.
value
=
true
const
data
=
await
MpMessageApi
.
getMessagePage
(
queryParams
)
...
...
@@ -249,34 +262,15 @@ const handleQuery = () => {
/** 重置按钮操作 */
const
resetQuery
=
async
()
=>
{
queryFormRef
.
value
.
resetFields
()
// 默认选中第一个
if
(
accountList
.
value
.
length
>
0
)
{
// @ts-ignore
queryParams
.
accountId
=
accountList
.
value
[
0
].
id
}
const
accountId
=
queryParams
.
accountId
queryFormRef
.
value
?.
resetFields
()
queryParams
.
accountId
=
accountId
handleQuery
()
}
const
handleSend
=
async
(
row
)
=>
{
userId
.
value
=
row
.
userId
open
.
value
=
true
}
const
openDialog
=
()
=>
{
open
.
value
=
true
/** 打开消息发送窗口 */
const
handleSend
=
async
(
row
:
any
)
=>
{
userId
.
value
=
row
.
userId
showMessageBox
.
value
=
true
}
// const closeDiaLog = () => {
// open.value = false
// }
/** 初始化 **/
onMounted
(
async
()
=>
{
accountList
.
value
=
await
MpAccountApi
.
getSimpleAccountList
()
// 选中第一个
if
(
accountList
.
value
.
length
>
0
)
{
// @ts-ignore
queryParams
.
accountId
=
accountList
.
value
[
0
].
id
}
await
getList
()
})
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment