...
|
...
|
@@ -2,59 +2,21 @@ |
|
|
<div>
|
|
|
<table class="banner-table">
|
|
|
<tbody>
|
|
|
<tr v-for="(i,index) in value_" :key="i.imgId">
|
|
|
<tr v-for="(i,index) in value_" :key="i">
|
|
|
<th>{{+index + 1}}</th>
|
|
|
|
|
|
<th>
|
|
|
<file-upload></file-upload>
|
|
|
<file-upload
|
|
|
:default-file="i.src | removeImageParams"
|
|
|
:id="index"
|
|
|
@success="onUploadSuccess"
|
|
|
@remove="onUploadRemove"
|
|
|
>
|
|
|
</file-upload>
|
|
|
</th>
|
|
|
|
|
|
<th>
|
|
|
<Form>
|
|
|
<FormItem>
|
|
|
<Select v-model="i.url.action">
|
|
|
<Option value="go.h5">H5网页</Option>
|
|
|
<Option value="go.ufo">商品列表页</Option>
|
|
|
<Option value="go.pool">商品池</Option>
|
|
|
</Select>
|
|
|
</FormItem>
|
|
|
|
|
|
<template v-if="i.url.action === 'go.h5'">
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.title" placeholder="参数"/>
|
|
|
|
|
|
</FormItem>
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.url" placeholder="参数"/>
|
|
|
</FormItem>
|
|
|
</template>
|
|
|
|
|
|
<template v-if="i.url.action === 'go.ufo'">
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.productListTitle" placeholder="参数"/>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.productPool" placeholder="参数"/>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.url" placeholder="参数"/>
|
|
|
</FormItem>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-if="i.url.action === 'go.pool'">
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.productId" placeholder="参数"/>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem>
|
|
|
<Input v-model="i.url.url" placeholder="参数"/>
|
|
|
</FormItem>
|
|
|
</template>
|
|
|
|
|
|
</Form>
|
|
|
<banner-params v-model="i.url"></banner-params>
|
|
|
</th>
|
|
|
|
|
|
<th>
|
...
|
...
|
@@ -73,29 +35,52 @@ |
|
|
<script>
|
|
|
|
|
|
import fileUpload from './drag-file-upload';
|
|
|
import bannerParams from './banner-params';
|
|
|
import util from '@/libs/util';
|
|
|
|
|
|
export default {
|
|
|
props: {
|
|
|
value: {
|
|
|
type: Object,
|
|
|
default: {}
|
|
|
props: ['value'],
|
|
|
filters: {
|
|
|
removeImageParams(url) {
|
|
|
if (!url) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
return url.split('?')[0]
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
value_: this.handleData(this.value)
|
|
|
value_: this.handleData(util.clone(this.value))
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
onDeleteBtnClick(i, index) {
|
|
|
this.value_.splice(index, 1);
|
|
|
this.$emit('input', this.value_);
|
|
|
this.$emit('input', this.handleSaveData(this.value_));
|
|
|
},
|
|
|
onAddBtnClick() {
|
|
|
this.value_.push({
|
|
|
|
|
|
alt: "",
|
|
|
bgColor: "",
|
|
|
imgId: "0",
|
|
|
isFocusRec: "0",
|
|
|
src: "",
|
|
|
url: {
|
|
|
action: 'go.h5',
|
|
|
url: ''
|
|
|
}
|
|
|
});
|
|
|
this.$emit('input', this.value_);
|
|
|
|
|
|
this.$emit('input', this.handleSaveData(this.value_));
|
|
|
},
|
|
|
onUploadSuccess(id, {url}) {
|
|
|
this.value_[id].src = url + '?imageView2/{mode}/w/{width}/h/{height}';
|
|
|
this.$emit('input', this.handleSaveData(this.value_));
|
|
|
},
|
|
|
onUploadRemove(id) {
|
|
|
this.value_[id].src = '';
|
|
|
this.$emit('input', this.handleSaveData(this.value_));
|
|
|
},
|
|
|
handleData(m) {
|
|
|
let keys = Object.keys(m);
|
...
|
...
|
@@ -119,34 +104,46 @@ export default { |
|
|
|
|
|
for (const i of keys) {
|
|
|
let a = m[i];
|
|
|
let url = new URL(a.url.url);
|
|
|
let params = new URLSearchParams(url.search);
|
|
|
|
|
|
a.url.url = `${url.origin}${url.pathname}`
|
|
|
|
|
|
if (a.url.action === 'go.ufo' && params.get('pagename') === 'productDetail') {
|
|
|
if (a.url.action === 'go.ufo' && util.getUrlQueryString(a.url.url, 'pagename') === 'productDetail') {
|
|
|
a.url.action = 'go.pool'
|
|
|
}
|
|
|
|
|
|
for (let p of params) {
|
|
|
a.url[p[0]] = p[1]
|
|
|
}
|
|
|
|
|
|
result.push(a)
|
|
|
}
|
|
|
|
|
|
console.log(result);
|
|
|
return result;
|
|
|
},
|
|
|
handleSaveData(m) {
|
|
|
let temp = util.clone(m)
|
|
|
|
|
|
for (const i of Object.keys(temp)) {
|
|
|
if (temp[i].url.action === 'go.pool') {
|
|
|
temp[i].url.action = 'go.ufo';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// array to object
|
|
|
const result = {}
|
|
|
|
|
|
for (const i of Object.keys(temp)) {
|
|
|
result[i] = temp[i]
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
getValue(){
|
|
|
return this.handleSaveData(this.value_);
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
value(newVal) {
|
|
|
this.value_ = newVal
|
|
|
this.value_ = this.handleData(util.clone(newVal));
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
fileUpload
|
|
|
fileUpload,
|
|
|
bannerParams
|
|
|
}
|
|
|
}
|
|
|
</script>
|
...
|
...
|
|