Commit 4853f810 by lixiaomin

修改赠送优惠券

parent 5ad9460a
......@@ -52,3 +52,12 @@ export function onlineCoupon(id) {
});
}
// 赠送优惠券
export function giveCoupon(data) {
return request({
url: "/coupon-user/give",
method: "post",
data: data,
});
}
......@@ -2,11 +2,11 @@
<div class="app-container">
<el-dialog :visible.sync="giveOpen" width="1000px" append-to-body>
<el-form :model="queryParams" size="small" :inline="true" label-width="68px">
<el-form-item label="手机号" prop="userInfo">
<el-form-item label="手机号" >
<el-input v-model="queryParams.userInfo" placeholder="请输入手机号" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="优惠券">
<el-select v-model="queryParams.state" placeholder="请选择优惠券" clearable @keyup.enter.native="handleQuery">
<el-select v-model="queryParams.couponId" placeholder="请选择优惠券" clearable @keyup.enter.native="handleQuery" filterable>
<el-option
v-for="item in couponList"
:key="item.id"
......@@ -60,7 +60,7 @@
<script>
import {listCustomer} from "@/api/system/customer";
import {listCoupon} from "@/api/coupon/coupon";
import {listCoupon,giveCoupon} from "@/api/coupon/coupon";
export default {
name: "Class",
data() {
......@@ -73,8 +73,8 @@ export default {
giveOpen: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
userInfo: null,
couponId: null,
},
customerList:[],
couponList:[]
......@@ -87,6 +87,10 @@ export default {
/** 查询列表 */
getList() {
this.giveOpen = true;
this.queryParams.userInfo=null;
this.queryParams.couponId=null;
this.customerList=[];
this.total=0;
},
/** 查询优惠券列表 */
getCouponList() {
......@@ -121,54 +125,33 @@ export default {
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
if(this.form.state == "1"){
this.$message.error("停用之后才可以修改");
let userId=null;
let userPhone=null;
if(this.customerList.length>0){
userId=this.customerList[0].id;
userPhone=this.customerList[0].phoneNumber;
}else{
this.$message.error("请查询赠送优惠券的用户!");
return;
}
updateClass(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.giveOpen = false;
this.getList();
});
} else {
addClass(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.giveOpen = false;
this.getList();
});
let couponId=this.queryParams.couponId;
if(couponId==null){
this.$message.error("请选择需要赠送的优惠券!");
return;
}
giveCoupon({"userId":userId,"userPhone":userPhone,"couponId":couponId}).then((response) => {
if(response.code==200){
this.$modal.msgSuccess("赠送成功");
this.giveOpen = false;
}
});
},
}
},
};
</script>
<style lang="scss" >
.dialogClass .spanClass{
margin-left: 10px;
}
.dialogClass .inputCalss{
width:50px;
margin-left: 10px;
}
.dialogClass .el-radio__label {
padding-left: 3px !important;
}
.dialogClass .marginLeft10 {
padding-left: 10px;
}
.dialogClass .marginLeft20 {
padding-left: 20px;
}
.dialogClass .width {
width: 326px;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment