/**
* 空的验证组件,后续如果增加业务,则更改组件
*/
var couponListHtml = '
';
Vue.component("coupon-list", {
template: couponListHtml,
data: function () {
return {
data: this.$parent.data,
goodsSources: [
{
text: "默认",
value: "default",
src: couponResourcePath + "/coupon/img/goods.png",
selectedSrc: couponResourcePath + "/coupon/img/goods_1.png"
},
{
text : "手动选择",
value : "diy",
src: couponResourcePath + "/coupon/img/manual.png",
selectedSrc: couponResourcePath + "/coupon/img/manual_1.png"
}
],
isLoad: false,
isShow: false,
couponCount: [6, 12, 18, 24, 30],
}
},
created:function() {
if(!this.$parent.data.verify) this.$parent.data.verify = [];
this.$parent.data.verify.push(this.verify);//加载验证方法
},
methods: {
shopNum: function(){
if (this.$parent.data.couponCount > 50){
layer.msg("优惠券数量最多为50");
this.$parent.data.couponCount = 50;
}
if (this.$parent.data.couponCount.length > 0 && this.$parent.data.couponCount < 1) {
layer.msg("优惠券数量不能小于0");
this.$parent.data.couponCount = 1;
}
},
verify : function () {
var res = { code : true, message : "" };
/* if(this.data.couponCount.length===0) {
res.code = false;
res.message = "请输入优惠券数量";
}
if (this.data.goodsCount < 0) {
res.code = false;
res.message = "优惠券数量不能小于0";
}
if(this.data.couponCount > 50){
res.code = false;
res.message = "优惠券数量最多为50";
} */
return res;
},
addCoupon: function(){
var self = this;
self.couponSelect(function (res) {
self.$parent.data.couponIds = [];
for (var i=0; i选择风格';
couponHtml += '';
couponHtml += '';
Vue.component("coupon-style", {
template : couponHtml,
data : function(){
return {
data : this.$parent.data,
};
},
methods:{
selectCouponStyle: function() {
var self = this;
layer.open({
type: 1,
title: '风格选择',
area:['930px','630px'],
btn: ['确定', '返回'],
content: $(".draggable-element[data-index='" + self.data.index + "'] .edit-attribute .coupon-list-style").html(),
success: function(layero, index) {
$(".layui-layer-content input[name='style']").val(self.data.style);
$(".layui-layer-content input[name='style_name']").val(self.data.styleName);
$("body").on("click", ".layui-layer-content .style-list-con-coupon .style-li-coupon", function () {
$(this).addClass("selected ns-border-color").siblings().removeClass("selected ns-border-color");
$(".layui-layer-content input[name='style']").val($(this).index() + 1);
$(".layui-layer-content input[name='style_name']").val($(this).find("span").text());
});
},
yes: function (index, layero) {
self.data.style = $(".layui-layer-content input[name='style']").val();
self.data.styleName = $(".layui-layer-content input[name='style_name']").val();
layer.closeAll()
}
});
},
}
});
// 优惠券领取状态开关
var moreBtnHtml = '';
Vue.component("coupon-status", {
props: {
data: {
type: Object,
default: function () {
return {
field: "status",
label: "优惠券领取状态"
};
}
}
},
created: function () {
if (this.data.label == undefined) this.data.label = "启用";
if (this.data.field == undefined) this.data.field = "status";
},
watch: {
data: function (val, oldVal) {
if (val.field == undefined) val.field = oldVal.field;
if (val.label == undefined) val.label = "启用";
},
},
template: moreBtnHtml,
data: function () {
return {
list: [
{label: "开启", value: 1},
{label: "关闭", value: 0},
],
parent: this.$parent.data,
};
}
});