文件
mashangyoujiu/Application/Retail/View/Plug/gift_card.html

313 行
11 KiB
HTML
可执行文件

<!DOCTYPE html>
<html>
<!--[1.8.67]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/goodsList.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/myscroll.css"/>
<style>
* {
margin: 0;
padding: 0;
}
table {
border: 1px solid #f1f1f1;
margin-top: 40px;
}
.layui-table-cell {
height: auto;
}
#exchange {
margin: 0 0 0 20px;
}
.layui-form input {
width: 400px;
}
.layui-textarea {
width: 400px;
height: 200px;
resize: none;
}
.layui-input-inline{
width: 400px!important;
}
.color-box{
display: inline-block;
position: relative;
}
.color-box>input{
width: 20px;
margin-top: 5px;
cursor: pointer;
}
.color-box>input:hover+span{
display: inline-block;
}
.color-box>span:after{
content: '';
position: absolute;
bottom: -4px;
left: 10px;
width: 10px;
height: 10px;
border-radius: 3px;
transform: rotateZ(45deg);
background-color: rgba(0,0,0,0.8);
}
.color-box>span{
position: absolute;
top: -30px;
left: -4px;
padding: 5px 20px;
border-radius: 5px;
background-color: rgba(0,0,0,0.8);
white-space: nowrap;
color: white;
font-size: 14px;
display: none;
}
#edit{
margin-top: 50px;
}
.layui-form-label {
float: left;
display: block;
padding: 9px 15px;
width: 120px;
font-weight: 400;
line-height: 20px;
text-align: right;
}
.goods_edit{
box-sizing: border-box;
padding: 10px 25px 0px 25px;
display: flex;
align-items: center;
}
.goods_table{
box-sizing: border-box;
padding: 0px 25px;
display: flex;
align-items: center;
}
</style>
</head>
<body style="cursor: pointer;">
<div class="goodsBox">
<div class="goods_edit">
<form action="#" class="form-inline PromotionForm">
<if condition="$authArr['gift_addcard'] eq true">
<button type="button" class="layui-btn" id="add">添加礼品卡</button>
</if>
</form>
<if condition="$authArr['gift_propaganda'] eq true">
<button type="button" class="layui-btn" id="propaganda" style="margin-left: 20px;">首页展示设置</button>
</if>
</div>
<script type="text/html" id="switchTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="status" <if condition="$authArr['gift_status'] neq true">disabled </if> date-value="{{d.status}}" data-id="{{d.id}}" value="{{d.status}}"
lay-skin="switch" lay-text="上架|下架" lay-filter="sexDemo" {{ d.status== 1 ? 'checked' : '' }}>
</script>
<div class="goods_table">
<table class="layui-hide" id="test" lay-filter="demo"></table>
<script type="text/html" id="barDemo">
<if condition="$authArr['gift_editGift'] eq true">
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
</if>
<if condition="$authArr['gift_detail'] eq true">
<button class="layui-btn layui-btn-xs" lay-event="detail">详情</button>
</if>
<if condition="$authArr['gift_dels'] eq true">
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
</if>
</script>
</div>
</div>
<form class="layui-form" id="edit" style="display: none;">
<div class="layui-form-item">
<label class="layui-form-label">礼品卡标题</label>
<input id="title" name="title" type="text" class="layui-input" placeholder="请输入标题">
</div>
<div class="layui-form-item">
<label class="layui-form-label">使用须知</label>
<textarea id="notes" name="notes" class="layui-textarea" placeholder="请输入使用须知"></textarea>
</div>
</form>
</body>
<script src="__PUBLIC__/jquery/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
<script>
layui.use(['form', 'layedit', 'laydate', 'table'], function () {
// 日期
var laydate = layui.laydate, form = layui.form;
var table = layui.table;
//展示已知数据
table.render({
elem: '#test',
url: "{:U('gift_Data')}",
method:'post',
cols: [
[{
field: 'index',
title: '序号',
width: 60
}, {
field: 'title',
title: '名称',
align: 'center',
width: 200
}, {
field: 'notes',
title: '使用须知',
align: 'center'
}, {
field: 'time',
title: '有效时间',
align: 'center',
width: 200
}, {
field: 'status',
title: '状态',
templet: '#switchTpl',
align: 'center',
width: 100
}, {
field: 'right',
title: '操作',
align: 'center',
toolbar: '#barDemo',
width: 180
}]
],
page: {
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
}, //是否开启分页
});
$('#Preservation').click(function () {
table.reload('test', {
page: {
curr: 1 //重新从第 1 页开始
}
, where: {
keyword: $('#keyword').val()
}
});
})
form.on('switch(sexDemo)', function (obj) {
console.log($(this).attr('date-value'));
// this.value = this.value == 1 ? 0 : 1;
var that = this;
var status = this.value;
status = status==1?0:1;
var id = $(obj.elem).attr('data-id');
$.ajax({
url: "{:U('gift_status')}",
type: 'POST',
data: {
status: status,
id: id
},
success: function (res) {
that.value = res.value;
if (res.value == 1) {
top.layer.msg(res.msg, {time: 1000});
$(obj.elem).parent().find('div').addClass('layui-form-onswitch');
$(obj.elem).parent().find('em').html('上架');
} else {
top.layer.msg(res.msg, {time: 1500});
$(obj.elem).parent().find('div').removeClass('layui-form-onswitch');
$(obj.elem).parent().find('em').html('下架');
}
}
})
});
table.on('tool(demo)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
var tr = obj.tr;
if (layEvent === 'del') { //删除
layer.confirm('确定删除这个礼品卡吗?', function (index) {
layer.close(index);
//向服务端发送删除指令
$.ajax({
url: "{:U('gift_dels')}",
data: {id: data.id},
type: 'post',
success: function (res) {
if (res.status == 1) {
obj.del();
} else {
top.layer.msg(res.msg, {icon: 4, time: 1000})
}
}
})
});
} else if (layEvent === 'detail') {
location.href = "{:U('gift_detail')}?giftid=" + data.id;
}else if(layEvent === 'edit'){
//编辑
$('#title').val(data.title);
$('#notes').val(data.notes);
layer.open({
type: 1,
content: $("#edit"),
title: "编辑",
area: ['100%', '100%'],
btn:['确定','取消'],
btnAlign: 'c',
btn1:function () {
if(!$('#title').val()){
layer.msg('标题不能为空');
return;
}
$.post("{:U('gift_editGift')}",{
id:data.id,
title:$('#title').val().trim(),
notes:$("#notes").val().trim()
},function (res) {
if(res.status==1){
layer.msg(res.msg,{icon:1,time:800},function () {
layer.closeAll();
obj.update({
title:$('#title').val().trim(),
notes:$('#notes').val().trim()
})
})
}else {
layer.msg(res.msg,{icon:4,time:1500});
}
})
}
})
}
});
$('#add').click(function () {
layer.open({
type: 2,
content: "{:U('gift_addcard')}",
title: "添加礼品卡",
area: ['100%', '100%'],
btnAlign: 'c',
end: function () {
table.reload('test', {});
}
})
});
$("#propaganda").click(function () {
window.location.href = "{:U('gift_propaganda')}";
});
})
</script>
</html>