<div class="opwindow">
	<form name="theform2" id="theform2" method="post" action="{echo \befen\get_url()}">
	<div class="layui-form layui-row">
		<div class="layui-form-item">
			<div class="layui-col layui-col-md4">
				<label>商户名称</label>
				<input type="text" name="merchant_name" id="merchant_name" class="layui-input layui-input-wdith" value="{$value[merchant_name]}" placeholder="请输入商户名称">
			</div>
			<div class="layui-col layui-col-md4">
				<label>商户类型</label>
				<div class="layui-input-inline layui-input-wdith">
					<select name="merchant_type" id="merchant_type" class="layui-select" placeholder="请选择商户类型">
						<option value="">选择商户类型</option>
						<!--{loop model('Merchant')->get_type() $key $val}-->
						<option value="{$val}" <!--{if $val == $value['merchant_type']}-->selected<!--{/if}-->>{$val}</option>
						<!--{/loop}-->
					</select>
				</div>
			</div>
			<div class="layui-col layui-col-md4">
				<label>行业类型</label>
				<div class="layui-input-inline layui-input-wdith">
					<select name="merchant_industry" id="merchant_industry" class="layui-select" placeholder="请选择行业类型">
						<option value="">选择行业类型</option>
						<!--{loop model('Merchant')->get_industry() $key $val}-->
						<option value="{$val}" <!--{if $val == $value['merchant_industry']}-->selected<!--{/if}-->>{$val}</option>
						<!--{/loop}-->
					</select>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md4">
				<label>负责人姓名</label>
				<input type="text" name="per_name" id="per_name" class="layui-input layui-input-wdith" value="{$value[per_name]}" placeholder="请输入负责人姓名">
			</div>
			<div class="layui-col layui-col-md4">
				<label>负责人电话</label>
				<input type="text" name="per_phone" id="per_phone" class="layui-input layui-input-wdith" value="{$value[per_phone]}" placeholder="请输入负责人电话">
			</div>
			<div class="layui-col layui-col-md4">
				<label>负责人邮箱</label>
				<input type="text" name="per_email" id="per_email" class="layui-input layui-input-wdith" value="{$value[per_email]}" placeholder="请输入负责人邮箱">
			</div>
		</div>
		<div class="layui-form-item" id="area-picker">
			<input type="hidden" id="area_code" name="area_code" value="{$value[area_code]}">
			<div class="layui-col layui-col-md4">
				<label>所属省级</label>
				<div class="layui-input-inline layui-input-wdith">
					<select name="province" id="province" class="province-selector" data-value="{$value[province]}"><option value="">--选择省--</option></select>
				</div>
			</div>
			<div class="layui-col layui-col-md4">
				<label>所属市级</label>
				<div class="layui-input-inline layui-input-wdith">
					<select name="city" id="city" class="city-selector" data-value="{$value[city]}"><option value="">--选择市--</option></select>
				</div>
			</div>
			<div class="layui-col layui-col-md4">
				<label>所属区级</label>
				<div class="layui-input-inline layui-input-wdith">
					<select name="county" id="county" class="county-selector" data-value="{$value[county]}"><option value="">--选择区--</option></select>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md4">
				<label>经营地址</label>
				<input type="text" name="address" id="address" class="layui-input layui-input-wdith" value="{$value[address]}" placeholder="请输入经营地址">
			</div>
			<div class="layui-col layui-col-md4">
				<label>支付宝</label>
				<input type="text" name="alipay" id="alipay" class="layui-input layui-input-wdith" value="{$value[alipay]}" placeholder="请输入支付宝账号">
			</div>
			<div class="layui-col layui-col-md4">
				<label>备注信息</label>
				<input type="text" name="remarks" id="remarks" class="layui-input layui-input-wdith" value="{$value[remarks]}">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md4">
				<label>商户信息-开户银行</label>
				<div style="position:relative;">
					<input type="text" name="account_bank" id="account_bank" class="layui-input layui-input-wdith" value="{$value[account_bank]}" placeholder="请输入开户银行">
				</div>
			</div>
			<div class="layui-col layui-col-md4">
				<label>商户信息-账户名称</label>
				<input type="text" name="account_name" id="account_name" class="layui-input layui-input-wdith" value="{$value[account_name]}" placeholder="请输入账号名称">
			</div>
			<div class="layui-col layui-col-md4">
				<label>商户信息-账户卡号</label>
				<input type="text" name="account_number" id="account_number" class="layui-input layui-input-wdith" value="{$value[account_number]}" placeholder="请输入银行卡号">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md2">
				<label>营业执照</label>
				<div class="mch-box">
					<img id="license_copy" class="mch-img" src="">
					<input type="hidden" name="license_copy" class="mch-obj" value="{$value[license_copy]}">
				</div>
			</div>
			<div class="layui-col layui-col-md2">
				<label>身份证人像面</label>
				<div class="mch-box">
					<img rel="mch-img" id="id_card_copy" class="mch-img" src="">
					<input type="hidden" name="id_card_copy" class="mch-obj" value="{$value[id_card_copy]}">
				</div>
			</div>
			<div class="layui-col layui-col-md2">
				<label>身份证国徽面</label>
				<div class="mch-box">
					<img id="id_card_national" class="mch-img" src="">
					<input type="hidden" name="id_card_national" class="mch-obj" value="{$value[id_card_national]}">
				</div>
			</div>
			<div class="layui-col layui-col-md2">
				<label>商户门头照片</label>
				<div class="mch-box">
					<img id="store_door" class="mch-img" src="">
					<input type="hidden" name="store_door" class="mch-obj" value="{$value[store_door]}">
				</div>
			</div>
			<div class="layui-col layui-col-md2">
				<label>店内环境照片</label>
				<div class="mch-box">
					<img id="store_inside" class="mch-img" src="">
					<input type="hidden" name="store_inside" class="mch-obj" value="{$value[store_inside]}">
				</div>
			</div>
			<div class="layui-col layui-col-md2">
				<label>特殊资质证明</label>
				<div class="mch-box">
					<img id="qualifications" class="mch-img" src="">
					<input type="hidden" name="qualifications" class="mch-obj" value="{$value[qualifications]}">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col layui-col-md12" style="text-align:right;">
				<!--{if !in_array($value['check_status'], [0, 2])}-->
				<button type="button" id="cancel2" class="layui-btn">关闭</button>
				<!--{else}-->
				<button type="submit" name="submit2" value="submit2" id="submit2" class="layui-btn">保存</button>
				<button type="submit" name="submit3" value="submit3" id="submit3" class="layui-btn layui-btn-danger">提交审核</button>
				<!--{/if}-->
			</div>
		</div>
	</div>
	</form>
</div>
<link rel="stylesheet" href="//at.alicdn.com/t/font_1614161_8o9u8s6h5fn.css" />
<style>
.layui-btn-download {width:96px;margin-top:5px;}
.mch-box { position:relative;width:96px;height:96px; }
.mch-box .mch-img { width:100%;height:100%;cursor:pointer; }
.mch-box .mch-view {
	position:absolute;
	top:0px;
	left:0px;
	width:100%;
	height:100%;
	background-color:rgba(0, 0, 0, .5);
	padding-top:35px;
	text-align:center;
	display:none;
	box-sizing:border-box;
	-moz-box-sizing:border-box;
	-webkit-box-sizing:border-box;
}
.mch-box .mch-view .iconfont {color:#FFF;font-size:24px;margin:0 3px;}
</style>
<script type="text/javascript">
var merchant_id = "{echo input('param.merchant_id')}";
init_Form();
init_Layarea("#area-picker", {
	change: res => { $('#area_code').val(res.countyCode) }
});
$(".mch-box").each(function(index){
	var mch_box = $(this);
	var mch_img = $(this).find(".mch-img");
	var mch_obj = $(this).find(".mch-obj");
	mch_box.hover(function(){
		if($(this).hasClass("hasImg")) {
			$(this).find(".mch-view").fadeIn(200);
		}
	}, function(){
		$(this).find(".mch-view").hide();
	});
	if(mch_obj.val()) {
		mch_box.addClass("hasImg");
		mch_img.attr("src", mch_obj.val());
	} else {
		mch_box.removeClass("hasImg");
		mch_img.attr("src", "/public/system/add-img.png");
	}
	add_upload(mch_img);
	mch_box.append('<p class="mch-view"><a href="javascript:;" class="iconfont icon-browse" title="预览"></a><a href="javascript:;" class="iconfont icon-ashbin" title="删除"></a></p>');
});
$(".icon-ashbin").click(function(){
	$(this).parent().hide();
	$(this).parent().parent().removeClass("hasImg");
	$(this).parent().parent().find(".mch-obj").val("");
	$(this).parent().parent().find(".mch-img").attr("src", "/public/system/add-img.png");
});
$(".icon-browse").click(function(){
	$(this).parent().hide();
	layer.photos({
		anim: 5,
		photos: {
			"title": "",
			"id": 0,
			"start": 0,
			"data": [
				{
					"alt": "",
					"pid": 0,
					"src": $(this).parent().parent().find(".mch-obj").val(),
					"thumb": $(this).parent().parent().find(".mch-obj").val(),
				}
			]
		}
	});
});
function add_upload(elem) {
	if(!elem) {
		elem = '.item-upload';
	}
	init_upload({
		elem: elem,
		url: "{echo url('merchant/upload', ['merchant_id' => input('param.merchant_id')])}",
		exts: "png|jpg",
		acceptMime: "image/*",
		callback: function(item, data, index, upload){
			//console.log(item);
			//console.log(data);
			if(data.status == 0) {
				showAlert(data.message);
			} else {
				item.parent().addClass("hasImg");
				item.attr("src", data.message);
				item.parent().find(".mch-obj").val(data.message);
			}
		}
	});
}
$('#theform2 input[name=account_bank]').autoComplete({
	url: "{echo url('banks/index')}",
	field: "",
	value: "{$value['account_bank']}",
	name_hidden: "bank_code",
	value_hidden: "{$value['bank_code']}",
});
$("#cancel2").click(function(){
	layer.close(index_window);
});
$("#submit2").click(function(){
	if(false == checkMerchant("#theform2")) {
		return false;
	}
	ajaxSubmit(this, "", "#theform2", function(){});
});
$("#submit3").click(function(){
	if(false == checkMerchant("#theform2")) {
		return false;
	}
	ajaxSubmit(this, "", "#theform2", function(){ reload(); });
});
</script>
