define({ name:"coupon", template:`
优惠券
订单完成赠送优惠券
会员购买指定商品,获得优惠券分享资格
删除
+ 增加优惠券
两项都填写才能生效;请勿重复选择优惠券
订单支付后,按照勾选发放规则获得对应优惠券分享资格
开启后购买该商品不能使用优惠券
开启后此商品订单可限制使用优惠券数量,注:开启拆单此设置不生效
商品订单可使用优惠券数量,为0不限制,只能设置0或整数
注:开启拆单此设置不生效
选择优惠券
搜索
`, style:` .chooseCoupon .el-input-group__append { background-color: #29BA9C; color: #fff; cursor: pointer; }, #coupon input::-webkit-outer-spin-button, #coupon input::-webkit-inner-spin-button { -webkit-appearance: none; } #coupon input[type="number"] { -moz-appearance: textfield; } .add-coupon{ margin-top: 10px; margin-bottom:10px; color: #29BA9C; border: 2px solid #29BA9C; } .el-dialog-class .el-dialog__header{ padding:25px !important; } .el-dialog-class .el-dialog__body{ padding: 10px 20px !important; } `, props: { form: { default() { return {} } }, http_url:{ type:String, default() { return ""; }, } }, data() { return { keyword:"", couponList:[], giveCouponItems:[],//赠送优惠券 giveId:1, type:"", shareCouponItems:[],//分享优惠券 couponDialog:false } }, mounted(){ this.giveCouponItems = this.form.coupon === null ? [] :this.form.coupon; this.shareCouponItems = this.form.share_coupon === null ? [] :this.form.share_coupon; }, methods: { extraDate(){ }, validate(){ let coupon = JSON.parse(JSON.stringify(this.giveCouponItems)).filter(item => { return item.coupon_name }) let share_coupon= JSON.parse(JSON.stringify(this.shareCouponItems)).filter(item => { return item.coupon_name }) return { is_give:this.form.is_give, send_type:this.form.send_type, send_num:this.form.send_num, shopping_share:this.form.shopping_share, no_use:this.form.no_use, is_use_num:this.form.is_use_num, use_num:this.form.use_num, coupon, share_coupon } }, openCouponDialog(id,type){ if(type == 'give'){ this.type = type this.giveId = id; } if(type == 'share'){ this.shareId = id this.type = type } this.couponDialog = true; }, handleCouponClose(){ this.couponDialog = false; }, //搜索按钮 queryBtn(){ this.$http.post(this.http_url +'coupon.coupon.get-search-coupons-v2&keyword='+this.keyword).then(response => { if(response.data.result==1){ this.$message({ message: '成功', type: 'success' }); this.couponList = response.data.data } else{ this.$message.error(response.data); } }),function(res){ console.log(res); }; }, //选择优惠券 selectCoupon(data) { if(this.type == "give"){ this.giveCouponItems[this.giveId].coupon_name = data.name this.giveCouponItems[this.giveId].coupon_id = data.id } if(this.type == "share"){ this.shareCouponItems[this.shareId].coupon_name = data.name this.shareCouponItems[this.shareId].coupon_id = data.id } this.couponDialog = false; }, prevent(e){ let keynum = window.event ? e.keyCode : e.which; //获取键盘码 if (keynum ==189|| keynum==190||keynum == 109 ||keynum == 110 ) { e.target.value = "" } }, //增加优惠券 addCoupon(type){ if(type == 'give'){ this.giveCouponItems.push( { coupon_id: "", coupon_name:'', coupon_several:'1', } ); } if(type == 'share'){ this.shareCouponItems.push( { coupon_id: "", coupon_name:'', coupon_several:'1' } ); } }, //删除优惠券 removeCoupon(id,type){ if(type == 'give'){ this.giveCouponItems.splice(id,1) } if(type == 'share'){ this.shareCouponItems.splice(id,1) } }, } })