|
85 | 85 | <el-tab-pane name="video">
|
86 | 86 | <span slot="label"><i class="el-icon-share"></i> 视频</span>
|
87 | 87 | <el-row>
|
88 |
| - <el-input v-model="objData.title" placeholder="请输入标题"></el-input> |
| 88 | + <el-input v-model="objData.title" placeholder="请输入标题" @input="inputContent" /> |
89 | 89 | <div style="margin: 20px 0;"></div>
|
90 |
| - <el-input v-model="objData.description" placeholder="请输入描述"></el-input> |
| 90 | + <el-input v-model="objData.description" placeholder="请输入描述" @input="inputContent" /> |
91 | 91 | <div style="margin: 20px 0;"></div>
|
92 | 92 | <div style="text-align: center;">
|
93 | 93 | <wx-video-player v-if="objData.url" :url="objData.url" />
|
|
149 | 149 | </el-col>
|
150 | 150 | </el-row>
|
151 | 151 | <div style="margin: 20px 0;"></div>
|
152 |
| - <el-input v-model="objData.musicUrl" placeholder="请输入音乐链接"></el-input> |
| 152 | + <el-input v-model="objData.musicUrl" placeholder="请输入音乐链接" @input="inputContent" /> |
153 | 153 | <div style="margin: 20px 0;"></div>
|
154 |
| - <el-input v-model="objData.hqMusicUrl" placeholder="请输入高质量音乐链接"></el-input> |
| 154 | + <el-input v-model="objData.hqMusicUrl" placeholder="请输入高质量音乐链接" @input="inputContent" /> |
155 | 155 | </el-tab-pane>
|
156 | 156 | </el-tabs>
|
157 | 157 | </template>
|
|
309 | 309 |
|
310 | 310 | // 从 tempObj 临时缓存中,获取对应的数据,并设置回 objData
|
311 | 311 | let tempObjItem = this.tempObj.get(this.objData.type)
|
312 |
| - // console.log(this.objData.type) |
313 |
| - // console.log(tempObjItem) |
314 |
| - // console.log(this.objData) |
315 |
| - // console.log(this.tempObj) |
316 | 312 | if (tempObjItem) {
|
317 |
| - console.log(this.tempObj) |
318 | 313 | this.objData.content = tempObjItem.content ? tempObjItem.content : null
|
319 | 314 | this.objData.mediaId = tempObjItem.mediaId ? tempObjItem.mediaId : null
|
320 | 315 | this.objData.url = tempObjItem.url ? tempObjItem.url : null
|
321 | 316 | this.objData.name = tempObjItem.url ? tempObjItem.name : null
|
322 |
| -
|
323 |
| - // TODO 芋艿:临时注释掉,看看有没用 |
324 |
| - // this.objData.repDesc = tempObjItem.repDesc ? tempObjItem.repDesc : null |
| 317 | + this.objData.title = tempObjItem.title ? tempObjItem.title : null |
| 318 | + this.objData.description = tempObjItem.description ? tempObjItem.description : null |
325 | 319 | return;
|
326 | 320 | }
|
327 | 321 | // 如果获取不到,需要把 objData 复原
|
328 |
| - this.objData.content = undefined; |
329 |
| - this.objData.mediaId = undefined; |
330 |
| - this.objData.url = undefined; |
331 |
| - this.objData.name = undefined; |
332 |
| - // this.$delete(this.objData,'repDesc') |
| 322 | + // 必须使用 $set 赋值,不然 input 无法输入内容 |
| 323 | + this.$set(this.objData, 'content', ''); |
| 324 | + this.$set(this.objData, 'title', ''); |
| 325 | + this.$set(this.objData, 'description', ''); |
333 | 326 | },
|
334 | 327 | /**
|
335 | 328 | * 选择素材,将设置设置到 objData 变量
|
|
348 | 341 | this.objData.thumbMediaId = item.mediaId
|
349 | 342 | tempObjItem.thumbMediaUrl = item.url
|
350 | 343 | this.objData.thumbMediaUrl = item.url
|
351 |
| - // title、introduction、musicUrl、hqMusicUrl |
352 |
| - tempObjItem.title = this.objData.title |
353 |
| - tempObjItem.introduction = this.objData.introduction |
354 |
| - tempObjItem.musicUrl = this.objData.musicUrl |
355 |
| - tempObjItem.hqMusicUrl = this.objData.hqMusicUrl |
| 344 | + // title、introduction、musicUrl、hqMusicUrl:从 objData 到 tempObjItem,避免上传素材后,被覆盖掉 |
| 345 | + tempObjItem.title = this.objData.title || '' |
| 346 | + tempObjItem.introduction = this.objData.introduction || '' |
| 347 | + tempObjItem.musicUrl = this.objData.musicUrl || '' |
| 348 | + tempObjItem.hqMusicUrl = this.objData.hqMusicUrl || '' |
356 | 349 | } else if (this.objData.type === 'image'
|
357 | 350 | || this.objData.type === 'voice') {
|
358 | 351 | tempObjItem.mediaId = item.mediaId
|
|
368 | 361 | this.objData.url = item.url;
|
369 | 362 | tempObjItem.name = item.name
|
370 | 363 | this.objData.name = item.name
|
371 |
| - // title、introduction |
372 |
| - this.objData.title = item.title |
373 |
| - tempObjItem.title = this.objData.title |
374 |
| - this.objData.description = item.introduction // 消息使用的是 description,素材使用的是 introduction,所以转换下 |
375 |
| - tempObjItem.description = this.objData.introduction |
| 364 | + // title、introduction:从 item 到 tempObjItem,因为素材里有 title、introduction |
| 365 | + this.objData.title = item.title || '' |
| 366 | + tempObjItem.title = item.title || '' |
| 367 | + this.objData.description = item.introduction || '' // 消息使用的是 description,素材使用的是 introduction,所以转换下 |
| 368 | + tempObjItem.description = item.introduction || '' |
| 369 | + } else if (this.objData.type === 'text') { |
| 370 | + this.objData.content = item.content || '' |
376 | 371 | }
|
377 | 372 | // 最终设置到临时缓存
|
378 | 373 | this.tempObj.set(this.objData.type, tempObjItem)
|
|
398 | 393 | this.dialogThumbVisible = false
|
399 | 394 | },
|
400 | 395 | deleteObj() {
|
401 |
| - // this.$delete(this.objData, 'url'); TODO 芋艿:重新实现清空;还有 reset |
402 |
| - this.selectMaterial({}) // 选择一个空的素材 |
| 396 | + if (this.objData.type === 'news') { |
| 397 | + this.objData.articles = [] |
| 398 | + } else if(this.objData.type === 'image') { |
| 399 | + this.objData.mediaId = null |
| 400 | + this.objData.url = null |
| 401 | + this.objData.name = null |
| 402 | + } else if(this.objData.type === 'voice') { |
| 403 | + this.objData.mediaId = null |
| 404 | + this.objData.url = null |
| 405 | + this.objData.name = null |
| 406 | + } else if(this.objData.type === 'video') { |
| 407 | + this.objData.mediaId = null |
| 408 | + this.objData.url = null |
| 409 | + this.objData.name = null |
| 410 | + this.objData.title = null |
| 411 | + this.objData.description = null |
| 412 | + } else if(this.objData.type === 'music') { |
| 413 | + this.objData.thumbMediaId = null |
| 414 | + this.objData.thumbMediaUrl = null |
| 415 | + this.objData.title = null |
| 416 | + this.objData.description = null |
| 417 | + this.objData.musicUrl = null |
| 418 | + this.objData.hqMusicUrl = null |
| 419 | + } else if(this.objData.type === 'text') { |
| 420 | + this.objData.content = null |
| 421 | + } |
| 422 | + // 覆盖缓存 |
| 423 | + this.tempObj.set(this.objData.type, Object.assign({}, this.objData)); |
403 | 424 | },
|
404 | 425 | getPage(page, params) {
|
405 | 426 | this.tableLoading = true
|
|
426 | 447 | * why?不确定为什么 v-model="objData.content" 不能自动缓存,所以通过这样的方式
|
427 | 448 | */
|
428 | 449 | inputContent(str) {
|
429 |
| - let tempObjItem = {...this.objData}; |
430 |
| - this.tempObj.set(this.objData.type, tempObjItem); |
| 450 | + // 覆盖缓存 |
| 451 | + this.tempObj.set(this.objData.type, Object.assign({}, this.objData)); |
431 | 452 | }
|
432 | 453 | }
|
433 | 454 | };
|
|
0 commit comments