|
|
|
@ -10,14 +10,15 @@ |
|
|
|
<Row :gutter="32"> |
|
|
|
<Col span="24"> |
|
|
|
<FormItem label="广告位置" prop="position"> |
|
|
|
<Select v-model="form.position" style="width:200px"> |
|
|
|
<Input v-if="isHomePopup" value="首页弹窗" disabled /> |
|
|
|
<Select v-else v-model="form.position" style="width:200px"> |
|
|
|
<Option v-for="item in dictData" :value="item.value" :key="item.value">{{ item.title }} |
|
|
|
</Option> |
|
|
|
</Select> |
|
|
|
</FormItem> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
<Row :gutter="32"> |
|
|
|
<Row :gutter="32" v-if="!isHomePopup"> |
|
|
|
<Col span="12"> |
|
|
|
<FormItem label="商家名" prop="value"> |
|
|
|
<Select v-model="form.merchantId" filterable @on-change="checkShop" |
|
|
|
@ -31,16 +32,16 @@ |
|
|
|
<Row :gutter="32"> |
|
|
|
<Col span="24"> |
|
|
|
|
|
|
|
<FormItem label="广告图" prop="adImage"> |
|
|
|
<FormItem :label="isHomePopup ? '弹窗图片' : '广告图'" prop="adImage"> |
|
|
|
<div v-for="(item,index) in adList" :key="index" style="display: flex;line-height: 30px;"> |
|
|
|
<upload-pic-input v-model="item.pic"></upload-pic-input> |
|
|
|
<Icon @click="delOne(index)" type="ios-trash-outline" v-if="adList.length>1" size="30" |
|
|
|
<Icon @click="delOne(index)" type="ios-trash-outline" v-if="!isHomePopup && adList.length>1" size="30" |
|
|
|
color="red" /> |
|
|
|
</div> |
|
|
|
</FormItem> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
<Row :gutter="32" v-if="form.position != 'home_top'"> |
|
|
|
<Row :gutter="32" v-if="!isHomePopup && form.position != 'home_top'"> |
|
|
|
<Col span="24"> |
|
|
|
<FormItem label="广告标题" prop="title"> |
|
|
|
<Input v-model="form.title" placeholder="请输入广告标题" /> |
|
|
|
@ -54,7 +55,7 @@ |
|
|
|
</FormItem> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
<Row :gutter="32" v-if="form.position != 'home_top'"> |
|
|
|
<Row :gutter="32" v-if="!isHomePopup && form.position != 'home_top'"> |
|
|
|
<Col span="24"> |
|
|
|
<FormItem label="广告关联商品" prop="productList1"> |
|
|
|
<div @click="checkGoods" |
|
|
|
@ -65,7 +66,7 @@ |
|
|
|
</FormItem> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
<Row :gutter="32" v-if="form.productList1.productName != ''"> |
|
|
|
<Row :gutter="32" v-if="!isHomePopup && form.productList1.productName != ''"> |
|
|
|
<Col span="12"> |
|
|
|
<FormItem label="商品原价" prop="originalPrice"> |
|
|
|
<Input v-model="form.productList1.originalPrice" placeholder="请输入商品原价" /> |
|
|
|
@ -124,6 +125,14 @@ |
|
|
|
type: String, |
|
|
|
default: "0", |
|
|
|
}, |
|
|
|
scene: { |
|
|
|
type: String, |
|
|
|
default: "homeAd", |
|
|
|
}, |
|
|
|
homeCenterAdCount: { |
|
|
|
type: Number, |
|
|
|
default: 0, |
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -136,28 +145,20 @@ |
|
|
|
roleList: [], |
|
|
|
visible: this.value, |
|
|
|
title: "", |
|
|
|
originalPosition: "", |
|
|
|
data: [], |
|
|
|
dictData: [{ |
|
|
|
title: "首页顶部大广告位", |
|
|
|
value: 'home_top' |
|
|
|
}, { |
|
|
|
title: "首页中位左上", |
|
|
|
value: 'home_center_left_top' |
|
|
|
}, { |
|
|
|
title: "首页中位左下", |
|
|
|
value: 'home_center_left_bottom' |
|
|
|
}, { |
|
|
|
title: "首页中位右上", |
|
|
|
value: 'home_center_right_top' |
|
|
|
}, { |
|
|
|
title: "首页中位右下", |
|
|
|
value: 'home_center_right_bottom' |
|
|
|
title: "首页广告位", |
|
|
|
value: 'home_center' |
|
|
|
}], |
|
|
|
passColor: "", |
|
|
|
submitLoading: false, |
|
|
|
maxHeight: 510, |
|
|
|
form: { |
|
|
|
position: '', |
|
|
|
position: 'home_center', |
|
|
|
sortOrder: "", |
|
|
|
title: '', |
|
|
|
adImage: '', |
|
|
|
@ -196,9 +197,38 @@ |
|
|
|
}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
isHomePopup() { |
|
|
|
return this.scene == "homePopup" || this.form.position == "home_popup"; |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init() { |
|
|
|
|
|
|
|
}, |
|
|
|
getDefaultForm() { |
|
|
|
return { |
|
|
|
position: this.scene == "homePopup" ? "home_popup" : 'home_center', |
|
|
|
sortOrder: "", |
|
|
|
title: this.scene == "homePopup" ? "首页弹窗" : '', |
|
|
|
adImage: '', |
|
|
|
status: 1, |
|
|
|
regionId: JSON.parse(this.getStore("user")).departmentId, |
|
|
|
merchantName: '', |
|
|
|
merchantId: '', |
|
|
|
merchantImage: '', |
|
|
|
linkUrl: this.scene == "homePopup" ? '' : '/package2/group/groupBuySingle?type=shop&item=', |
|
|
|
linkParams: '', |
|
|
|
productList1: { |
|
|
|
adId: "", |
|
|
|
productImage: "", |
|
|
|
productName: "", |
|
|
|
originalPrice: "", |
|
|
|
groupPrice: "", |
|
|
|
groupMembers: "" |
|
|
|
}, |
|
|
|
productList: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
addOne() { |
|
|
|
let data = { |
|
|
|
@ -209,13 +239,40 @@ |
|
|
|
delOne(i) { |
|
|
|
this.adList.splice(i, 1); |
|
|
|
}, |
|
|
|
isHomeCenterPosition(position) { |
|
|
|
return !!position && position != 'home_top' && position != 'home_popup'; |
|
|
|
}, |
|
|
|
submit() { |
|
|
|
this.form.productList = [] |
|
|
|
this.form.productList.push(this.form.productList1) |
|
|
|
this.form.linkUrl = '/package2/group/groupBuySingle?type=shop&item=' |
|
|
|
this.form.adImage = '' |
|
|
|
for (let i = 0; i < this.adList.length; i++) { |
|
|
|
this.form.adImage += this.adList[i].pic + ',' |
|
|
|
this.form.adImage = this.adList |
|
|
|
.map(item => item.pic) |
|
|
|
.filter(item => item != null && String(item).trim() != '') |
|
|
|
.map(item => String(item).trim()) |
|
|
|
.join(',') |
|
|
|
if (this.isHomePopup) { |
|
|
|
this.form.position = 'home_popup' |
|
|
|
this.form.title = this.form.title || '首页弹窗' |
|
|
|
this.form.merchantName = '' |
|
|
|
this.form.merchantId = '' |
|
|
|
this.form.merchantImage = '' |
|
|
|
this.form.linkUrl = '' |
|
|
|
this.form.linkParams = '' |
|
|
|
this.form.productList = [] |
|
|
|
} else { |
|
|
|
if (this.isHomeCenterPosition(this.form.position)) { |
|
|
|
const isNewHomeCenterAd = !this.isHomeCenterPosition(this.originalPosition) |
|
|
|
if (isNewHomeCenterAd && this.homeCenterAdCount >= 10) { |
|
|
|
this.$Message.warning("首页广告位最多添加10个"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.form.position = 'home_center' |
|
|
|
} |
|
|
|
this.form.productList = [] |
|
|
|
this.form.productList.push(this.form.productList1) |
|
|
|
this.form.linkUrl = '/package2/group/groupBuySingle?type=shop&item=' |
|
|
|
} |
|
|
|
if (this.isHomePopup && !this.form.adImage) { |
|
|
|
this.$Message.warning("请上传弹窗图片"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
@ -405,16 +462,26 @@ |
|
|
|
} |
|
|
|
// 清空数据 |
|
|
|
this.$refs.form.resetFields(); |
|
|
|
this.originalPosition = ""; |
|
|
|
this.form = this.getDefaultForm(); |
|
|
|
this.adList = [{ |
|
|
|
pic: '' |
|
|
|
}]; |
|
|
|
if (this.type == "0" || this.type == "1") { |
|
|
|
// 回显数据 |
|
|
|
let data = this.data; |
|
|
|
this.originalPosition = data.position || ""; |
|
|
|
// 回显 |
|
|
|
this.form = data; |
|
|
|
this.form = Object.assign(this.getDefaultForm(), data); |
|
|
|
if (this.isHomeCenterPosition(this.form.position)) { |
|
|
|
this.form.position = 'home_center'; |
|
|
|
} |
|
|
|
|
|
|
|
// 判断字符串中是否包含逗号 |
|
|
|
if (this.form.adImage.indexOf(',') !== -1) { |
|
|
|
const adImage = this.form.adImage || ''; |
|
|
|
if (adImage.indexOf(',') !== -1) { |
|
|
|
// 有逗号:先按逗号分割,再过滤掉空字符串或纯空白字符串,最后映射为 {pic: url} 对象数组 |
|
|
|
this.adList = this.form.adImage |
|
|
|
this.adList = adImage |
|
|
|
.split(',') |
|
|
|
.filter(item => item.trim() !== '') // 过滤掉空项 |
|
|
|
.map(url => ({ |
|
|
|
@ -423,7 +490,7 @@ |
|
|
|
} else { |
|
|
|
// 没有逗号:整个字符串作为一个对象 |
|
|
|
this.adList = [{ |
|
|
|
pic: this.form.adImage.trim() |
|
|
|
pic: adImage.trim() |
|
|
|
}]; |
|
|
|
} |
|
|
|
getShopData(this.searchForm).then((res) => { |
|
|
|
@ -436,7 +503,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
if (data.productList.length > 0) { |
|
|
|
if (data.productList && data.productList.length > 0) { |
|
|
|
this.form.productList1 = { |
|
|
|
adId: data.id, |
|
|
|
productImage: data.productList[0].productImage, |
|
|
|
|