lzq пре 6 година
родитељ
комит
8b55c577e7

+ 31 - 1
admin-update/src/cool/components/editor/quill.vue

@@ -5,6 +5,7 @@
 		<el-upload
 			:show-file-list="false"
 			:action="uploadURL"
+			:http-request="httpRequest"
 			:headers="{
 				Authorization: token,
 				...headers
@@ -124,13 +125,38 @@ export default {
 	},
 
 	methods: {
+        httpRequest(params) {
+            const file = params.file
+            this.getBase64(file).then(res => {
+                this.$service.common.uploadImg({content: res}).then(subRes => {
+                    params.onSuccess(subRes)
+                });
+            });
+        },
+        getBase64(file) {
+            return new Promise(function (resolve, reject) {
+                let reader = new FileReader();
+                let imgResult = '';
+                reader.readAsDataURL(file);
+                reader.onload = function () {
+                    imgResult = reader.result;
+                };
+                reader.onerror = function (error) {
+                    reject(error);
+                };
+                reader.onloadend = function () {
+                    resolve(imgResult);
+                };
+            });
+        },
 		uploadImageHandler() {
 			document.getElementById('quill-upload-btn').click();
 		},
 
 		upSuccess(res) {
+            console.log(res)
 			const { index } = this.quill.getSelection();
-			this.quill.insertEmbed(index || 0, 'image', res.data, Quill.sources.USER);
+			this.quill.insertEmbed(index || 0, 'image', res.smallUrl, Quill.sources.USER);
 		},
 
 		setContent(val) {
@@ -225,5 +251,9 @@ export default {
 	.ql-snow .ql-picker.ql-font .ql-picker-label[data-value='monospace']::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value='monospace']::before {
 		content: '等宽字体';
 	}
+
+	.ql-snow .ql-editor img{
+		width: auto !important;
+	}
 }
 </style>

+ 4 - 4
admin-update/src/views/goods/auto-price.vue

@@ -84,10 +84,10 @@ export default {
 		},
 		_getData() {
 			this.$service.goods.getAutoPrice().then(res => {
-				if (this.$util.isEmpty(res.data)) return;
-				res.data.festIdList = res.data.festIdList.map(e => e + '');
+				if (this.$util.isEmpty(res)) return;
+				res.festIdList = res.festIdList.map(e => e + '');
 				Object.keys(this.form).forEach((i, index) => {
-					this.form[i] = res.data[i];
+					this.form[i] = res[i];
 				});
 			});
 		},
@@ -101,7 +101,7 @@ export default {
 			// 	return false;
 			// }
 			this.$service.goods.setAutoPrice(this.form).then(res => {
-				this.$message.error('更新成功!');
+				this.$message('更新成功!');
 			});
 		},
 		submitForm(formName) {

+ 3 - 1
admin-update/src/views/goods/img-store.vue

@@ -166,6 +166,7 @@ export default {
 				picIdList: '',
 				price: 0,
 				name: '',
+                shopImg: [],
 				categoryIdList: []
 			},
 			rules: {}
@@ -204,7 +205,8 @@ export default {
 			this._list();
 		},
 		// 新增图片
-		addImgFn() {
+		addImgFn(res) {
+			this.addForm.shopImg.push(res.shortUrl)
 			this.addImageModal = true;
 		},
 		selChangeDialogFn(status, item) {