Skip to content

Commit aa3a9fa

Browse files
committed
mp:优化 wx-editor 图片的上传
1 parent b7c63e5 commit aa3a9fa

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/views/mp/components/wx-editor/WxEditor.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<!--
22
- Copyright (C) 2018-2019
33
- All rights reserved, Designed By www.joolun.com
4+
芋道源码:
5+
① 调整 uploadData 属性,只需要传入 accountId 即可
46
-->
57
<template>
68
<div id="wxEditor">
@@ -44,14 +46,16 @@ import { getAccessToken } from "@/utils/auth";
4446
4547
export default {
4648
props: {
47-
uploadData: {
48-
type: Object
49+
/* 公众号账号编号 */
50+
accountId: {
51+
type: Number,
52+
required: true
4953
},
50-
/*编辑器的内容*/
54+
/* 编辑器的内容 */
5155
value: {
5256
type: String
5357
},
54-
/*图片大小*/
58+
/* 图片大小 */
5559
maxSize: {
5660
type: Number,
5761
default: 4000 // kb
@@ -97,6 +101,10 @@ export default {
97101
},
98102
actionUrl: process.env.VUE_APP_BASE_API +'/admin-api/mp/material/upload-news-image', // 这里写你要上传的图片服务器地址
99103
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
104+
uploadData: {
105+
"type": 'image', // TODO 芋艿:试试要不要换成 thumb
106+
"accountId": this.accountId,
107+
},
100108
}
101109
},
102110
methods: {

src/views/mp/draft/index.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ SOFTWARE.
117117
<div class="right" v-loading="addMaterialLoading" v-if="articlesAdd.length > 0">
118118
<!--富文本编辑器组件-->
119119
<el-row>
120-
<wx-editor v-model="articlesAdd[isActiveAddNews].content" :uploadData="uploadData"
120+
<wx-editor v-model="articlesAdd[isActiveAddNews].content" :account-id="this.uploadData.accountId"
121121
v-if="hackResetEditor"/>
122122
</el-row>
123123
<br><br><br><br>
@@ -204,9 +204,7 @@ export default {
204204
fileList: [],
205205
uploadData: {
206206
"type": 'image', // TODO 芋艿:试试要不要换成 thumb
207-
"title": '',
208-
"introduction": '',
209-
"accountId": 1,
207+
// "accountId": 1,
210208
},
211209
212210
// ========== 草稿新建 or 修改 ==========
@@ -495,8 +493,6 @@ export default {
495493
496494
// 重置上传文件的表单
497495
this.fileList = []
498-
this.uploadData.title = ''
499-
this.uploadData.introduction = ''
500496
501497
// 设置草稿的封面字段
502498
this.articlesAdd[this.isActiveAddNews].thumbMediaId = response.data.mediaId

0 commit comments

Comments
 (0)