|
@@ -1,5 +1,22 @@
|
|
|
<template>
|
|
|
<q-page padding>
|
|
|
+ <q-dialog v-model="imageUploadBox">
|
|
|
+ <q-card>
|
|
|
+ <q-card-section style="width: 300px" class="row items-center q-pb-none">
|
|
|
+ <div class="text-h6">图片上传</div>
|
|
|
+ <q-space />
|
|
|
+ <q-btn icon="close" flat round dense v-close-popup />
|
|
|
+ </q-card-section>
|
|
|
+
|
|
|
+ <q-card-section>
|
|
|
+ <upload-image
|
|
|
+ :processImage="customProcessImage"
|
|
|
+ :removeImage="customRemoveImage"
|
|
|
+ @update-urls="customHandleUpdatedUrls"
|
|
|
+ ></upload-image>
|
|
|
+ </q-card-section>
|
|
|
+ </q-card>
|
|
|
+ </q-dialog>
|
|
|
<q-btn
|
|
|
round
|
|
|
title="增加一张"
|
|
@@ -28,6 +45,12 @@
|
|
|
v-for="index in numberofslides"
|
|
|
:key="index"
|
|
|
>
|
|
|
+ <q-btn
|
|
|
+ color="deep-orange"
|
|
|
+ glossy
|
|
|
+ label="上传滚动图"
|
|
|
+ @click="uploadImage(index)"
|
|
|
+ />
|
|
|
<q-input
|
|
|
label="滚动图URL"
|
|
|
v-model="sliders[index - 1]['imageUrl']"
|
|
@@ -61,7 +84,11 @@
|
|
|
<script>
|
|
|
import { api } from "boot/axios";
|
|
|
import { useQuasar } from "quasar";
|
|
|
+import UploadImage from "v-upload-image";
|
|
|
export default {
|
|
|
+ components: {
|
|
|
+ "upload-image": UploadImage,
|
|
|
+ },
|
|
|
name: "HomeSlideImagePage",
|
|
|
setup() {
|
|
|
const $q = useQuasar();
|
|
@@ -87,6 +114,8 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
numberofslides: 3,
|
|
|
+ currentSelectedIndex: 0,
|
|
|
+ imageUploadBox: false,
|
|
|
sliders: [
|
|
|
{ imageUrl: "", title: "", subTitle: "", linkToBlog: "" },
|
|
|
{ imageUrl: "", title: "", subTitle: "", linkToBlog: "" },
|
|
@@ -98,6 +127,27 @@ export default {
|
|
|
this.loadExistingHomeSliders();
|
|
|
},
|
|
|
methods: {
|
|
|
+ async customProcessImage(image) {
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append("expectedType", "blogImage");
|
|
|
+ formData.append("imageFile", image);
|
|
|
+ api
|
|
|
+ .post("/api/v1/image/upload", formData)
|
|
|
+ .then((response) => {
|
|
|
+ this.showNotifyMessageSucceed("成功插入图片");
|
|
|
+ this.imageUploadBox = false;
|
|
|
+ this.sliders[this.currentSelectedIndex - 1]["imageUrl"] =
|
|
|
+ response.data.data;
|
|
|
+ return { imageId: "somefake", imageUrl: response.data.data };
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ this.showNotifyMessageFail(e.toString());
|
|
|
+ });
|
|
|
+ },
|
|
|
+ uploadImage(index) {
|
|
|
+ this.imageUploadBox = true;
|
|
|
+ this.currentSelectedIndex = index;
|
|
|
+ },
|
|
|
loadExistingHomeSliders() {
|
|
|
api
|
|
|
.get("/api/v1/pagecontent/homesliders")
|