2023-01-29 10:26:52 +08:00

85 lines
3.1 KiB
HTML

{extend name="public/base" /}
{block name="body"}
<style>
.clinhei{width:100%;height:20px;}
</style>
<div class="main-box-body clearfix">
<a href="{:url('coupon/add')}"><button type="button" class="btn btn-primary">添加优惠券</button></a>
<table class="table">
<thead>
<tr>
<th style="text-align: center;">ID</th>
<th style="text-align: center;">优惠券金额</th>
<th style="text-align: center;">优惠券有效期</th>
<th style="text-align: center;">下载领卷码</th>
<th style="text-align: center;">创建时间</th>
<th style="text-align: center;">操作</th>
</tr>
</thead>
<tbody>
{volist name="data" id="v"}
<tr style="background: #fff;box-shadow: 2px 2px 2px#A0A4A7;">
<td style="text-align: center;font-weight:bold;">{$v.id}</td>
<td style="color: red;text-align: center;">{$v.money}</td>
<td style="color:#002945;text-align: center;">{$v.period} 天</td>
<td>
<a href="{$v.code}" download="{$v.id}-{$v.money}-{$v.period}.png" style="text-decoration: none">
<button type="button" class="btn btn-primary" style="display: block;margin:0 auto;">保存到本地</button>
</a>
</td>
<td style="color: seagreen;text-align: center;">{$v.addtime|date='Y-m-d H:i:s',###}</td>
<td style="text-align: center;"><button type="button" class="btn btn-danger" style="display: block;margin:0 auto;" onclick="del('{$v.id}')">删除</button></td>
</tr>
{/volist}
</tbody>
</table>
</div>
{/block}
{block name="script"}
<script>
function del(id){
swal({
title: '删除此优惠券?',
text: "删除此优惠券后此领卷码将失效",
type: 'warning',
buttons:{
confirm: {
text : '确认',
className : 'btn btn-success'
},
cancel: {
text : '关闭',
visible: true,
className: 'btn btn-danger'
}
}
}).then((Delete) => {
if (Delete) {
$.ajax({
type: "POST",
url:"{:url('coupon/del')}",
data: {id:id},
dataType:"json",
success: function(data) {
if(data.status==1){
swal('删除成功',"", {icon : "success",buttons:{confirm:{className : 'btn btn-success'}},});
setTimeout(function(){ window.location = ""; }, 1500);
}else{
swal('错误',data.reg, {icon : "error",buttons:{confirm:{className : 'btn btn-danger'}},});
}
}
});
} else {
//关闭执行
swal.close();
}
});
}
</script>
{/block}