<link type="text/css" rel="stylesheet" href="{url:#css/ucenter.css}" />
{echo:JS::import('form');}
{echo:JS::import('date');}
{echo:JS::import('dialog?skin=tinysimple');}
<div class="container list blank">
	<div class="row-5">
		<div class="col-1">
		{widget:name=sub_navs action=ucsidebar sidebar=$sidebar act=$actionId}
		</div>
		<div class="col-4">
			<h1 class="title"><span>基本资料：</span></h1>
			{if:isset($msg)}
			<div class="alert alert-fail">{$msg[1]}</div>
			{elseif:isset($validator)}
			<div class="alert alter-file">{$validator['msg']}</div>
			{/if}
			<div class="row">
				<div class="col-3">
				<form id="info-form"  action="{url:/ucenter/info_save}" method="post">
				<ul class="tiny-form">
					<li class="line caption">
						<label class="caption">会员帐号：</label><input type="text" pattern="email" name="email" class="field disabled" {if:Validator::match('\d+@no.com',$info['email'])}{else:}disabled="disabled" value="{$email}"{/if}  alt="邮箱格式错误">
					</li>
					<li class="line caption">
						<label class="caption">会员级别：</label><input type="text" class="field disabled" name="" disabled="disabled" value="{$gname|'默认分组'}">
					</li>
					<li class="line caption">
						<label class="caption">昵称：</label><input type="text" class="field" pattern="required" name="name" maxlen="20" value="{$name}" alt="长度不得超过20个字">
					</li>
					<li class="line caption">
						<label class="caption">真实姓名：</label><input type="text" pattern="required" name="real_name" class="field" maxlen="20" value="{$real_name}" alt="长度不得超过20个字">
					</li>

					<li class="line caption">
						<label class="caption">生日：</label><input name="birthday" type="text" onfocus="WdatePicker()" class="Wdate field"  value="{$birthday}" >
					</li>
					<li class="line caption">
						<label class="caption">手机号码：</label>{if:Validator::mobi($info['mobile'])}<input type="text" class="field disabled" name="" disabled="disabled" value="{$mobile}">{else:}<input type="text" class="field" pattern="mobi" name="mobile" value="{$mobile}" alt="请正确填写手机号"><label></label>{/if}
					</li>
					<li class="line caption">
						<label class="caption">电话号码：</label><input type="text" class="field" name="phone"  value="{$phone}" empty pattern="phone" alt="请正确填写电话号码">
					</li>
					<li class="line other">
						<label class="caption">性别：</label><input name="sex" type="radio" value="0" class="magic-radio" id="magic-radio-1" checked="checked"><label for="magic-radio-1"> 女</label> &nbsp;&nbsp;<input class="magic-radio" name="sex" id="magic-radio-2" type="radio" {if:isset($sex) && $sex==1}checked="checked"{/if} value="1"> <label for="magic-radio-2"> 男</label>
					</li>
					<li class="line other">
					 	<label class="caption"> 所在地区：</label><td id="area"><select id="province" class="field"  name="province" >
							<option value="0">==省份/直辖市==</option>
						</select>
						<select id="city"  class="field" name="city"><option value="0">==市==</option></select>
						<select id="county"  class="field" name="county"><option value="0">==县/区==</option></select><input pattern="^\d+,\d+,\d+$" id="test" type="text" style="visibility:hidden;width:0;" value="{$province},{$city},{$county}" alt="请选择完整地区信息！"><label></label></td>
					</li>
					<li class="line textarea">
						<label class="caption">街道地址：</label>
						<textarea name="addr" pattern="required" minlen="5" maxlen="120" alt="不需要重复填写省市区，必须大于5个字符，小于120个字符">{$addr}</textarea>
					</li>
					<li class="line tc">
						<input type="submit" class="btn btn-main" value="保存">
					</li>
				</ul>
				</form>
				</div>
				<div class="col-1">
					{if:$user['head_pic']==''}
					<img id="head-pic" class="ie6png" src="{url:#images/no-img.png}" width="120" height="120">
					{else:}
					<img id="head-pic" class="ie6png" src="{url:@$user[head_pic]}" width="120" height="120">
					{/if}
					<p style="padding: 10px 30px;"><a href="javascript:;" id="upload-link">修改头像</a></p>
				</div>
			</div>
		</div>
	</div>
</div>
<div id="head-dialog" style="display: none">
	<div class="box" style="width:400px;">
		<h2>上传头像：</h2>
		<div class="content mt20 p10">
			<form enctype="multipart/form-data" action="{url:/ucenter/upload_head}" method="post"  id="uploadForm">
				<p><input type="file" name="imgFile" ></p>
				<p class="mt20 tc"><button class="btn btn-main" id="upload-btn">上传</button></p>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	$("#upload-link").on("click",function (){
		art.dialog({id:'head-dialog',content:document.getElementById('head-dialog'),lock:true});
	});

	$("#uploadForm").iframePostForm({
		iframeID: 'iframe-post-form',
		json:true,
		post: function(){
			$("#upload-btn").text("上传中...")
		},
		complete: function(data){
			if(data['error']==1){
				alert(data['message']);
			}else{
				var root_url = "{url:@}"
				$("#head-pic").attr("src",root_url+data['url']+'?i='+Math.random());
				art.dialog({id:'head-dialog'}).close();
			}
			$("#upload-btn").text("上传");
		}

	});

	var form =  new Form('info-form');
	form.setValue('is_default','{$is_default}');
	$("#areas").Linkage({ url:"{url:/ajax/area_data}",selected:[{$province|0},{$city|0},{$county|0}],callback:function(data){
		var text = new Array();
		var value = new Array();
		for(i in data[0]){
			if(data[0][i]!=0){
				text.push(data[1][i]);
				value.push(data[0][i]);
			}
		}
		$("#test").val(value.join(','));
		FireEvent(document.getElementById("test"),"change");
	}});
	{if:isset($invalid)}
	autoValidate.showMsg({id:$("input[name='{$invalid['name']}']").get(0),error:true,msg:'{$invalid['msg']}'});
	{/if}
</script>
