<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  <title><?php echo $shoname; ?></title>
  <link rel="shortcut icon" href="" />
        
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

  <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
 
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->  

<link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
<link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
<script type="text/javascript">
            window.sysinfo = {
            <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
			
            <?php if( !empty($_W['acid'])  ){ ?>'acid': '{$_W['acid']}',<?php } ?>
			
            <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
			
            <?php if( !empty($_W['uid']) ) {  ?>'uid': '{$_W['uid']}',<?php } ?>
			
            'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php  }else{  ?>0<?php } ?>,
			
            'siteroot': '{$_W['siteroot']}',
                    'siteurl': '{$_W['siteurl']}',
                    'attachurl': '{$_W['attachurl']}',
                    'attachurl_local': '{$_W['attachurl_local']}',
                    'attachurl_remote': '{$_W['attachurl_remote']}',
                    'module' : {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
            'cookie' : {'pre': ''},
            'account' : {:json_encode($_W['account'])},
            };
        </script>
		
<script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
<script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
<script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
<script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
<script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
   <link href="/static/css/snailfish.css" rel="stylesheet">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-header layui-elem-quote">当前位置：<span class="line-text">邀新有礼</span></div>
		<div class="layui-card-body" style="padding:15px;">
			<form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
				<div class="layui-form-item">
					<label class="layui-form-label">邀新有礼</label>
					<div class="layui-input-block">
						<label class='radio-inline'>
							<input type='radio' name='is_invite_open_status' value='1' <?php if( isset($data['is_invite_open_status']) && $data['is_invite_open_status'] == 1){ ?>checked<?php } ?> title="开启" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='is_invite_open_status' value='0' <?php if( !isset($data['is_invite_open_status']) || $data['is_invite_open_status'] == 0){ ?>checked<?php } ?> title="关闭" />
						</label>
						<span class="layui-form-mid layui-word-aux"></span>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邀请者奖励</label>
					<div class="layui-input-block">
						<label class='radio-inline'>
							<input type='radio' name='inviter_reward_type' lay-filter="inviter_reward_type" value='1' <?php if( isset($data['inviter_reward_type']) && $data['inviter_reward_type'] == 1){ ?>checked<?php } ?> title="送优惠券" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='inviter_reward_type' lay-filter="inviter_reward_type" value='2' <?php if( isset($data['inviter_reward_type']) && $data['inviter_reward_type'] == 2){ ?>checked<?php } ?> title="送积分" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='inviter_reward_type' lay-filter="inviter_reward_type" value='0' <?php if( !isset($data['inviter_reward_type']) || $data['inviter_reward_type'] == 0){ ?>checked<?php } ?> title="送优惠券和积分" />
						</label>
						<span class="help-block layui-word-aux">邀请成功以后，会员收到的奖励</span>
					</div>
				</div>
				<div class="layui-form-item" id="inviter_reward_type_1"
					<?php if( !isset($data['inviter_reward_type']) || (isset($data['inviter_reward_type']) && $data['inviter_reward_type'] == 1 || $data['inviter_reward_type'] == 0) ){ ?>style="display:block;"<?php }else{ ?>style="display:none;"<?php } ?>>
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<label class="layui-form-label" style="width:100px;">选择优惠券</label>
						<div class="layui-input-block" style="margin-left: 100px;width: 600px;">
							<select name="inviter_reward_couponid">
								<option value="">请选择</option>
								<?php foreach($coupon_list as $k=>$v){ ?>
									<option value="{$v['id']}"
										<?php if($data['inviter_reward_couponid'] == $v['id']){ ?>
											selected="selected"
										<?php } ?>
									>{$v['voucher_title']}({$v['remain_count']})
									</option>
								<?php } ?>
							</select>
							<span class="help-block layui-word-aux">选择赠送的优惠券（优惠券如果限制领取数量，用户邀请成功赠送优惠券的奖励也会受到限制）</span>
						</div>
					</div>
			</div>
			<div class="layui-form-item" id="inviter_reward_type_2"
			<?php if( !isset($data['inviter_reward_type']) || (isset($data['inviter_reward_type']) && $data['inviter_reward_type'] == 2 || $data['inviter_reward_type'] == 0) ){ ?>style="display:block;"<?php }else{ ?>style="display:none;"<?php } ?>
			>
				<label class="layui-form-label"></label>
				<div class="layui-input-block" style="width: 300px;">
					<label class="layui-form-label" style="width:100px;">赠送</label>
					<div class="input-group" style="width: 200px;">
						<input class="form-control" name="inviter_reward_point" type="text" placeholder="" value="{$data['inviter_reward_point']}" maxlength="10">
						<div class="input-group-addon">积分</div>
					</div>
					<span class="help-block" style="padding-left: 100px;color: #999;">设置赠送的积分数量</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">被邀请者奖励</label>
				<div class="layui-input-block">
					<label class='radio-inline'>
						<input type='radio' name='invitees_reward_type' lay-filter="invitees_reward_type" value='1' <?php if( isset($data['invitees_reward_type']) && $data['invitees_reward_type'] == 1){ ?>checked<?php } ?> title="新人注册（授权登录）即奖励" />
					</label>
					<label class='radio-inline'>
						<input type='radio' name='invitees_reward_type' lay-filter="invitees_reward_type" value='2' <?php if( isset($data['invitees_reward_type']) && $data['invitees_reward_type'] == 2){ ?>checked<?php } ?> title="新人注册（授权登录）并且下单奖励" />
					</label>
					<label class='radio-inline'>
						<input type='radio' name='invitees_reward_type' lay-filter="invitees_reward_type" value='0' <?php if( !isset($data['invitees_reward_type']) || $data['invitees_reward_type'] == 0){ ?>checked<?php } ?> title="新人注册（授权登录）和下单分别奖励" />
					</label>
					<span class="help-block layui-word-aux">被邀请成功以后，被邀请人收到的奖励</span>
				</div>
			</div>
			<div class="layui-form-item" id="invitees_reward_type_1"
				<?php if( !isset($data['invitees_reward_type']) || (isset($data['invitees_reward_type']) && $data['invitees_reward_type'] == 1 || $data['invitees_reward_type'] == 0) ){ ?>style="display:block;"<?php }else{ ?>style="display:none;"<?php } ?>
				>
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<h5 style="font-weight:bold;">新人注册（授权登录）</h5>
					<div class="layui-input-block" style="margin: 20px 0 20px 10px;">
						<label class='radio-inline'>
							<input type='radio' name='invitees_register_reward_type' lay-filter="invitees_register_reward_type" value='1' <?php if( isset($data['invitees_register_reward_type']) && $data['invitees_register_reward_type'] == 1){ ?>checked<?php } ?> title="送优惠券" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='invitees_register_reward_type' lay-filter="invitees_register_reward_type" value='2' <?php if( isset($data['invitees_register_reward_type']) && $data['invitees_register_reward_type'] == 2){ ?>checked<?php } ?> title="送积分" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='invitees_register_reward_type' lay-filter="invitees_register_reward_type" value='0' <?php if( !isset($data['invitees_register_reward_type']) || $data['invitees_register_reward_type'] == 0){ ?>checked<?php } ?> title="送优惠券和积分" />
						</label>
					</div>
					<div class="layui-input-block" id="invitees_register_reward_type_1" style="margin-left: 10px;
										 <?php if( !isset($data['invitees_register_reward_type']) || (isset($data['invitees_register_reward_type']) && $data['invitees_register_reward_type'] == 1 || $data['invitees_register_reward_type'] == 0) ){ ?>display:block;<?php }else{ ?>display:none;<?php } ?>
										">
						<label class="layui-form-label" style="width:100px;">选择优惠券</label>
						<div class="layui-input-block" style="margin-left: 100px;width: 600px;">
							<select name="invitees_register_reward_couponid">
								<option value="">请选择</option>
								<?php foreach($coupon_list as $k=>$v){ ?>
									<option value="{$v['id']}"
									<?php if($data['invitees_register_reward_couponid'] == $v['id']){ ?>
									selected="selected"
									<?php } ?>
									>{$v['voucher_title']}({$v['remain_count']})
									</option>
								<?php } ?>
							</select>
							<span class="layui-form-mid layui-word-aux">选择赠送的优惠券（优惠券如果限制领取数量，用户邀请成功赠送优惠券的奖励也会受到限制）</span>
						</div>
					</div>
					<div class="layui-input-block" id="invitees_register_reward_type_2" style="width: 300px;margin-left: 10px;
											<?php if( !isset($data['invitees_register_reward_type']) || (isset($data['invitees_register_reward_type']) && $data['invitees_register_reward_type'] == 2 || $data['invitees_register_reward_type'] == 0) ){ ?>display:block;<?php }else{ ?>display:none;<?php } ?>
										">
						<label class="layui-form-label" style="width:100px;">赠送</label>
						<div class="input-group" style="width: 200px;">
							<input class="form-control" name="invitees_register_reward_point" type="text" placeholder="" value="{$data['invitees_register_reward_point']}" maxlength="10">
							<div class="input-group-addon">积分</div>
						</div>
						<span class="layui-form-mid layui-word-aux" style="padding-left: 100px;">设置赠送的积分数量</span>
					</div>
				</div>
			</div>
			<div class="layui-form-item" id="invitees_reward_type_2"
				<?php if( !isset($data['invitees_reward_type']) || (isset($data['invitees_reward_type']) && $data['invitees_reward_type'] == 2 || $data['invitees_reward_type'] == 0) ){ ?>style="display:block;"<?php }else{ ?>style="display:none;"<?php } ?>
				>
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<h5 style="font-weight:bold;">下单完成</h5>
					<div class="layui-input-block" style="margin: 20px 0 20px 10px;">
						<label class='radio-inline'>
							<input type='radio' name='invitees_order_reward_type' lay-filter="invitees_order_reward_type" value='1' <?php if( isset($data['invitees_order_reward_type']) && $data['invitees_order_reward_type'] == 1){ ?>checked<?php } ?> title="送优惠券" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='invitees_order_reward_type' lay-filter="invitees_order_reward_type" value='2' <?php if( isset($data['invitees_order_reward_type']) && $data['invitees_order_reward_type'] == 2){ ?>checked<?php } ?> title="送积分" />
						</label>
						<label class='radio-inline'>
							<input type='radio' name='invitees_order_reward_type' lay-filter="invitees_order_reward_type" value='0' <?php if( !isset($data['invitees_order_reward_type']) || $data['invitees_order_reward_type'] == 0){ ?>checked<?php } ?> title="送优惠券和积分" />
						</label>
					</div>
					<div class="layui-input-block" id="invitees_order_reward_type_1" style="margin-left: 10px;
												<?php if( !isset($data['invitees_order_reward_type']) || (isset($data['invitees_order_reward_type']) && $data['invitees_order_reward_type'] == 1 || $data['invitees_order_reward_type'] == 0) ){ ?>display:block;<?php }else{ ?>display:none;<?php } ?>
											">
						<label class="layui-form-label" style="width:100px;">选择优惠券</label>
						<div class="layui-input-block" style="margin-left: 100px;width: 600px;">
							<select name="invitees_order_reward_couponid">
								<option value="">请选择</option>
								<?php foreach($coupon_list as $k=>$v){ ?>
									<option value="{$v['id']}"
									<?php if($data['invitees_order_reward_couponid'] == $v['id']){ ?>
									selected="selected"
									<?php } ?>
									>{$v['voucher_title']}({$v['remain_count']})
									</option>
								<?php } ?>
							</select>
							<span class="layui-form-mid layui-word-aux">选择赠送的优惠券（优惠券如果限制领取数量，用户邀请成功赠送优惠券的奖励也会受到限制）</span>
						</div>
					</div>
					<div class="layui-input-block" id="invitees_order_reward_type_2" style="width: 300px;margin-left: 10px;
												<?php if( !isset($data['invitees_order_reward_type']) || (isset($data['invitees_order_reward_type']) && $data['invitees_order_reward_type'] == 2 || $data['invitees_order_reward_type'] == 0) ){ ?>display:block;<?php }else{ ?>display:none;<?php } ?>
											">
						<label class="layui-form-label" style="width:100px;">赠送</label>
						<div class="input-group" style="width: 200px;">
							<input class="form-control" name="invitees_order_reward_point" type="text" placeholder="" value="{$data['invitees_order_reward_point']}" maxlength="10">
							<div class="input-group-addon">积分</div>
						</div>
						<span class="layui-form-mid layui-word-aux" style="padding-left: 100px;">设置赠送的积分数量</span>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">活动奖励</label>
				<div class="layui-input-block">
					<label class='radio-inline'>
						<input type='radio' name='invite_activity_reward_type' value='0' <?php if( !isset($data['invite_activity_reward_type']) || $data['invite_activity_reward_type'] == 0){ ?>checked<?php } ?> title="下单支付完成获得奖励" />
					</label>
					<label class='radio-inline'>
						<input type='radio' name='invite_activity_reward_type' value='1' <?php if( isset($data['invite_activity_reward_type']) && $data['invite_activity_reward_type'] == 1){ ?>checked<?php } ?> title="订单售后期结束获得奖励" />
					</label>
					<span class="layui-form-mid layui-word-aux">此处设置仅对“被邀请者奖励”里面的“登录且下单奖励”和“登录和下单分别奖励”有效，下单支付完成获得奖励指用户订单支付完成即为邀请成功，订单售后期结束获得奖励指用户订单售后期结束以后才为邀请成功。</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">邀请人数</label>
				<div class="layui-input-block">
					<input type="checkbox" name="is_open_invitation_limit" lay-skin="primary" title="开启邀请人数限制" <?php if( isset($data['is_open_invitation_limit']) && $data['is_open_invitation_limit'] == 1){ ?>checked<?php } ?> value="1">
					<div class="input-group" style="width: 200px;">
						<div class="input-group-addon">限制</div>
						<input class="form-control" name="invitation_limit_person" type="text" placeholder="" value="{$data['invitation_limit_person']}" maxlength="10">
						<div class="input-group-addon">人</div>
					</div>
					<span class="layui-form-mid layui-word-aux">设置邀请人员的数量，根据是否获得“被邀请者奖励”判断邀请人数是否达到上限</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">邀新有礼活动顶部背景图</label>
				<div class="layui-input-block">
					{:tpl_form_field_image2('invite_activity_topback_img', $data['invite_activity_topback_img'])}
					<span class='layui-form-mid layui-word-aux'>活动页面顶部背景图</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">活动打开页面顶部背景图</label>
				<div class="layui-input-block">
					{:tpl_form_field_image2('invite_activity_open_topback_img', $data['invite_activity_open_topback_img'])}
					<span class='layui-form-mid layui-word-aux'>此处为邀请人发送活动给被邀请人，被邀请人打开活动顶部背景图</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">活动积分/优惠券使用规则</label>
				<div class="layui-input-block">
					{:tpl_ueditor('invite_activity_use_rules',$data['invite_activity_use_rules'],array('height'=>'300'))}
					<span class='layui-form-mid layui-word-aux'>此处为邀请人发送活动给被邀请人，被邀请人打开以后，最下方的使用说明</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">分享标题</label>
				<div class="layui-input-block">
					<input class="form-control" name="invite_share_title" type="text" placeholder="请输入" value="{$data['invite_share_title']}">
					<span class='layui-form-mid layui-word-aux'></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">分享图片</label>
				<div class="layui-input-block">
					{:tpl_form_field_image2('invite_share_img', $data['invite_share_img'])}
					<span class='layui-form-mid layui-word-aux'>邀新有礼分享图片</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">“邀请下单”分享标题</label>
				<div class="layui-input-block">
					<input class="form-control" name="invite_order_share_title" type="text" placeholder="请输入" value="{$data['invite_order_share_title']}">
					<span class='layui-form-mid layui-word-aux'></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">“邀请下单”分享图片</label>
				<div class="layui-input-block">
					{:tpl_form_field_image2('invite_order_share_img', $data['invite_order_share_img'])}
					<span class='layui-form-mid layui-word-aux'>邀新有礼分享图片</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">活动规则</label>
				<div class="layui-input-block">
					{:tpl_ueditor('invite_activity_rules',$data['invite_activity_rules'],array('height'=>'300'))}
					<span class='layui-form-mid layui-word-aux'></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"> </label>
				<div class="layui-input-block">
					<input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary"  />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				</div>
			</div>
		  </form>
	   </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>

<script>
	layui.config({
		base: '/layuiadmin/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use('index');
</script>

<script>
//由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
var layer = layui.layer;
var $;

var cur_open_div;

layui.use(['jquery', 'layer','form','colorpicker'], function(){ 
  $ = layui.$;
  var form = layui.form;
  var colorpicker = layui.colorpicker;

	form.on('radio(inviter_reward_type)',function(data){
		if(data.value == 1){
			$('#inviter_reward_type_1').show();
			$('#inviter_reward_type_2').hide();
		}else if(data.value == 2){
			$('#inviter_reward_type_1').hide();
			$('#inviter_reward_type_2').show();
		}else{
			$('#inviter_reward_type_1').show();
			$('#inviter_reward_type_2').show();
		}
	});

	form.on('radio(invitees_reward_type)',function(data){
		if(data.value == 1){
			$('#invitees_reward_type_1').show();
			$('#invitees_reward_type_2').hide();
		}else if(data.value == 2){
			$('#invitees_reward_type_1').hide();
			$('#invitees_reward_type_2').show();
		}else{
			$('#invitees_reward_type_1').show();
			$('#invitees_reward_type_2').show();
		}
	});

	form.on('radio(invitees_register_reward_type)',function(data){
		if(data.value == 1){
			$('#invitees_register_reward_type_1').show();
			$('#invitees_register_reward_type_2').hide();
		}else if(data.value == 2){
			$('#invitees_register_reward_type_1').hide();
			$('#invitees_register_reward_type_2').show();
		}else{
			$('#invitees_register_reward_type_1').show();
			$('#invitees_register_reward_type_2').show();
		}
	});

	form.on('radio(invitees_order_reward_type)',function(data){
		if(data.value == 1){
			$('#invitees_order_reward_type_1').show();
			$('#invitees_order_reward_type_2').hide();
		}else if(data.value == 2){
			$('#invitees_order_reward_type_1').hide();
			$('#invitees_order_reward_type_2').show();
		}else{
			$('#invitees_order_reward_type_1').show();
			$('#invitees_order_reward_type_2').show();
		}
	});

  //监听提交
  form.on('submit(formDemo)', function(data){
	
	 $.ajax({
		url: data.form.action,
		type: data.form.method,
		data: data.field,
		dataType:'json',
		success: function (info) {
		  
			if(info.status == 0)
			{
				layer.msg(info.result.message,{icon: 1,time: 2000});
			}else if(info.status == 1){
				var go_url = location.href;
				if( info.result.hasOwnProperty("url") )
				{
					go_url = info.result.url;
				}
				
				layer.msg('操作成功',{time: 1000,
					end:function(){
						location.href = info.result.url;
					}
				}); 
			}
		}
	});
	
    return false;
  });
})



</script>  
</body>
