70adfe8f
亚洲
公众号开发
|
1
2
|
<template>
<div class="app-container">
|
ca8bb724
YunaiV
版本 1.7.0 发布:增加微信公...
|
3
|
<doc-alert title="公众号消息" url="https://doc.iocoder.cn/mp/message/" />
|
70adfe8f
亚洲
公众号开发
|
4
5
6
|
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
7
8
9
10
|
<el-form-item label="公众号" prop="accountId">
<el-select v-model="queryParams.accountId" placeholder="请选择公众号">
<el-option v-for="item in accounts" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" />
</el-select>
|
70adfe8f
亚洲
公众号开发
|
11
|
</el-form-item>
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
12
13
14
15
16
|
<!-- TODO 等待处理 -->
<el-form-item label="消息类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择消息类型" clearable size="small">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.MP_MESSAGE_TYPE)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
70adfe8f
亚洲
公众号开发
|
17
18
|
</el-select>
</el-form-item>
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
19
20
|
<el-form-item label="用户标识" prop="openid">
<el-input v-model="queryParams.openid" placeholder="请输入用户标识" clearable @keyup.enter.native="handleQuery"/>
|
70adfe8f
亚洲
公众号开发
|
21
|
</el-form-item>
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
22
23
24
|
<el-form-item label="创建时间" prop="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
|
70adfe8f
亚洲
公众号开发
|
25
26
27
28
29
30
31
32
33
|
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
|
70adfe8f
亚洲
公众号开发
|
34
35
36
37
38
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
39
|
<el-table-column label="发送时间" align="center" prop="createTime" width="180">
|
0bd0bbd5
xingyu
fix: slot-scope 已...
|
40
|
<template v-slot="scope">
|
70adfe8f
亚洲
公众号开发
|
41
42
43
|
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
44
|
<el-table-column label="消息类型" align="center" prop="type" width="80"/>
|
9e4a978f
YunaiV
mp:解决 wx-msg 的 cs...
|
45
|
<el-table-column label="发送方" align="center" prop="sendFrom" width="80">
|
0bd0bbd5
xingyu
fix: slot-scope 已...
|
46
|
<template v-slot="scope">
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
47
|
<el-tag v-if="scope.row.sendFrom === 1" type="success">粉丝</el-tag>
|
9e4a978f
YunaiV
mp:解决 wx-msg 的 cs...
|
48
49
50
|
<el-tag v-else type="info">公众号</el-tag>
</template>
</el-table-column>
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
51
|
<el-table-column label="用户标识" align="center" prop="openid" width="300" />
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
52
|
<el-table-column label="内容" prop="content">
|
0bd0bbd5
xingyu
fix: slot-scope 已...
|
53
|
<template v-slot="scope">
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<!-- 【事件】区域 -->
<div v-if="scope.row.type === 'event' && scope.row.event === 'subscribe'">
<el-tag type="success" size="mini">关注</el-tag>
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'unsubscribe'">
<el-tag type="danger" size="mini">取消关注</el-tag>
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'CLICK'">
<el-tag size="mini">点击菜单</el-tag>【{{ scope.row.eventKey }}】
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'VIEW'">
<el-tag size="mini">点击菜单链接</el-tag>【{{ scope.row.eventKey }}】
</div>
|
86002145
YunaiV
mp:优化【菜单】其它类型的处理
|
67
|
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_waitmsg'">
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
68
69
|
<el-tag size="mini">扫码结果</el-tag>【{{ scope.row.eventKey }}】
</div>
|
86002145
YunaiV
mp:优化【菜单】其它类型的处理
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_push'">
<el-tag size="mini">扫码结果</el-tag>【{{ scope.row.eventKey }}】
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_sysphoto'">
<el-tag size="mini">系统拍照发图</el-tag>
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_photo_or_album'">
<el-tag size="mini">拍照或者相册</el-tag>
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_weixin'">
<el-tag size="mini">微信相册</el-tag>
</div>
<div v-else-if="scope.row.type === 'event' && scope.row.event === 'location_select'">
<el-tag size="mini">选择地理位置</el-tag>
</div>
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
85
86
87
88
89
|
<div v-else-if="scope.row.type === 'event'">
<el-tag type="danger" size="mini">未知事件类型</el-tag>
</div>
<!-- 【消息】区域 -->
<div v-else-if="scope.row.type === 'text'">{{ scope.row.content }}</div>
|
94178998
YunaiV
mp:前端 message 增加 ...
|
90
91
92
|
<div v-else-if="scope.row.type === 'voice'">
<wx-voice-player :url="scope.row.mediaUrl" :content="scope.row.recognition" />
</div>
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
93
94
95
96
97
98
|
<div v-else-if="scope.row.type === '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'">
|
18bf098a
YunaiV
mp:前端 message 增加视...
|
99
100
|
<wx-video-player :url="scope.row.mediaUrl" style="margin-top: 10px" />
</div>
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
101
102
103
104
|
<div v-else-if="scope.row.type === 'link'">
<el-tag size="mini">链接</el-tag>:
<a :href="scope.row.url" target="_blank">{{scope.row.title}}</a>
</div>
|
b0386429
YunaiV
mp:支持 wx-news、wx-...
|
105
106
107
|
<div v-else-if="scope.row.type === 'location'">
<wx-location :label="scope.row.label" :location-y="scope.row.locationY" :location-x="scope.row.locationX" />
</div>
|
6325dd28
YunaiV
mp:前端增加 message 消...
|
108
109
110
111
|
<div v-else-if="scope.row.type === 'music'">
<wx-music :title="scope.row.title" :description="scope.row.description" :thumb-media-url="scope.row.thumbMediaUrl"
:music-url="scope.row.musicUrl" :hq-music-url="scope.row.hqMusicUrl" />
</div>
|
9f7b646f
YunaiV
mp:增加发送【图文】消息
|
112
113
114
|
<div v-else-if="scope.row.type === 'news'">
<wx-news :articles="scope.row.articles" />
</div>
|
8a5db8c1
YunaiV
mp:前端 message 增加文...
|
115
116
117
|
<div v-else>
<el-tag type="danger" size="mini">未知消息类型</el-tag>
</div>
|
18bf098a
YunaiV
mp:前端 message 增加视...
|
118
119
|
</template>
</el-table-column>
|
70adfe8f
亚洲
公众号开发
|
120
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
0bd0bbd5
xingyu
fix: slot-scope 已...
|
121
|
<template v-slot="scope">
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
122
123
124
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleSend(scope.row)"
v-hasPermi="['mp:message:send']">消息
</el-button>
|
70adfe8f
亚洲
公众号开发
|
125
126
127
128
129
130
131
|
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
132
133
134
|
<!-- 发送消息的弹窗 -->
<el-dialog title="粉丝消息列表" :visible.sync="open" width="50%">
<wx-msg :user-id="userId" v-if="open" />
|
70adfe8f
亚洲
公众号开发
|
135
|
</el-dialog>
|
2b477a4d
YunaiV
mp:实现 wx-msg 的消息列...
|
136
|
|
70adfe8f
亚洲
公众号开发
|
137
138
139
140
|
</div>
</template>
<script>
|
18bf098a
YunaiV
mp:前端 message 增加视...
|
141
|
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
|
94178998
YunaiV
mp:前端 message 增加 ...
|
142
|
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue';
|
2b477a4d
YunaiV
mp:实现 wx-msg 的消息列...
|
143
|
import WxMsg from '@/views/mp/components/wx-msg/main.vue';
|
b0386429
YunaiV
mp:支持 wx-news、wx-...
|
144
|
import WxLocation from '@/views/mp/components/wx-location/main.vue';
|
6325dd28
YunaiV
mp:前端增加 message 消...
|
145
|
import WxMusic from '@/views/mp/components/wx-music/main.vue';
|
9f7b646f
YunaiV
mp:增加发送【图文】消息
|
146
|
import WxNews from '@/views/mp/components/wx-news/main.vue';
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
147
148
|
import { getMessagePage } from "@/api/mp/message";
import { getSimpleAccounts } from "@/api/mp/account";
|
70adfe8f
亚洲
公众号开发
|
149
|
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
150
|
export default {
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
151
|
name: "MpMessage",
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
152
|
components: {
|
18bf098a
YunaiV
mp:前端 message 增加视...
|
153
|
WxVideoPlayer,
|
2b477a4d
YunaiV
mp:实现 wx-msg 的消息列...
|
154
|
WxVoicePlayer,
|
b0386429
YunaiV
mp:支持 wx-news、wx-...
|
155
|
WxMsg,
|
6325dd28
YunaiV
mp:前端增加 message 消...
|
156
|
WxLocation,
|
9f7b646f
YunaiV
mp:增加发送【图文】消息
|
157
158
|
WxMusic,
WxNews
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
159
160
161
162
163
164
165
166
167
168
169
|
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
|
5901ab66
YunaiV
mp:增加 server 草稿箱的...
|
170
|
// 粉丝消息列表
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
171
|
list: [],
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
172
|
// 是否显示弹出层
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
173
|
open: false,
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
174
|
// 查询参数
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
175
176
177
178
|
queryParams: {
pageNo: 1,
pageSize: 10,
openid: null,
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
179
180
181
|
accountId: null,
type: null,
createTime: []
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
182
|
},
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
183
184
|
// 操作的用户编号
userId: 0,
|
18bf098a
YunaiV
mp:前端 message 增加视...
|
185
186
187
|
// 公众号账号列表
accounts: []
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
188
189
190
|
};
},
created() {
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
191
192
193
194
195
196
197
198
199
|
getSimpleAccounts().then(response => {
this.accounts = response.data;
// 默认选中第一个
if (this.accounts.length > 0) {
this.queryParams.accountId = this.accounts[0].id;
}
// 加载数据
this.getList();
})
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
200
201
202
203
|
},
methods: {
/** 查询列表 */
getList() {
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
204
205
206
207
208
209
|
// 如果没有选中公众号账号,则进行提示。
if (!this.queryParams.accountId) {
this.$message.error('未选中公众号,无法查询消息')
return false
}
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
210
|
this.loading = true;
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
211
|
// 执行查询
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
212
|
getMessagePage(this.queryParams).then(response => {
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
213
214
215
216
217
|
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
218
219
220
|
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
|
70adfe8f
亚洲
公众号开发
|
221
222
|
this.getList();
},
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
223
224
|
/** 重置按钮操作 */
resetQuery() {
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
225
|
this.resetForm("queryForm");
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
226
227
228
229
|
// 默认选中第一个
if (this.accounts.length > 0) {
this.queryParams.accountId = this.accounts[0].id;
}
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
230
231
|
this.handleQuery();
},
|
68ef11ee
YunaiV
mp:完善微信公众号的消息
|
232
233
234
235
|
handleSend(row) {
this.userId = row.userId;
this.open = true;
},
|
9ec2f8b6
YunaiV
mp:梳理 message 的前端...
|
236
237
|
}
};
|
70adfe8f
亚洲
公众号开发
|
238
|
</script>
|