<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<script src="../../../admin/index.js" door type="text/javascript" charset="utf-8"></script>
		<script type="text/html" id="userTpl">
			<li>用户名称：{{d.name || ''}}</li>
			<li>注册时间：{{d.registrationTime || ''}}</li>
			<li>绑定手机号：{{d.phone || ''}}</li>
		</script>
		<script type="text/html" id="recordTpl">
			{{#  if(d.status == 2){ }}
			<li><span>备案类型：个人</span></li>
			<li><span>身份证号码：{{d.archival.idCard || ''}}</span></li>
			<li><span>姓名：{{d.archival.name || ''}}</span></li>
			<li><span>身份证照片：<img layer-src="{{window.hywa.config.href+d.archival.frontImage}}" src="{{window.hywa.config.href+d.archival.frontImage}}" alt=""></span><span><img src="{{window.hywa.config.href+d.archival.contraryImage}}" alt=""></span></li>
			{{# } else if(d.status == 1) { }} 
			 <li><span>备案类型：企业</span></li>
			 <li><span>营业执照号：{{d.archival.socialCreditCode || ''}}</span></li>
			 <li><span>企业名称：{{d.archival.name || ''}}</span></li>
			 <li><span>企业法人：{{d.archival.juridicalPerson || ''}}</span></li>
			 <li>营业执照照片：<img layer-src="{{window.hywa.config.href+d.archival.businessLicense}}" src="{{window.hywa.config.href+d.archival.businessLicense}}" alt=""></li>
			{{#  } }} 
		</script>
	</head>

	<body>
		<div id="detailBox">
			<div class="layui-card">
				<div class="layui-card-header">基本信息</div>
				<div class="layui-card-body">
					<ul id="userInfo">
					</ul>
				</div>
			</div>
			<div class="layui-card">
				<div class="layui-card-header">备案信息</div>
				<div class="layui-card-body">
					<ul id="recordInfo" class="layer-photos-demo">
					</ul>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			layui.config({
				base: "../../../admin/js/layuiPlugins/"
			}).use(["form", 'layer', 'cascade', 'laytpl', 'upload'], function() {
				var form = layui.form,
					$ = layui.$,
					layer = layui.layer,
					laytpl = layui.laytpl,
					cascade = layui.cascade,
					upload = layui.upload;
				var object = {
					id: (JSON.stringify(location.searchObj()) != "{}") ? location.searchObj().id || null : null, //带参传入ID
					currentData: {}, //当前表单数据
					byIdUrl: "userByIdUrl", //根据id查询详情
					formLayFilter: "addForm", //表单容器
					closeModal: function() { //关闭当前窗口
						parent.layer.close(parent.layer.getFrameIndex(window.name));
					}
				};

				//初始化
				object.main = function() {
					var _this = this;
					if (this.id) {
						_this.getCurrent(_this.id); //获取并初始化表单角色信息
					}
					return this;
				};
				//获取当前信息
				object.getCurrent = function(id) {
					var _this = this;
					$.ajax({
						url: _this.byIdUrl,
						data: {
							id: id || _this.id //当前ID
						},
						success: function(res) {
							console.log(res)
							laytpl(userTpl.innerHTML).render(res.data[0].buyer, function(html) {
								$("#userInfo").html(html);
							});
							laytpl(recordTpl.innerHTML).render(res.data[0].archival, function(html) {
								$("#recordInfo").html(html);
								layer.photos({
									photos: '#recordInfo'
								});
							});
						}
					});
					return this;
				};
				object.main();
			});
		</script>
	</body>

</html>
