1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<template>
<div class="publish">
<van-cell-group class="content">
<van-field
v-model="message"
autosize
type="textarea"
maxlength="200"
placeholder="这一刻的想法..."
show-word-limit
/>
<van-uploader
class="add"
multiple
v-model="fileList"
:after-read="afterRead"
>
<img
class="add-img"
src="@/assets/images/editAdd.png"
alt="添加图片和视频"
/>
</van-uploader>
</van-cell-group>
<div class="btn">
<van-button type="primary" size="large" @click="onPublish"
>发布</van-button
>
</div>
</div>
</template>
<script>
import { uploadImage } from "@/api/infomation";
export default {
name: "publish",
data() {
return {
message: "",
fileShow: false,
fileList: []
};
},
methods: {
onPublish() {
console.log("发布===文字", this.message);
console.log("发布===文件", this.fileList);
const fd = new FormData();
this.fileList.forEach(file => {
fd.append("files", file.file);
});
fd.append("zxField", this.message);
fd.append("userId", "13100911369");
uploadImage(fd).then();
},
openPopup() {
this.fileShow = true;
},
afterRead(file) {
console.log(file);
}
}
};
</script>
<style lang="scss" scoped>
.content {
position: relative;
height: 350px;
margin-top: 10px;
background-color: #fff;
.van-field {
height: 230px;
}
::v-deep .van-field__word-limit {
position: absolute;
right: 0;
bottom: 0;
}
.add {
position: absolute;
left: 10px;
bottom: 20px;
.add-img {
width: 88px;
height: 88px;
}
}
}
.btn {
padding: 10px 16px;
}
</style>