f8eed5dd
YunaiV
mp:初始化回复组件
|
1
2
3
|
<!--
- Copyright (C) 2018-2019
- All rights reserved, Designed By www.joolun.com
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
4
5
6
|
芋道源码:
① 移除多余的 rep 为前缀的变量,让 message 消息更简单
② 代码优化,补充注释,提升阅读性
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
7
8
|
③ 优化消息的临时缓存策略,发送消息时,只清理被发送消息的 tab,不会强制切回到 text 输入
④ 支持发送【视频】消息时,支持新建视频
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
9
10
|
-->
<template>
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
11
|
<el-tabs type="border-card" v-model="objData.type" @tab-click="handleClick">
|
ec872c70
YunaiV
mp:增加上传临时素材的接口
|
12
|
<!-- 类型 1:文本 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
13
14
|
<el-tab-pane name="text">
<span slot="label"><i class="el-icon-document"></i> 文本</span>
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
15
|
<el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="objData.content" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
16
|
</el-tab-pane>
|
ec872c70
YunaiV
mp:增加上传临时素材的接口
|
17
|
<!-- 类型 2:图片 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
18
19
20
|
<el-tab-pane name="image">
<span slot="label"><i class="el-icon-picture"></i> 图片</span>
<el-row>
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
21
22
23
|
<!-- 情况一:已经选择好素材、或者上传好图片 -->
<div class="select-item" v-if="objData.url">
<img class="material-img" :src="objData.url">
|
331af28f
YunaiV
mp:增加【语音】【视频】的素材选择
|
24
|
<p class="item-name" v-if="objData.name">{{objData.name}}</p>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
25
26
27
28
|
<el-row class="ope-row">
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj"></el-button>
</el-row>
</div>
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
29
30
|
<!-- 情况二:未做完上述操作 -->
<div v-else>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
31
|
<el-row style="text-align: center">
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
32
|
<!-- 选择素材 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
33
|
<el-col :span="12" class="col-select">
|
188d8802
YunaiV
mp:增加【图片】素材的选择
|
34
35
36
|
<el-button type="success" @click="openMaterial">
素材库选择<i class="el-icon-circle-check el-icon--right"></i>
</el-button>
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
37
38
39
|
<el-dialog title="选择图片" :visible.sync="dialogImageVisible" width="90%" append-to-body>
<wx-material-select :obj-data="objData" @selectMaterial="selectMaterial" />
</el-dialog>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
40
|
</el-col>
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
41
|
<!-- 文件上传 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
42
|
<el-col :span="12" class="col-add">
|
ec872c70
YunaiV
mp:增加上传临时素材的接口
|
43
44
|
<el-upload :action="actionUrl" :headers="headers" multiple :limit="1" :file-list="fileList" :data="uploadData"
:before-upload="beforeImageUpload" :on-success="handleUploadSuccess">
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
45
|
<el-button type="primary">上传图片</el-button>
|
ec872c70
YunaiV
mp:增加上传临时素材的接口
|
46
|
<div slot="tip" class="el-upload__tip">支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M</div>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
47
48
49
50
|
</el-upload>
</el-col>
</el-row>
</div>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
51
52
|
</el-row>
</el-tab-pane>
|
90e0ebc2
YunaiV
mp:支持 wx-reply 发送...
|
53
|
<!-- 类型 3:语音 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
54
55
56
|
<el-tab-pane name="voice">
<span slot="label"><i class="el-icon-phone"></i> 语音</span>
<el-row>
|
90e0ebc2
YunaiV
mp:支持 wx-reply 发送...
|
57
|
<div class="select-item2" v-if="objData.url">
|
331af28f
YunaiV
mp:增加【语音】【视频】的素材选择
|
58
|
<p class="item-name">{{objData.name}}</p>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
59
|
<div class="item-infos">
|
90e0ebc2
YunaiV
mp:支持 wx-reply 发送...
|
60
|
<wx-voice-player :url="objData.url" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
61
62
63
64
65
|
</div>
<el-row class="ope-row">
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj"></el-button>
</el-row>
</div>
|
90e0ebc2
YunaiV
mp:支持 wx-reply 发送...
|
66
|
<div v-else>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
67
|
<el-row style="text-align: center">
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
68
|
<!-- 选择素材 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
69
|
<el-col :span="12" class="col-select">
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
70
71
72
73
74
75
|
<el-button type="success" @click="openMaterial">
素材库选择<i class="el-icon-circle-check el-icon--right"></i>
</el-button>
<el-dialog title="选择语音" :visible.sync="dialogVoiceVisible" width="90%" append-to-body>
<WxMaterialSelect :objData="objData" @selectMaterial="selectMaterial"></WxMaterialSelect>
</el-dialog>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
76
|
</el-col>
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
77
|
<!-- 文件上传 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
78
|
<el-col :span="12" class="col-add">
|
90e0ebc2
YunaiV
mp:支持 wx-reply 发送...
|
79
80
|
<el-upload :action="actionUrl" :headers="headers" multiple :limit="1" :file-list="fileList" :data="uploadData"
:before-upload="beforeVoiceUpload" :on-success="handleUploadSuccess">
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
81
|
<el-button type="primary">点击上传</el-button>
|
90e0ebc2
YunaiV
mp:支持 wx-reply 发送...
|
82
|
<div slot="tip" class="el-upload__tip">格式支持 mp3/wma/wav/amr,文件大小不超过 2M,播放长度不超过 60s</div>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
83
84
85
86
|
</el-upload>
</el-col>
</el-row>
</div>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
87
88
|
</el-row>
</el-tab-pane>
|
7ba6a2e3
YunaiV
mp:增加【视频】消息的发送
|
89
|
<!-- 类型 4:视频 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
90
91
92
|
<el-tab-pane name="video">
<span slot="label"><i class="el-icon-share"></i> 视频</span>
<el-row>
|
858b4e81
YunaiV
mp:优化前端消息发送的缓存逻辑
|
93
|
<el-input v-model="objData.title" placeholder="请输入标题" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
94
|
<div style="margin: 20px 0;"></div>
|
858b4e81
YunaiV
mp:优化前端消息发送的缓存逻辑
|
95
|
<el-input v-model="objData.description" placeholder="请输入描述" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
96
97
|
<div style="margin: 20px 0;"></div>
<div style="text-align: center;">
|
7ba6a2e3
YunaiV
mp:增加【视频】消息的发送
|
98
|
<wx-video-player v-if="objData.url" :url="objData.url" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
99
100
|
</div>
<div style="margin: 20px 0;"></div>
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<el-row style="text-align: center">
<!-- 选择素材 -->
<el-col :span="12">
<el-button type="success" @click="openMaterial">
素材库选择<i class="el-icon-circle-check el-icon--right"></i>
</el-button>
<el-dialog title="选择视频" :visible.sync="dialogVideoVisible" width="90%" append-to-body>
<wx-material-select :objData="objData" @selectMaterial="selectMaterial" />
</el-dialog>
</el-col>
<!-- 文件上传 -->
<el-col :span="12">
<el-upload :action="actionUrl" :headers="headers" multiple :limit="1" :file-list="fileList" :data="uploadData"
:before-upload="beforeVideoUpload" :on-success="handleUploadSuccess">
<el-button type="primary">新建视频<i class="el-icon-upload el-icon--right"></i></el-button>
</el-upload>
</el-col>
</el-row>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
119
120
|
</el-row>
</el-tab-pane>
|
02ccf52d
YunaiV
mp:增加发送【图文】消息
|
121
|
<!-- 类型 5:图文 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
122
123
124
|
<el-tab-pane name="news">
<span slot="label"><i class="el-icon-news"></i> 图文</span>
<el-row>
|
02ccf52d
YunaiV
mp:增加发送【图文】消息
|
125
126
|
<div class="select-item" v-if="objData.articles">
<wx-news :articles="objData.articles" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
127
|
<el-row class="ope-row">
|
02ccf52d
YunaiV
mp:增加发送【图文】消息
|
128
|
<el-button type="danger" icon="el-icon-delete" circle @click="deleteObj" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
129
130
|
</el-row>
</div>
|
02ccf52d
YunaiV
mp:增加发送【图文】消息
|
131
|
<!-- 选择素材 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
132
133
|
<div v-if="!objData.content">
<el-row style="text-align: center">
|
02ccf52d
YunaiV
mp:增加发送【图文】消息
|
134
|
<el-col :span="24">
|
32f152cc
YunaiV
mp:支持 wx-reply 发送...
|
135
|
<el-button type="success" @click="openMaterial">{{newsType === '1' ? '选择已发布图文' : '选择草稿箱图文'}}<i class="el-icon-circle-check el-icon--right"></i></el-button>
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
136
137
138
139
|
</el-col>
</el-row>
</div>
<el-dialog title="选择图文" :visible.sync="dialogNewsVisible" width="90%" append-to-body>
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
140
|
<wx-material-select :objData="objData" @selectMaterial="selectMaterial" :newsType="newsType" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
141
142
143
|
</el-dialog>
</el-row>
</el-tab-pane>
|
267b1790
YunaiV
mp:支持发送【视频】消息时,支持...
|
144
|
<!-- 类型 6:音乐 -->
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
145
146
147
148
149
|
<el-tab-pane name="music">
<span slot="label"><i class="el-icon-service"></i> 音乐</span>
<el-row>
<el-col :span="6">
<div class="thumb-div">
|
32f152cc
YunaiV
mp:支持 wx-reply 发送...
|
150
|
<img style="width: 100px" v-if="objData.thumbMediaUrl" :src="objData.thumbMediaUrl">
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
151
152
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
<div class="thumb-but">
|
32f152cc
YunaiV
mp:支持 wx-reply 发送...
|
153
154
|
<el-upload :action="actionUrl" :headers="headers" multiple :limit="1" :file-list="fileList" :data="uploadData"
:before-upload="beforeThumbImageUpload" :on-success="handleUploadSuccess">
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
155
156
157
158
159
160
|
<el-button slot="trigger" size="mini" type="text">本地上传</el-button>
<el-button size="mini" type="text" @click="openMaterial" style="margin-left: 5px">素材库选择</el-button>
</el-upload>
</div>
</div>
<el-dialog title="选择图片" :visible.sync="dialogThumbVisible" width="80%" append-to-body>
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
161
|
<wx-material-select :objData="{type:'image', accountId: objData.accountId}" @selectMaterial="selectMaterial" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
162
163
164
|
</el-dialog>
</el-col>
<el-col :span="18">
|
32f152cc
YunaiV
mp:支持 wx-reply 发送...
|
165
|
<el-input v-model="objData.title" placeholder="请输入标题" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
166
|
<div style="margin: 20px 0;"></div>
|
32f152cc
YunaiV
mp:支持 wx-reply 发送...
|
167
|
<el-input v-model="objData.description" placeholder="请输入描述" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
168
169
170
|
</el-col>
</el-row>
<div style="margin: 20px 0;"></div>
|
858b4e81
YunaiV
mp:优化前端消息发送的缓存逻辑
|
171
|
<el-input v-model="objData.musicUrl" placeholder="请输入音乐链接" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
172
|
<div style="margin: 20px 0;"></div>
|
858b4e81
YunaiV
mp:优化前端消息发送的缓存逻辑
|
173
|
<el-input v-model="objData.hqMusicUrl" placeholder="请输入高质量音乐链接" @input="inputContent" />
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
174
175
176
177
178
|
</el-tab-pane>
</el-tabs>
</template>
<script>
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
179
180
181
182
|
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';
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
183
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
import { getAccessToken } from '@/utils/auth'
export default {
name: "wxReplySelect",
components: {
WxNews,
WxMaterialSelect,
WxVoicePlayer,
WxVideoPlayer
},
props: {
objData: { // 消息对象。
type: Object, // 设置为 Object 的原因,方便属性的传递
required: true,
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
198
|
},
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
199
200
201
|
newsType:{ // 图文类型:1、已发布图文;2、草稿箱图文
type: String,
default: "1"
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
202
|
},
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
203
204
205
206
207
208
|
},
data() {
return {
tempPlayerObj: {
type: '2'
},
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
209
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
210
211
212
|
tempObj: new Map().set( // 临时缓存,切换消息类型的 tab 的时候,可以保存对应的数据;
this.objData.type, // 消息类型
Object.assign({}, this.objData)), // 消息内容
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
213
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
214
215
216
217
218
219
|
// ========== 素材选择的弹窗,是否可见 ==========
dialogNewsVisible: false, // 图文
dialogImageVisible: false, // 图片
dialogVoiceVisible: false, // 语音
dialogVideoVisible: false, // 视频
dialogThumbVisible: false, // 缩略图
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
220
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
// ========== 文件上传(图片、语音、视频) ==========
fileList: [], // 文件列表
uploadData: {
"accountId": undefined,
"type": this.objData.type,
"title":'',
"introduction":''
},
actionUrl: process.env.VUE_APP_BASE_API + '/admin-api/mp/material/upload-temporary',
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
}
},
methods:{
beforeThumbImageUpload(file){
const isType = file.type === 'image/jpeg'
|| file.type === 'image/png'
|| file.type === 'image/gif'
|| file.type === 'image/bmp'
|| file.type === 'image/jpg';
if (!isType) {
this.$message.error('上传图片格式不对!');
return false;
}
const isLt = file.size / 1024 / 1024 < 2;
if (!isLt) {
this.$message.error('上传图片大小不能超过 2M!');
return false;
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
248
|
}
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
249
250
|
this.uploadData.accountId = this.objData.accountId;
return true;
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
251
|
},
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
beforeVoiceUpload(file){
// 校验格式
const isType = file.type === 'audio/mp3'
|| file.type === 'audio/mpeg'
|| file.type === 'audio/wma'
|| file.type === 'audio/wav'
|| file.type === 'audio/amr';
if (!isType) {
this.$message.error('上传语音格式不对!' + file.type);
return false;
}
// 校验大小
const isLt = file.size / 1024 / 1024 < 2;
if (!isLt) {
this.$message.error('上传语音大小不能超过 2M!');
return false;
}
this.uploadData.accountId = this.objData.accountId;
return true;
},
beforeImageUpload(file) {
// 校验格式
const isType = file.type === 'image/jpeg'
|| file.type === 'image/png'
|| file.type === 'image/gif'
|| file.type === 'image/bmp'
|| file.type === 'image/jpg';
if (!isType) {
this.$message.error('上传图片格式不对!');
return false;
}
// 校验大小
const isLt = file.size / 1024 / 1024 < 2;
if (!isLt) {
this.$message.error('上传图片大小不能超过 2M!');
return false;
}
this.uploadData.accountId = this.objData.accountId;
return true;
},
beforeVideoUpload(file){
// 校验格式
const isType = file.type === 'video/mp4';
if (!isType) {
this.$message.error('上传视频格式不对!');
return false;
}
// 校验大小
const isLt = file.size / 1024 / 1024 < 10;
if (!isLt) {
this.$message.error('上传视频大小不能超过 10M!');
return false;
}
this.uploadData.accountId = this.objData.accountId;
return true;
},
handleUploadSuccess(response, file, fileList) {
if (response.code !== 0) {
this.$message.error('上传出错:' + response.msg)
return false;
}
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
313
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
314
315
316
317
|
// 清空上传时的各种数据
this.fileList = []
this.uploadData.title = ''
this.uploadData.introduction = ''
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
318
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
// 上传好的文件,本质是个素材,所以可以进行选中
let item = response.data
this.selectMaterial(item)
},
/**
* 切换消息类型的 tab
*
* @param tab tab
*/
handleClick(tab) {
// 设置后续文件上传的文件类型
this.uploadData.type = this.objData.type;
if (this.uploadData.type === 'music') { // 【音乐】上传的是缩略图
this.uploadData.type = 'thumb';
}
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
334
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
// 从 tempObj 临时缓存中,获取对应的数据,并设置回 objData
let tempObjItem = this.tempObj.get(this.objData.type)
if (tempObjItem) {
this.objData.content = tempObjItem.content ? tempObjItem.content : null
this.objData.mediaId = tempObjItem.mediaId ? tempObjItem.mediaId : null
this.objData.url = tempObjItem.url ? tempObjItem.url : null
this.objData.name = tempObjItem.url ? tempObjItem.name : null
this.objData.title = tempObjItem.title ? tempObjItem.title : null
this.objData.description = tempObjItem.description ? tempObjItem.description : null
return;
}
// 如果获取不到,需要把 objData 复原
// 必须使用 $set 赋值,不然 input 无法输入内容
this.$set(this.objData, 'content', '');
|
64fa3a7e
YunaiV
mp:修复 wx-reply 组件...
|
349
350
|
this.$delete(this.objData, 'mediaId');
this.$delete(this.objData, 'url');
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
351
352
|
this.$set(this.objData, 'title', '');
this.$set(this.objData, 'description', '');
|
64fa3a7e
YunaiV
mp:修复 wx-reply 组件...
|
353
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
354
355
356
357
358
359
360
361
362
|
},
/**
* 选择素材,将设置设置到 objData 变量
*
* @param item 素材
*/
selectMaterial(item) {
// 选择好素材,所以隐藏弹窗
this.closeMaterial();
|
29cf7704
YunaiV
mp:支持 wx-reply 发送...
|
363
|
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
// 创建 tempObjItem 对象,并设置对应的值
let tempObjItem = {}
tempObjItem.type = this.objData.type;
if (this.objData.type === 'news') {
tempObjItem.articles = item.content.newsItem
this.objData.articles = item.content.newsItem
} else if (this.objData.type === 'music') { // 音乐需要特殊处理,因为选择的是图片的缩略图
tempObjItem.thumbMediaId = item.mediaId
this.objData.thumbMediaId = item.mediaId
tempObjItem.thumbMediaUrl = item.url
this.objData.thumbMediaUrl = item.url
// title、introduction、musicUrl、hqMusicUrl:从 objData 到 tempObjItem,避免上传素材后,被覆盖掉
tempObjItem.title = this.objData.title || ''
tempObjItem.introduction = this.objData.introduction || ''
tempObjItem.musicUrl = this.objData.musicUrl || ''
tempObjItem.hqMusicUrl = this.objData.hqMusicUrl || ''
} else if (this.objData.type === 'image'
|| this.objData.type === 'voice') {
tempObjItem.mediaId = item.mediaId
this.objData.mediaId = item.mediaId
tempObjItem.url = item.url;
this.objData.url = item.url;
tempObjItem.name = item.name
this.objData.name = item.name
} else if (this.objData.type === 'video') {
tempObjItem.mediaId = item.mediaId
this.objData.mediaId = item.mediaId
tempObjItem.url = item.url;
this.objData.url = item.url;
tempObjItem.name = item.name
this.objData.name = item.name
// title、introduction:从 item 到 tempObjItem,因为素材里有 title、introduction
if (item.title) {
this.objData.title = item.title || ''
tempObjItem.title = item.title || ''
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
399
|
}
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
400
401
402
|
if (item.introduction) {
this.objData.description = item.introduction || '' // 消息使用的是 description,素材使用的是 introduction,所以转换下
tempObjItem.description = item.introduction || ''
|
858b4e81
YunaiV
mp:优化前端消息发送的缓存逻辑
|
403
|
}
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
} else if (this.objData.type === 'text') {
this.objData.content = item.content || ''
}
// 最终设置到临时缓存
this.tempObj.set(this.objData.type, tempObjItem)
},
openMaterial() {
if (this.objData.type === 'news') {
this.dialogNewsVisible = true
} else if(this.objData.type === 'image') {
this.dialogImageVisible = true
} else if(this.objData.type === 'voice') {
this.dialogVoiceVisible = true
} else if(this.objData.type === 'video') {
this.dialogVideoVisible = true
} else if(this.objData.type === 'music') {
this.dialogThumbVisible = true
}
},
closeMaterial() {
this.dialogNewsVisible = false
this.dialogImageVisible = false
this.dialogVoiceVisible = false
this.dialogVideoVisible = false
this.dialogThumbVisible = false
},
deleteObj() {
if (this.objData.type === 'news') {
this.$delete(this.objData, 'articles');
} else if(this.objData.type === 'image') {
this.objData.mediaId = null
|
64fa3a7e
YunaiV
mp:修复 wx-reply 组件...
|
435
|
this.$delete(this.objData, 'url');
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
436
437
438
|
this.objData.name = null
} else if(this.objData.type === 'voice') {
this.objData.mediaId = null
|
64fa3a7e
YunaiV
mp:修复 wx-reply 组件...
|
439
|
this.$delete(this.objData, 'url');
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
440
441
442
|
this.objData.name = null
} else if(this.objData.type === 'video') {
this.objData.mediaId = null
|
64fa3a7e
YunaiV
mp:修复 wx-reply 组件...
|
443
|
this.$delete(this.objData, 'url');
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
444
445
446
447
448
449
450
451
452
453
454
455
|
this.objData.name = null
this.objData.title = null
this.objData.description = null
} else if(this.objData.type === 'music') {
this.objData.thumbMediaId = null
this.objData.thumbMediaUrl = null
this.objData.title = null
this.objData.description = null
this.objData.musicUrl = null
this.objData.hqMusicUrl = null
} else if(this.objData.type === 'text') {
this.objData.content = null
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
456
|
}
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
457
458
459
460
461
462
463
464
465
466
467
|
// 覆盖缓存
this.tempObj.set(this.objData.type, Object.assign({}, this.objData));
},
/**
* 输入时,缓存每次 objData 到 tempObj 中
*
* why?不确定为什么 v-model="objData.content" 不能自动缓存,所以通过这样的方式
*/
inputContent(str) {
// 覆盖缓存
this.tempObj.set(this.objData.type, Object.assign({}, this.objData));
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
468
|
}
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
469
470
|
}
};
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
471
472
473
|
</script>
<style lang="scss" scoped>
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
474
475
476
477
|
.public-account-management{
.el-input{
width: 70%;
margin-right: 2%;
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
478
|
}
|
3654afed
YunaiV
mp:修复 WxMaterialS...
|
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
}
.pagination{
text-align: right;
margin-right: 25px;
}
.select-item{
width: 280px;
padding: 10px;
margin: 0 auto 10px auto;
border: 1px solid #eaeaea;
}
.select-item2{
padding: 10px;
margin: 0 auto 10px auto;
border: 1px solid #eaeaea;
}
.ope-row{
padding-top: 10px;
text-align: center;
}
.item-name{
font-size: 12px;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
text-align: center;
}
.el-form-item__content{
line-height:unset!important;
}
.col-select{
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
width: 49.5%;
}
.col-select2{
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
}
.col-add{
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
width: 49.5%;
float: right
}
.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;
}
.material-img {
width: 100%;
}
.thumb-div{
display: inline-block;
text-align: center;
}
.item-infos{
width: 30%;
margin: auto
}
|
f8eed5dd
YunaiV
mp:初始化回复组件
|
547
|
</style>
|