@jx3box/jx3box-common-ui 5.7.5 → 5.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/upload/upload_banner.vue +32 -24
package/package.json
CHANGED
|
@@ -9,23 +9,29 @@
|
|
|
9
9
|
<div v-else class="u-upload el-upload el-upload--picture-card" @click="select">
|
|
10
10
|
<i class="el-icon-plus"></i>
|
|
11
11
|
</div>
|
|
12
|
-
<input
|
|
12
|
+
<input
|
|
13
|
+
class="u-upload-input"
|
|
14
|
+
type="file"
|
|
15
|
+
@change="upload"
|
|
16
|
+
ref="uploadInput"
|
|
17
|
+
accept=".jpg, .jpeg, .png, .gif, .bmp,.webp"
|
|
18
|
+
/>
|
|
13
19
|
</div>
|
|
14
20
|
</template>
|
|
15
21
|
|
|
16
22
|
<script>
|
|
17
23
|
import { getThumbnail } from "@jx3box/jx3box-common/js/utils";
|
|
18
|
-
import { uploadImage } from
|
|
24
|
+
import { uploadImage } from "../../service/cms.js";
|
|
19
25
|
export default {
|
|
20
|
-
name:
|
|
26
|
+
name: "upload-banner",
|
|
21
27
|
props: {
|
|
22
28
|
content: {
|
|
23
29
|
type: String,
|
|
24
|
-
default:
|
|
30
|
+
default: "",
|
|
25
31
|
},
|
|
26
32
|
info: {
|
|
27
33
|
type: String,
|
|
28
|
-
default:
|
|
34
|
+
default: "用于展示tips",
|
|
29
35
|
},
|
|
30
36
|
size: {
|
|
31
37
|
type: [Array, Number],
|
|
@@ -38,19 +44,19 @@ export default {
|
|
|
38
44
|
},
|
|
39
45
|
data() {
|
|
40
46
|
return {
|
|
41
|
-
data: this.content ||
|
|
47
|
+
data: this.content || "",
|
|
42
48
|
};
|
|
43
49
|
},
|
|
44
50
|
model: {
|
|
45
|
-
prop:
|
|
46
|
-
event:
|
|
51
|
+
prop: "content",
|
|
52
|
+
event: "input",
|
|
47
53
|
},
|
|
48
54
|
watch: {
|
|
49
55
|
content(val) {
|
|
50
56
|
this.data = val;
|
|
51
57
|
},
|
|
52
58
|
data(val) {
|
|
53
|
-
this.$emit(
|
|
59
|
+
this.$emit("input", val);
|
|
54
60
|
},
|
|
55
61
|
},
|
|
56
62
|
computed: {
|
|
@@ -64,29 +70,31 @@ export default {
|
|
|
64
70
|
uploadStyle() {
|
|
65
71
|
let size = Array.isArray(this.size) ? this.size : [this.size, this.size];
|
|
66
72
|
return {
|
|
67
|
-
width: size[0] +
|
|
68
|
-
height: size[1] +
|
|
73
|
+
width: size[0] + "px",
|
|
74
|
+
height: size[1] + "px",
|
|
69
75
|
};
|
|
70
76
|
},
|
|
71
77
|
},
|
|
72
78
|
methods: {
|
|
73
79
|
select() {
|
|
74
|
-
this.fileInput.dispatchEvent(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
this.fileInput.dispatchEvent(
|
|
81
|
+
new MouseEvent("click", {
|
|
82
|
+
bubbles: true,
|
|
83
|
+
cancelable: true,
|
|
84
|
+
view: window,
|
|
85
|
+
})
|
|
86
|
+
);
|
|
79
87
|
},
|
|
80
88
|
upload() {
|
|
81
89
|
const file = this.fileInput.files[0];
|
|
82
90
|
if (!file) return;
|
|
83
91
|
if (file.size > this.maxSize * 1024 * 1024) {
|
|
84
|
-
this.$message.error(
|
|
92
|
+
this.$message.error("图片大小不能超过" + this.maxSize + "M");
|
|
85
93
|
return;
|
|
86
94
|
}
|
|
87
95
|
const formData = new FormData();
|
|
88
|
-
formData.append(
|
|
89
|
-
uploadImage(formData).then(res => {
|
|
96
|
+
formData.append("avatar", file);
|
|
97
|
+
uploadImage(formData).then((res) => {
|
|
90
98
|
this.data = res.data.data[0];
|
|
91
99
|
this.$message({
|
|
92
100
|
message: "上传成功",
|
|
@@ -95,16 +103,16 @@ export default {
|
|
|
95
103
|
});
|
|
96
104
|
},
|
|
97
105
|
remove() {
|
|
98
|
-
this.data =
|
|
106
|
+
this.data = "";
|
|
99
107
|
},
|
|
100
|
-
}
|
|
101
|
-
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
102
110
|
</script>
|
|
103
111
|
|
|
104
112
|
<style lang="less">
|
|
105
113
|
.c-upload-banner {
|
|
106
|
-
.u-tip{
|
|
107
|
-
padding:5px 15px;
|
|
114
|
+
.u-tip {
|
|
115
|
+
padding: 5px 15px;
|
|
108
116
|
}
|
|
109
117
|
.u-upload {
|
|
110
118
|
.pr;
|