{include file="public/heard"}
    <body>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                    <div class="layui-card-body ">
                            <table class="layui-table" id="mlist" lay-filter="mlist">
                                <thead>
                                    <tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
		<script type="text/html" id="status">
		 <input type="checkbox" name="start" value="{{d.id}}" da-rate="{{d.urate}}" da-type="{{d.type}}" lay-skin="switch" lay-text="已启用|已停止" lay-filter="start" {{ d.start == 1 ? 'checked' : '' }}>
		</script>
        <script>
	layui.use(['table','form','laydate'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery,laydate = layui.laydate;
        tableIn = table.render({
            elem: '#mlist',
            url: "{$url}",
            method: 'post',
			page:true,
			totalRow:true,
            cols: [[
			    {type: 'checkbox',width:40,minWidth:30},
				{field:'type',title:"通道代码", align: 'center', sort: true},
			    {field:'name',title: '卡类',align: 'center'},
                {field:'payrate', title: '默认费率' ,align: 'center'} ,
				{field:'urate',align: 'center',title:'当前费率',edit:"text"},
				{field: 'start',align: 'center', title: '账户状态',toolbar: '#status',},
            ]],
			limit:20,
			limits:[20,50,60]
        });		
		table.on('edit(mlist)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = "{$uid}",str = obj.value;
            $.post('{:U("simple/member/memberFl")}',{'id':id,'rate':str,'type':obj.data.type,'start':obj.data.start},function (res) {
                layer.close(loading);
				if(res.code==1){
				  tableIn.reload();
				}else{
					layer.msg(res.msg,{time:1000,icon:2});
					return false;
				}
            })		  
		});
		form.on('switch(start)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = "{$uid}";
			var urate=$(this).attr('da-rate'),type=$(this).attr('da-type');
            var authopen = obj.elem.checked===true?1:0;
			var str="启用";
			 if(authopen==1){
			    str="停用";
			 }
				$.post('{:U("simple/member/memberFl")}',{'id':id,'rate':urate,'type':type,'start':authopen},function (res) {
					layer.close(loading);
					if (res.code==1) {
						tableIn.reload();
					}else{
						layer.msg(res.msg,{time:1000,icon:2});
						return false;
					}
				})
        });
		
		 //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });
    </script>
    </body>

</html>