mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-06 00:49:48 +08:00
【新增】优惠券增加发放功能,可以将优惠券发放到特定用户内。
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<script type="text/html" template lay-done="layui.data.sendParams(d);">
|
||||
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-CoreCmsPromotion-grantForm" id="LAY-app-CoreCmsPromotion-grantForm">
|
||||
<input type="hidden" name="id" id="id" value="{{d.params.data.model.id}}" />
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="name" class="layui-form-label">优惠券名称</label>
|
||||
<div class="layui-input-inline layui-inline-8">
|
||||
<input class="layui-input" value="{{d.params.data.model.name || '' }}" disabled="disabled" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="sort" class="layui-form-label">用户信息</label>
|
||||
<div class="layui-input-inline layui-inline-5">
|
||||
<input type="number" min="0" max="999999" name="data" lay-verType="tips" lay-verify="required|number" class="layui-input" lay-reqText="请输入数字" />
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">请输入用户手机号码或者用户序列</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item core-hidden">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer">
|
||||
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-CoreCmsPromotion-grantForm-submit" id="LAY-app-CoreCmsPromotion-grantForm-submit" value="确认分发">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var debug = layui.setter.debug;
|
||||
layui.data.sendParams = function (d) {
|
||||
//开启调试情况下获取接口赋值数据
|
||||
if (debug) { console.log(d.params.data); }
|
||||
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'util', 'view'],
|
||||
function () {
|
||||
var $ = layui.$
|
||||
, form = layui.form
|
||||
, admin = layui.admin
|
||||
, laydate = layui.laydate
|
||||
, upload = layui.upload
|
||||
, util = layui.util
|
||||
, view = layui.view
|
||||
, coreHelper = layui.coreHelper;
|
||||
|
||||
//重载form
|
||||
form.render(null, 'LAY-app-CoreCmsPromotion-grantForm');
|
||||
})
|
||||
};
|
||||
</script>
|
||||
@@ -51,7 +51,8 @@
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="LAY-app-CoreCmsPromotion-tableBox-bar">
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="couponlist">券码列表</a>
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="couponlist">券码列表</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="grant">优惠券发放</a>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">设置参数</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
</script>
|
||||
@@ -132,7 +133,7 @@
|
||||
{ field: 'effectiveDays', title: '有效天数', sort: false, width: 80 },
|
||||
{ field: 'effectiveHours', title: '有效小时', sort: false, width: 80 },
|
||||
{ field: 'isEnable', title: '是否开启', width: 80, templet: '#switch_isEnable', sort: false, unresize: true },
|
||||
{ width: 202, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsPromotion-tableBox-bar' }
|
||||
{ width: 282, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsPromotion-tableBox-bar' }
|
||||
]
|
||||
]
|
||||
});
|
||||
@@ -164,6 +165,8 @@
|
||||
doDelete(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
doEdit(obj)
|
||||
} else if (obj.event === 'grant') {
|
||||
doGrant(obj)
|
||||
}
|
||||
});
|
||||
//执行创建操作
|
||||
@@ -268,6 +271,47 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
//执行分发操作
|
||||
function doGrant(obj) {
|
||||
coreHelper.Post("Api/CoreCmsPromotion/GetGrant", { id: obj.data.id }, function (e) {
|
||||
if (e.code === 0) {
|
||||
admin.popup({
|
||||
shadeClose: false,
|
||||
title: '分发优惠券',
|
||||
area: ['600px', '300px'],
|
||||
id: 'LAY-popup-CoreCmsPromotion-edit',
|
||||
success: function (layero, index) {
|
||||
view(this.id).render('promotion/coupon/grant', { data: e.data }).done(function () {
|
||||
//监听提交
|
||||
form.on('submit(LAY-app-CoreCmsPromotion-grantForm-submit)',
|
||||
function (data) {
|
||||
var field = data.field; //获取提交的字段
|
||||
|
||||
if (debug) { console.log(field); } //开启调试返回数据
|
||||
//提交 Ajax 成功后,关闭当前弹层并重载表格
|
||||
coreHelper.Post("Api/CoreCmsPromotion/DoGrant", field, function (e) {
|
||||
console.log(e)
|
||||
if (e.code === 0) {
|
||||
layui.table.reloadData('LAY-app-CoreCmsPromotion-tableBox'); //重载表格
|
||||
layer.close(index); //再执行关闭
|
||||
layer.msg(e.msg);
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
, btn: ['确定', '取消']
|
||||
, yes: function (index, layero) {
|
||||
layero.contents().find("#LAY-app-CoreCmsPromotion-grantForm-submit").click();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
//执行单个删除
|
||||
function doDelete(obj) {
|
||||
layer.confirm('确定删除吗?删除后将无法恢复。', function (index) {
|
||||
|
||||
Reference in New Issue
Block a user