mp:优化 wx-editor 图片的上传
parent
73fac5235f
commit
28884ee638
|
@ -1,6 +1,8 @@
|
||||||
<!--
|
<!--
|
||||||
- Copyright (C) 2018-2019
|
- Copyright (C) 2018-2019
|
||||||
- All rights reserved, Designed By www.joolun.com
|
- All rights reserved, Designed By www.joolun.com
|
||||||
|
芋道源码:
|
||||||
|
① 调整 uploadData 属性,只需要传入 accountId 即可
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div id="wxEditor">
|
<div id="wxEditor">
|
||||||
|
@ -44,14 +46,16 @@ import { getAccessToken } from "@/utils/auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
uploadData: {
|
/* 公众号账号编号 */
|
||||||
type: Object
|
accountId: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
},
|
},
|
||||||
/*编辑器的内容*/
|
/* 编辑器的内容 */
|
||||||
value: {
|
value: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
/*图片大小*/
|
/* 图片大小 */
|
||||||
maxSize: {
|
maxSize: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 4000 // kb
|
default: 4000 // kb
|
||||||
|
@ -97,6 +101,10 @@ export default {
|
||||||
},
|
},
|
||||||
actionUrl: process.env.VUE_APP_BASE_API +'/admin-api/mp/material/upload-news-image', // 这里写你要上传的图片服务器地址
|
actionUrl: process.env.VUE_APP_BASE_API +'/admin-api/mp/material/upload-news-image', // 这里写你要上传的图片服务器地址
|
||||||
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
|
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
|
||||||
|
uploadData: {
|
||||||
|
"type": 'image', // TODO 芋艿:试试要不要换成 thumb
|
||||||
|
"accountId": this.accountId,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -117,7 +117,7 @@ SOFTWARE.
|
||||||
<div class="right" v-loading="addMaterialLoading" v-if="articlesAdd.length > 0">
|
<div class="right" v-loading="addMaterialLoading" v-if="articlesAdd.length > 0">
|
||||||
<!--富文本编辑器组件-->
|
<!--富文本编辑器组件-->
|
||||||
<el-row>
|
<el-row>
|
||||||
<wx-editor v-model="articlesAdd[isActiveAddNews].content" :uploadData="uploadData"
|
<wx-editor v-model="articlesAdd[isActiveAddNews].content" :account-id="this.uploadData.accountId"
|
||||||
v-if="hackResetEditor"/>
|
v-if="hackResetEditor"/>
|
||||||
</el-row>
|
</el-row>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
|
@ -204,9 +204,7 @@ export default {
|
||||||
fileList: [],
|
fileList: [],
|
||||||
uploadData: {
|
uploadData: {
|
||||||
"type": 'image', // TODO 芋艿:试试要不要换成 thumb
|
"type": 'image', // TODO 芋艿:试试要不要换成 thumb
|
||||||
"title": '',
|
// "accountId": 1,
|
||||||
"introduction": '',
|
|
||||||
"accountId": 1,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// ========== 草稿新建 or 修改 ==========
|
// ========== 草稿新建 or 修改 ==========
|
||||||
|
@ -495,8 +493,6 @@ export default {
|
||||||
|
|
||||||
// 重置上传文件的表单
|
// 重置上传文件的表单
|
||||||
this.fileList = []
|
this.fileList = []
|
||||||
this.uploadData.title = ''
|
|
||||||
this.uploadData.introduction = ''
|
|
||||||
|
|
||||||
// 设置草稿的封面字段
|
// 设置草稿的封面字段
|
||||||
this.articlesAdd[this.isActiveAddNews].thumbMediaId = response.data.mediaId
|
this.articlesAdd[this.isActiveAddNews].thumbMediaId = response.data.mediaId
|
||||||
|
|
Loading…
Reference in New Issue