|
@@ -7,17 +7,17 @@
|
7
|
7
|
<div class="app-container">
|
8
|
8
|
<el-tabs type="border-card">
|
9
|
9
|
<el-tab-pane label="文章">
|
10
|
|
- <el-form label-width="80px" class="clearfix">
|
|
10
|
+ <el-form label-width="80px" class="clearfix" :model="form" ref="form" v-loading="formloading" :element-loading-text="loadingText">
|
11
|
11
|
<el-row>
|
12
|
12
|
<el-col :span="24">
|
13
|
13
|
<el-form-item label="文章标题:">
|
14
|
|
- <el-input placeholder="文章标题"></el-input>
|
|
14
|
+ <el-input v-model="form.act_name" placeholder="文章标题"></el-input>
|
15
|
15
|
</el-form-item>
|
16
|
|
- <el-form-item label="文章内容:" prop="org_introduction">
|
|
16
|
+ <el-form-item label="文章内容:">
|
17
|
17
|
<keep-alive>
|
18
|
18
|
<neditor ref="neditor"
|
19
|
19
|
id="editor"
|
20
|
|
- v-bind:r_content="form.org_introduction">
|
|
20
|
+ v-bind:r_content="form.act_content">
|
21
|
21
|
</neditor>
|
22
|
22
|
</keep-alive>
|
23
|
23
|
</el-form-item>
|
|
@@ -25,18 +25,19 @@
|
25
|
25
|
<el-radio v-model="radio" label="1" @click.native.prevent="select()" >单图</el-radio>
|
26
|
26
|
<el-radio v-model="radio" label="2" @click.native.prevent="clickitem()" >三图</el-radio>
|
27
|
27
|
</el-form-item>
|
28
|
|
- <el-form-item>
|
|
28
|
+ <el-form-item prop="org_logo">
|
29
|
29
|
<el-col :span="3">
|
30
|
30
|
<div>
|
31
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
32
|
|
- <img v-if="imageUrl" :src="imageUrl" class="avatar">
|
33
|
|
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
34
|
|
- </el-upload>
|
35
|
|
- </div>
|
36
|
|
- </el-col>
|
37
|
|
- <el-col :span="3">
|
38
|
|
- <div class="elupload" v-if="show">
|
39
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
31
|
+ <el-upload
|
|
32
|
+ v-loading="uploading"
|
|
33
|
+ :element-loading-text="loadingText"
|
|
34
|
+ class="avatar-uploader"
|
|
35
|
+ :data="uploadData"
|
|
36
|
+ action="https://upload.qiniup.com"
|
|
37
|
+ :show-file-list="false"
|
|
38
|
+ :on-error="handleAvatarError"
|
|
39
|
+ :on-success="handleAvatarSuccess"
|
|
40
|
+ :before-upload="beforeAvatarUpload">
|
40
|
41
|
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
41
|
42
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
42
|
43
|
</el-upload>
|
|
@@ -44,7 +45,11 @@
|
44
|
45
|
</el-col>
|
45
|
46
|
<el-col :span="3">
|
46
|
47
|
<div v-if="show">
|
47
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
48
|
+ <el-upload
|
|
49
|
+ class="avatar-uploader"
|
|
50
|
+ :show-file-list="false"
|
|
51
|
+ :on-success="handleAvatarSuccess"
|
|
52
|
+ :before-upload="beforeAvatarUpload">
|
48
|
53
|
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
49
|
54
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
50
|
55
|
</el-upload>
|
|
@@ -67,7 +72,7 @@
|
67
|
72
|
<el-row :span="24">
|
68
|
73
|
<el-col :span="24">
|
69
|
74
|
<el-form-item>
|
70
|
|
- <el-button size="small" type="primary" style="width: 100px">发布</el-button>
|
|
75
|
+ <el-button size="small" type="primary" style="width: 100px" @click="submitForm">发布</el-button>
|
71
|
76
|
<el-button size="small" style="width: 100px">预览</el-button>
|
72
|
77
|
<el-button size="small" style="width: 100px">保存草稿</el-button>
|
73
|
78
|
<el-button size="small" style="width: 100px">取消</el-button>
|
|
@@ -112,7 +117,7 @@
|
112
|
117
|
</el-form-item>
|
113
|
118
|
<el-form-item label="视频封面:"></el-form-item>
|
114
|
119
|
<el-form-item>
|
115
|
|
- <el-upload class="avatar-uploader":show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
120
|
+ <el-upload class="avatar-uploader" :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
116
|
121
|
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
117
|
122
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
118
|
123
|
</el-upload>
|
|
@@ -153,6 +158,9 @@
|
153
|
158
|
import 'quill/dist/quill.snow.css'
|
154
|
159
|
import 'quill/dist/quill.bubble.css'
|
155
|
160
|
import Neditor from '@/components/Neditor'
|
|
161
|
+ import {submitForm} from '@/api/act/submitinfo'
|
|
162
|
+ import { getToken } from '@/api/qiniu'
|
|
163
|
+ import { getFileExtension} from '@/utils/tools'
|
156
|
164
|
export default {
|
157
|
165
|
name: 'createArticle',
|
158
|
166
|
components:{
|
|
@@ -188,13 +196,28 @@
|
188
|
196
|
company:"",
|
189
|
197
|
fileList: [{name: '123', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
|
190
|
198
|
form:{
|
191
|
|
- org_introduction:'',
|
192
|
|
- }
|
|
199
|
+ act_name:'',
|
|
200
|
+ act_content:'',
|
|
201
|
+ act_picture:'',
|
|
202
|
+ act_category:'',
|
|
203
|
+ org_logo:'',
|
|
204
|
+ },
|
|
205
|
+ formloading:false,
|
|
206
|
+ qiniuDomain: 'https://images.shengws.com/',
|
|
207
|
+ uploading:false,
|
|
208
|
+ loadingText:'',
|
|
209
|
+ uploadData: { token: '', key: '' },
|
193
|
210
|
}
|
194
|
211
|
},
|
195
|
212
|
methods: {
|
196
|
213
|
handleAvatarSuccess(res, file) {
|
197
|
|
- this.imageUrl = URL.createObjectURL(file.raw);
|
|
214
|
+ //this.imageUrl = URL.createObjectURL(file.raw);
|
|
215
|
+ this.form.org_logo = this.qiniuDomain + res.url;
|
|
216
|
+ },
|
|
217
|
+ handleAvatarError(err, file, fileList) {
|
|
218
|
+ this.$message.error(err);
|
|
219
|
+ this.uploading = false;
|
|
220
|
+ return false
|
198
|
221
|
},
|
199
|
222
|
beforeAvatarUpload(file) {
|
200
|
223
|
const isJPG = file.type === 'image/jpeg';
|
|
@@ -206,7 +229,27 @@
|
206
|
229
|
if (!isLt2M) {
|
207
|
230
|
this.$message.error('上传头像图片大小不能超过 2MB!');
|
208
|
231
|
}
|
209
|
|
- return isJPG && isLt2M;
|
|
232
|
+
|
|
233
|
+ var date = new Date()
|
|
234
|
+ var ext = getFileExtension(file.name)
|
|
235
|
+ var key = date.getFullYear() + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds() +'_o_' + file.uid + '.' + ext;
|
|
236
|
+ this.uploading = true;
|
|
237
|
+ this.loadingText = '封面图片上传中'
|
|
238
|
+
|
|
239
|
+ const _self = this
|
|
240
|
+ return new Promise((resolve, reject) => {
|
|
241
|
+ getToken().then(response => {
|
|
242
|
+ const token = response.data.data.uptoken
|
|
243
|
+ _self._data.uploadData.token = token
|
|
244
|
+ _self._data.uploadData.key = key
|
|
245
|
+ resolve(true)
|
|
246
|
+ }).catch(err => {
|
|
247
|
+ reject(false)
|
|
248
|
+ this.uploading = false;
|
|
249
|
+ })
|
|
250
|
+ })
|
|
251
|
+
|
|
252
|
+ //return isJPG && isLt2M;
|
210
|
253
|
},
|
211
|
254
|
beforeUpload(file) {
|
212
|
255
|
var testmsg=file.name.substring(file.name.lastIndexOf('.')+1)
|
|
@@ -245,6 +288,23 @@
|
245
|
288
|
beforeRemove(file, fileList) {
|
246
|
289
|
return this.$confirm(`确定移除 ${ file.name }?`);
|
247
|
290
|
},
|
|
291
|
+ submitForm(){
|
|
292
|
+ var params = new Object()
|
|
293
|
+ params.act_name = this.form.act_name
|
|
294
|
+ params.act_content = this.$refs.neditor.content
|
|
295
|
+ this.formloading=true
|
|
296
|
+ console.log("文章标题",params.act_name)
|
|
297
|
+ console.log("文章内容",params.act_content)
|
|
298
|
+ console.log("富文本编辑器的内容",params.act_content)
|
|
299
|
+ submitForm(params).then(response => {
|
|
300
|
+ if(response.data.state === 1){
|
|
301
|
+ this.$message({
|
|
302
|
+ type: 'success',
|
|
303
|
+ message: '成功!'
|
|
304
|
+ })
|
|
305
|
+ }
|
|
306
|
+ })
|
|
307
|
+ },
|
248
|
308
|
|
249
|
309
|
},
|
250
|
310
|
}
|