58
58
59
59
<!-- 列表 -->
60
60
<ContentWrap >
61
- <el-table v-loading =" loading" :data =" list" >
62
- <el-table-column
63
- label =" 发送时间"
64
- align =" center"
65
- prop =" createTime"
66
- width =" 180"
67
- :formatter =" dateFormatter"
68
- />
69
- <el-table-column label =" 消息类型" align =" center" prop =" type" width =" 80" />
70
- <el-table-column label =" 发送方" align =" center" prop =" sendFrom" width =" 80" >
71
- <template #default =" scope " >
72
- <el-tag v-if =" scope.row.sendFrom === 1" type =" success" >粉丝</el-tag >
73
- <el-tag v-else type =" info" >公众号</el-tag >
74
- </template >
75
- </el-table-column >
76
- <el-table-column label =" 用户标识" align =" center" prop =" openid" width =" 300" />
77
- <el-table-column label =" 内容" prop =" content" >
78
- <template #default =" scope " >
79
- <!-- 【事件】区域 -->
80
- <div v-if =" scope.row.type === MsgType.Event && scope.row.event === 'subscribe'" >
81
- <el-tag type =" success" >关注</el-tag >
82
- </div >
83
- <div v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'unsubscribe'" >
84
- <el-tag type =" danger" >取消关注</el-tag >
85
- </div >
86
- <div v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'CLICK'" >
87
- <el-tag >点击菜单</el-tag >
88
- 【{{ scope.row.eventKey }}】
89
- </div >
90
- <div v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'VIEW'" >
91
- <el-tag >点击菜单链接</el-tag >
92
- 【{{ scope.row.eventKey }}】
93
- </div >
94
- <div
95
- v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'scancode_waitmsg'"
96
- >
97
- <el-tag >扫码结果</el-tag >
98
- 【{{ scope.row.eventKey }}】
99
- </div >
100
- <div v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'scancode_push'" >
101
- <el-tag >扫码结果</el-tag >
102
- 【{{ scope.row.eventKey }}】
103
- </div >
104
- <div v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'pic_sysphoto'" >
105
- <el-tag >系统拍照发图</el-tag >
106
- </div >
107
- <div
108
- v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'pic_photo_or_album'"
109
- >
110
- <el-tag >拍照或者相册</el-tag >
111
- </div >
112
- <div v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'pic_weixin'" >
113
- <el-tag >微信相册</el-tag >
114
- </div >
115
- <div
116
- v-else-if =" scope.row.type === MsgType.Event && scope.row.event === 'location_select'"
117
- >
118
- <el-tag >选择地理位置</el-tag >
119
- </div >
120
- <div v-else-if =" scope.row.type === MsgType.Event" >
121
- <el-tag type =" danger" >未知事件类型</el-tag >
122
- </div >
123
- <!-- 【消息】区域 -->
124
- <div v-else-if =" scope.row.type === MsgType.Text" >{{ scope.row.content }}</div >
125
- <div v-else-if =" scope.row.type === MsgType.Voice" >
126
- <wx-voice-player :url =" scope.row.mediaUrl" :content =" scope.row.recognition" />
127
- </div >
128
- <div v-else-if =" scope.row.type === MsgType.Image" >
129
- <a target =" _blank" :href =" scope.row.mediaUrl" >
130
- <img :src =" scope.row.mediaUrl" style =" width : 100px " />
131
- </a >
132
- </div >
133
- <div v-else-if =" scope.row.type === MsgType.Video || scope.row.type === 'shortvideo'" >
134
- <wx-video-player :url =" scope.row.mediaUrl" style =" margin-top : 10px " />
135
- </div >
136
- <div v-else-if =" scope.row.type === MsgType.Link" >
137
- <el-tag >链接</el-tag >
138
- :
139
- <a :href =" scope.row.url" target =" _blank" >{{ scope.row.title }}</a >
140
- </div >
141
- <div v-else-if =" scope.row.type === MsgType.Location" >
142
- <WxLocation
143
- :label =" scope.row.label"
144
- :location-y =" scope.row.locationY"
145
- :location-x =" scope.row.locationX"
146
- />
147
- </div >
148
- <div v-else-if =" scope.row.type === MsgType.Music" >
149
- <WxMusic
150
- :title =" scope.row.title"
151
- :description =" scope.row.description"
152
- :thumb-media-url =" scope.row.thumbMediaUrl"
153
- :music-url =" scope.row.musicUrl"
154
- :hq-music-url =" scope.row.hqMusicUrl"
155
- />
156
- </div >
157
- <div v-else-if =" scope.row.type === MsgType.News" >
158
- <WxNews :articles =" scope.row.articles" />
159
- </div >
160
- <div v-else >
161
- <el-tag type =" danger" >未知消息类型</el-tag >
162
- </div >
163
- </template >
164
- </el-table-column >
165
- <el-table-column label =" 操作" align =" center" class-name =" small-padding fixed-width" >
166
- <template #default =" scope " >
167
- <el-button
168
- link
169
- type =" primary"
170
- @click =" handleSend(scope.row)"
171
- v-hasPermi =" ['mp:message:send']"
172
- >
173
- 消息
174
- </el-button >
175
- </template >
176
- </el-table-column >
177
- </el-table >
178
- <!-- 分页组件 -->
61
+ <DataGrid :list =" list" :loading =" loading" @send =" handleSend" />
179
62
<Pagination
180
63
v-show =" total > 0"
181
64
:total =" total"
182
65
v-model:page =" queryParams.pageNo"
183
66
v-model:limit =" queryParams.pageSize"
184
67
@pagination =" getList"
185
68
/>
186
-
187
- <!-- 发送消息的弹窗 -->
188
- <el-dialog
189
- title =" 粉丝消息列表"
190
- v-model =" showMessageBox"
191
- @click =" showMessageBox = true"
192
- width =" 50%"
193
- destroy-on-close
194
- >
195
- <WxMsg :user-id =" userId" />
196
- </el-dialog >
197
69
</ContentWrap >
70
+
71
+ <!-- 发送消息的弹窗 -->
72
+ <el-dialog
73
+ title =" 粉丝消息列表"
74
+ v-model =" messageBox.show"
75
+ @click =" messageBox.show = true"
76
+ width =" 50%"
77
+ destroy-on-close
78
+ >
79
+ <WxMsg :user-id =" messageBox.userId" />
80
+ </el-dialog >
198
81
</template >
199
82
<script setup lang="ts" name="MpMessage">
200
- import WxVideoPlayer from ' @/views/mp/components/wx-video-play/main.vue'
201
- import WxVoicePlayer from ' @/views/mp/components/wx-voice-play/main.vue'
83
+ import * as MpMessageApi from ' @/api/mp/message'
202
84
import WxMsg from ' @/views/mp/components/wx-msg/main.vue'
203
- import WxLocation from ' @/views/mp/components/wx-location/main.vue'
204
- import WxMusic from ' @/views/mp/components/wx-music/main.vue'
205
- import WxNews from ' @/views/mp/components/wx-news/main.vue'
206
85
import WxAccountSelect from ' @/views/mp/components/wx-account-select/main.vue'
207
- import * as MpMessageApi from ' @/api/mp/message '
86
+ import DataGrid from ' ./DataGrid.vue '
208
87
import { DICT_TYPE , getStrDictOptions } from ' @/utils/dict'
209
- import { dateFormatter } from ' @/utils/formatTime'
210
88
import { MsgType } from ' @/views/mp/components/wx-msg/types'
211
89
import type { FormInstance } from ' element-plus'
212
90
213
- const loading = ref (true ) // 列表的加载中
214
- const total = ref (0 ) // 列表的总页数
215
- const list = ref <any []>([]) // 列表的数据
91
+ const loading = ref (false )
92
+ const total = ref (0 ) // 数据的总页数
93
+ const list = ref <any []>([]) // 当前页的列表数据
216
94
217
95
// 搜索参数
218
96
interface QueryParams {
@@ -232,8 +110,12 @@ const queryParams: QueryParams = reactive({
232
110
createTime: []
233
111
})
234
112
const queryFormRef = ref <FormInstance | null >(null ) // 搜索的表单
235
- const showMessageBox = ref (false ) // 是否显示弹出层
236
- const userId = ref (0 ) // 操作的用户编号
113
+
114
+ // 消息对话框
115
+ const messageBox = reactive ({
116
+ show: false ,
117
+ userId: 0
118
+ })
237
119
238
120
/** 侦听accountId */
239
121
const onAccountChanged = (id ? : number ) => {
@@ -242,6 +124,11 @@ const onAccountChanged = (id?: number) => {
242
124
}
243
125
244
126
/** 查询列表 */
127
+ const handleQuery = () => {
128
+ queryParams .pageNo = 1
129
+ getList ()
130
+ }
131
+
245
132
const getList = async () => {
246
133
try {
247
134
loading .value = true
@@ -253,12 +140,6 @@ const getList = async () => {
253
140
}
254
141
}
255
142
256
- /** 搜索按钮操作 */
257
- const handleQuery = () => {
258
- queryParams .pageNo = 1
259
- getList ()
260
- }
261
-
262
143
/** 重置按钮操作 */
263
144
const resetQuery = async () => {
264
145
// 暂存accountId,并在reset后恢复
@@ -269,8 +150,8 @@ const resetQuery = async () => {
269
150
}
270
151
271
152
/** 打开消息发送窗口 */
272
- const handleSend = async (row : any ) => {
273
- userId . value = row . userId
274
- showMessageBox . value = true
153
+ const handleSend = async (userId : number ) => {
154
+ messageBox . userId = userId
155
+ messageBox . show = true
275
156
}
276
157
</script >
0 commit comments