241 行
8.1 KiB
HTML
可执行文件
241 行
8.1 KiB
HTML
可执行文件
<!DOCTYPE html>
|
|
<html>
|
|
<!--[1.8.68]-->
|
|
<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-switch {
|
|
position: relative;
|
|
height: 28px;
|
|
line-height: 28px;
|
|
width: 56px;
|
|
}
|
|
.layui-form-onswitch i {
|
|
left: 40px;
|
|
}
|
|
.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['score_add'] eq true">
|
|
<button type="button" class="layui-btn" id="add">添加商品</button>
|
|
</if>
|
|
</form>
|
|
<if condition="$authArr['score_exchange'] eq true">
|
|
<button type="button" class="layui-btn" id="exchange">兑换记录</button>
|
|
</if>
|
|
<if condition="$authArr['score_banner'] eq true">
|
|
<button type="button" class="layui-btn" id="banner">首页轮播管理</button>
|
|
</if>
|
|
</div>
|
|
<script type="text/html" id="switchTpl">
|
|
<input type="checkbox" name="status" <if condition="$authArr['score_upstatus'] 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['score_add'] eq true">
|
|
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
|
|
</if>
|
|
<if condition="$authArr['score_dels'] eq true">
|
|
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
|
|
</if>
|
|
</script>
|
|
</div>
|
|
</div>
|
|
<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('score_getData')}",
|
|
method:'post',
|
|
cols: [
|
|
[{
|
|
field: 'index',
|
|
title: '序号',
|
|
width: 60
|
|
}, {
|
|
field: 'name',
|
|
title: '商品名',
|
|
align: 'center'
|
|
}, {
|
|
field: 'image',
|
|
title: '商品图片',
|
|
style: 'height:100%;',
|
|
align: 'center',
|
|
templet: '<div><img src="{{ d.image}}" style="width: 80px;"></div>'
|
|
}, {
|
|
field: 'num',
|
|
title: '数量',
|
|
align: 'center'
|
|
}, {
|
|
field: 'integral',
|
|
title: '所需积分',
|
|
align: 'center'
|
|
}, {
|
|
field: 'price',
|
|
title: '所需金额/元',
|
|
align: 'center'
|
|
}, {
|
|
field: 'time',
|
|
title: '添加时间',
|
|
align: 'center'
|
|
}, {
|
|
field: 'information',
|
|
title: '商品描述',
|
|
align: 'center'
|
|
},{
|
|
field: 'notice',
|
|
title: '兑换须知',
|
|
align: 'center'
|
|
}, {
|
|
field: 'status',
|
|
title: '状态',
|
|
templet: '#switchTpl',
|
|
align: 'center',
|
|
width: 120
|
|
}, {
|
|
field: 'right',
|
|
title: '操作',
|
|
align: 'center',
|
|
toolbar: '#barDemo',
|
|
width: 140
|
|
}]
|
|
],
|
|
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 ? 2 : 1;
|
|
var status = this.value;
|
|
var id = $(obj.elem).attr('data-id');
|
|
$.ajax({
|
|
url: "{:U('score_upstatus')}",
|
|
type: 'POST',
|
|
data: {
|
|
status: status,
|
|
id: id
|
|
},
|
|
success: function (res) {
|
|
if (res.status == 1) {
|
|
layer.msg('修改成功', {icon: 1, time: 500})
|
|
} else {
|
|
layer.msg('修改失败', {icon: 4, time: 500})
|
|
}
|
|
}
|
|
})
|
|
});
|
|
table.on('tool(demo)', function (obj) {
|
|
var data = obj.data;
|
|
var layEvent = obj.event;
|
|
|
|
if (layEvent === 'del') { //删除
|
|
layer.confirm('确定删除这个商品吗?', function (index) {
|
|
layer.close(index);
|
|
//向服务端发送删除指令
|
|
$.ajax({
|
|
url: "{:U('score_dels')}",
|
|
data: {id: data.id},
|
|
type: 'post',
|
|
success: function (res) {
|
|
if (res.status == 1) {
|
|
obj.del();
|
|
} else {
|
|
layer.msg(res.msg, {icon: 4, time: 1000})
|
|
}
|
|
}
|
|
})
|
|
});
|
|
} else if (layEvent === 'edit') { //编辑
|
|
layer.open({
|
|
type: 2,
|
|
content: "{:U('score_add')}?id=" + data.id,
|
|
title: "编辑商品",
|
|
area: ["100%", '100%'],
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
table.reload('test', {});
|
|
}
|
|
})
|
|
}
|
|
});
|
|
$('#add').click(function () {
|
|
layer.open({
|
|
type: 2,
|
|
content: "{:U('score_add')}",
|
|
title: "添加商品",
|
|
area: ["100%", "100%"],
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
table.reload('test', {});
|
|
}
|
|
})
|
|
|
|
});
|
|
$("#exchange").click(function () {
|
|
window.location.href = "{:U('score_exchange')}";
|
|
});
|
|
$("#banner").click(function () {
|
|
window.location.href = "{:U('score_banner')}";
|
|
});
|
|
})
|
|
</script>
|
|
</body>
|
|
</html>
|