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

297 行
11 KiB
HTML
可执行文件

<!DOCTYPE html>
<html>
<!--[1.2.7]-->
<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: 600px;
height: 300px;
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">
<button type="button" class="layui-btn" id="propaganda" style="margin-right: 20px;">返回</button>
<form action="#" class="form-inline PromotionForm">
<if condition="$authArr['gift_addpropaganda'] eq true">
<button type="button" class="layui-btn" id="add">添加展示图</button>
</if>
</form>
</div>
<script type="text/html" id="switchTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="status" <if condition="$authArr['gift_prostu'] 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_editTile'] eq true">
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑标题</button>
</if>
<if condition="$authArr['gift_prodel'] 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>
</form>
<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_pro_Data')}",
method:'post',
cols: [
[ //标题栏
{
field: 'id',
title: '序号',
width:60
},{
field: 'title',
title: '展示标题',
align:'center'
},{
field: 'imgurl',
title: '图片',
style:'height:100%;',
align:'center',
templet:'<div><img src="{{ d.imgurl}}" style="width: 80px;"></div>'
},{
field: 'addtime',
title: '添加时间',
align:'center'
}, {
field: 'status',
title: '状态',
templet: '#switchTpl',
align:'center'
},
{field: 'right',
title:'操作',
align:'center',
toolbar: '#barDemo'
}]
],
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');
console.log($(this).parents("tr").siblings().find(".layui-table-cell"))
var that =this;
$.ajax({
url: "{:U('gift_prostu')}",
type: 'POST',
data: {
status: status,
id: id
},
success: function (res) {
if (res.status == 1) {
layer.msg('修改成功', {icon: 1, time: 500});
if(status==1){
$(that).parents("tr").siblings().find(".layui-table-cell").find('input').val(2);//
$(that).parents("tr").siblings().find(".layui-table-cell").find('div').removeClass("layui-form-onswitch");
$(that).parents("tr").siblings().find(".layui-table-cell").find('em').html("关闭");
$(that).next().find('em').html('开启');
$(that).next().addClass("layui-form-onswitch");
}
$(that).val(res.value);
} else {
layer.msg('修改失败', {icon: 4, time: 500})
}
}
})
});
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_prodel')}",
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'){
$('#title').val(data.title);
layer.open({
type: 1,
content: $("#edit"),
title: "编辑展示标题",
area: ["650px",'210px'],
btn:['确定','取消'],
btnAlign: 'c',
btn1:function () {
if(!$('#title').val()){
layer.msg('标题不能为空');
return;
}
$.post("{:U('gift_editTile')}",{
id:data.id,
title:$('#title').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()
})
})
}else {
layer.msg(res.msg,{icon:4,time:1500});
}
})
}
})
}
});
$('#add').click(function () {
layer.open({
type: 2,
content: "{:U('gift_addpropaganda')}",
title: "添加展示图",
area: ['95%','90%'],
btnAlign: 'c',
end:function () {
table.reload('test', {
});
}
})
});
$("#propaganda").click(function(){
window.history.go(-1);
});
})
</script>
</body>
</html>