{extend name="base"}

{block name="content"}
<div class="row">
	<div class="col-sm-12">
		<div class="card-box">
			<div class="row">
				<div class="col-sm-6">
					<form class="form-inline" role="form" action="" method="get">
						<div class="form-group">
							<select name="status" class="form-control">
								<option value="" {if $Think.get.status==''}selected{/if}>全部状态</option>
								<option value="1" {if $Think.get.status=='1'}selected{/if}>已处理</option>
								<option value="2" {if $Think.get.status=='2'}selected{/if}>未处理</option>
								<option value="-1" {if $Think.get.status=='-1'}selected{/if}>已撤销</option>
							</select>
						</div>
						<div class="form-group">
							<select name="type" class="form-control">
								<option value="">全部类型</option>
								<option value="无效卡密" {if $Think.get.type=='无效卡密'}selected{/if}>无效卡密</option>
								<option value="虚假商品" {if $Think.get.type=='虚假商品'}selected{/if}>虚假商品</option>
								<option value="非法商品" {if $Think.get.type=='非法商品'}selected{/if}>非法商品</option>
								<option value="侵权商品" {if $Think.get.type=='侵权商品'}selected{/if}>侵权商品</option>
								<option value="不能购买" {if $Think.get.type=='不能购买'}selected{/if}>不能购买</option>
								<option value="恐怖色情" {if $Think.get.type=='恐怖色情'}selected{/if}>恐怖色情</option>
								<option value="其他投诉" {if $Think.get.type=='其他投诉'}selected{/if}>其他投诉</option>
							</select>
						</div>
						<button type="submit" class="btn btn-purple waves-effect waves-light"><i class="fa fa-search"></i> 搜索</button>
					</form>
				</div>
			</div>
			<!-- end row -->
			<div class="row">
				<table class="table table-striped m-0">
					<thead>
						<tr>
							<th>投诉订单</th>
							<th>投诉类型</th>
							<th>投诉说明</th>
							<th>QQ</th>
							<th>手机</th>
							<th>投诉处理状态</th>
							<th>投诉时间</th>
							 <th>操作</th>
						</tr>
					</thead>
					<tbody>
						{foreach $complaints as $v}
						<tr>
							<td>{$v.trade_no}</td>
							<td>{$v.type}</td>
							<td>{$v.desc}</td>
							<td>{$v.qq}</td>
							<td>{$v.mobile}</td>
							<td>
								{if $v.status==0}处理中{elseif $v.status==1}已处理{elseif $v.status == -1}已撤销{/if}
								<!--<input onchange="change_status(this,{$v.id})" type="checkbox" data-plugin="switchery" data-color="#2bb309" data-size="small" data-switchery="true" style="display: none;" {if $v.status==1}checked{/if}>-->
							</td>
							<td>{$v.create_at|date="Y-m-d H:i:s",###}</td>
							<td>
							<!--<a href="javascript:void(0);" onclick="del(this,{$v.id})">删除</a>-->
								<a href="javascript:void(0);" onclick="detail(this,'{$v.id}')">沟通处理</a>
							</td>
						</tr>
						{/foreach}
					</tbody>
				</table>
			</div>
			<!-- end row -->
		</div>
		{$page}
	</div>
</div>
{/block}

{block name="appendJS"}

<script>
	function change_status(obj,id)
	{
		var status=$(obj).prop('checked');
		if(status){
			status=1;
		}else{
			status=0;
		}
		$.post('/merchant/complaint/changeStatus',{
			id:id,
			status:status
		},function(res){
			if(res.code!=0){
				alert(res.msg);
			}
		});
	}

	function detail(obj,id){
	    layer.open({
            type: 2,
            content: "{:url('Merchant/Complaint/detail')}?id=" + id,
			area:['80%','80%']
		})
	}

	function del(obj,id)
	{
		swal({
			title: "确定删除吗？",
			text: "你将无法恢复该操作！",
			type: "warning",
			showCancelButton: true,
			confirmButtonColor: "#DD6B55",
			confirmButtonText: "确定删除！",
			closeOnConfirm: false
		},
		function(){
			$.post('/merchant/complaint/del',{
				id:id
			},function(res){
				if(res.code!=0){
					swal('删除失败', res.msg, "error");
				}else{
					swal('删除成功', '', "success");
					setTimeout(function(){
						location.reload();
					},200);
				}
			});
		});
	}
</script>

{/block}
