{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-12">
				</div>
			</div>
			<!-- end row -->
			<div class="row">
				<table class="table table-striped m-0">
					<thead>
						<tr>
							<th>支付方式</th>
							<th>平台收取</th>
							<th>状态</th>
						</tr>
					</thead>
					<tbody>
						{foreach $userChannels as $v}
						<tr>
							<td>{$v.title}</td>
							<td>{$v.rate*100}%</td>
							<td>
								<input onchange="change_status(this,{$v.channel_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>
						</tr>
						{/foreach}
					</tbody>
				</table>
			</div>
			<!-- end row -->
		</div>
	</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/user/changeChannelStatus',{
			id:id,
			status:status
		},function(res){
			if(res.code!=0){
				alert(res.msg);
			}
		});
	}
</script>

{/block}
