<!DOCTYPE html>
<html>
	<?php echo $this->fetch('head.html'); ?>

	<body>
		<div class="header">
			<div class="header-back"></div>
			<div class="header-title">分类信息发布</div>
		</div>
		<div class="header-row"></div>
		<div class="main-body">
			<form method="post" action="/module.php?m=fenlei&a=save">
				<input type="hidden" name="id" style="display:none;" value="<?php echo $this->_var['data']['id']; ?>">
				 <input type="hidden" name="catid" value="<?php echo $this->_var['catid']; ?>" />
					<div class="input-flex">
						<div class="input-flex-label input-flex-require">标题：</div>
						<input type="text" class="input-flex-text" name="title" id="title" value="<?php echo $this->_var['data']['title']; ?>">
						
					</div>
					
					<?php if ($this->_var['cat']['money_open']): ?>
					<div class="input-flex">
						<div class="input-flex-label input-flex-require"><?php echo $this->_var['cat']['moneyLabel']; ?>：</div>
						<input type="text" class="input-flex-text" name="money" id="money" value="<?php echo $this->_var['data']['money']; ?>">
						<div class="input-flex-note">元</div>
					</div>
					 <?php endif; ?>
					<?php if ($this->_var['cat']['area_open']): ?> 
					<div class="input-flex">
						<div class="input-flex-label input-flex-require">所在区域：</div>
						<select name="sc_id" class="input-flex-select">
							<option value="0">请选择</option>
							<?php $_from = $this->_var['scList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
							<option value="<?php echo $this->_var['c']['sc_id']; ?>" <?php if ($this->_var['data']['sc_id'] == $this->_var['c']['sc_id']): ?>selected<?php endif; ?>><?php echo $this->_var['c']['title']; ?></option>
							<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
						</select>
					</div>
					<?php endif; ?>
					<?php if ($this->_var['typeList']): ?>
					 <div class="input-flex">
					 	<div class="input-flex-label input-flex-require"><?php echo $this->_var['cat']['typeLabel']; ?>：</div>
					 	<select name="typeid" class="input-flex-select">
					 		<option value="0">请选择</option>
					 		<?php $_from = $this->_var['typeList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
					 		<option value="<?php echo $this->_var['k']; ?>" <?php if ($this->_var['data']['typeid'] == $this->_var['k']): ?>selected<?php endif; ?>><?php echo $this->_var['c']; ?></option>
					 		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
					 	</select>
					 </div>
					<?php endif; ?> 
					<div class="textarea-flex">
						<div class="textarea-flex-label input-flex-require">描述：</div>
						<textarea  class="textarea-flex-text h60" name="description" id="description"><?php echo $this->_var['data']['description']; ?></textarea>
					</div>
					 
					
					 
					<div class="bg-fff mgb-5">
						<input type="hidden" name="imgsdata" id="imgsdata" value="<?php echo $this->_var['data']['imgsdata']; ?>" />
					<?php echo $this->fetch('inc/uploader-data.html'); ?>
					</div>
					 
					
					<div class="input-flex">
						<div class="input-flex-label input-flex-require">联系人：</div>
						<input type="text" class="input-flex-text" name="nickname" id="nickname" value="<?php echo $this->_var['nickname']; ?>">
					</div>
					<div class="input-flex">
						<div class="input-flex-label input-flex-require">电话：</div>
						<input type="text" class="input-flex-text" name="telephone" id="telephone" value="<?php echo $this->_var['telephone']; ?>">
					</div>
					
					<div class="input-flex">
						<div class="input-flex-label input-flex-require">地址：</div>
						<input type="text" class="input-flex-text" name="address" id="address" value="<?php echo $this->_var['address']; ?>">
					</div>
				<?php if ($this->_var['payMoney']): ?>
				 <div class="input-flex">
					 <div class="input-flex-label">支付费用</div>
					 <div class="input-flex-txt"><?php echo $this->_var['payMoney']; ?></div>
					 
				 </div>
				 <?php if ($this->_var['inIos']): ?>
				 <div class="pd-10 cl-red">Ios暂时无法支付，请联系客服充值</div>
				 <?php endif; ?>
				 <?php endif; ?>
				 <?php if ($this->_var['fieldsList']): ?>
				 <div class="pd-10">扩展属性</div>
				 <?php endif; ?>
				 <?php $_from = $this->_var['fieldsList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
				 <?php if ($this->_var['c']['fieldtype'] == 'text'): ?>
				 <div class="input-flex">
				 	<div class="input-flex-label"><?php echo $this->_var['c']['title']; ?></div>
				 	<input class="input-flex-text" type="text" name="tablefield[<?php echo $this->_var['c']['fieldname']; ?>]" value="<?php echo $this->_var['c']['value']; ?>" />
				 </div>
				 <?php elseif ($this->_var['c']['fieldtype'] == 'textarea'): ?>
				 <div class="textarea-flex">
				 	<div class="textarea-flex-label"><?php echo $this->_var['c']['title']; ?></div>
				 	<textarea name="tablefield[<?php echo $this->_var['c']['fieldname']; ?>]" class="textarea-flex-text h60"><?php echo $this->_var['c']['value']; ?></textarea>
				 </div>
				 <?php elseif ($this->_var['c']['fieldtype'] == 'html'): ?>
				 <div class="textarea-flex">
				 	<div class="textarea-flex-label"><?php echo $this->_var['c']['title']; ?></div>
				 	<div class="js-html-item">
				 		<textarea name="tablefield[<?php echo $this->_var['c']['fieldname']; ?>]" class="none js-html-textarea"><?php echo $this->_var['c']['value']; ?></textarea>
				 		<div contenteditable="true" class="sky-editor-content textarea-flex-text "><?php echo $this->_var['c']['value']; ?></div>
				 	</div>
				 </div>
				 <?php elseif ($this->_var['c']['fieldtype'] == 'img'): ?>
				 <div class="input-flex">
				 	<div class="input-flex-label"><?php echo $this->_var['c']['title']; ?></div>
				 	<div class="flex-1">
				 		<div class="js-upload-item">
				 			<input type="file" id="tablefield<?php echo $this->_var['c']['id']; ?>" class="js-upload-file" style="display: none;" />
				 			<div class="upimg-btn js-upload-btn">+</div>
				 			<input type="hidden" name="tablefield[<?php echo $this->_var['c']['fieldname']; ?>]" class="js-imgurl" value="<?php echo $this->_var['c']['value']; ?>" />
				 			<div class="js-imgbox">
				 				<?php if ($this->_var['c']['value']): ?>
				 				<img src="<?php echo images_site($this->_var['c']['value']); ?>.100x100.jpg" class="w60" />
				 				<?php endif; ?>
				 			</div>
				 		</div>
				 	</div>
				 </div>
				 <?php elseif ($this->_var['c']['fieldtype'] == 'map'): ?>
				 <div class="bg-white">
				 	<div class="pd-10"><?php echo $this->_var['c']['title']; ?></div>
				 	<div class="js-map">
				 		<input type="hidden" class="map-value"  name="tablefield[<?php echo $this->_var['c']['fieldname']; ?>]"  value="<?php echo $this->_var['c']['value']; ?>" />
				 		<div class="flex mgb-5 pdl-10">
				 			<input type="text" id="mapWord" />
				 			<div id="mapSearch" class="input-flex-btn">搜一下</div>
				 		</div>
				 		<div class="map" id="map" style="width: 100%; height: 300px;"></div>
				 	</div>
				 </div> 
				 <?php endif; ?>
				 <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
				<div class="btn-row-submit " id="submit">保存</div>
			</form>

		</div>
		<?php echo $this->fetch('footer.html'); ?>
		<?php if (INWEIXIN): ?>
		<?php wx_jssdk();?>
		<script src="<?php echo $this->_var['skins']; ?>inc/uploader-data-wx.js?<?php echo time(); ?>"></script> 
		<?php else: ?> 
		<script src="<?php echo $this->_var['skins']; ?>inc/uploader-data.js"></script>
		<script src="/plugin/lrz/lrz.bundle.js?v2"></script>
		<?php endif; ?>
		<script src="/plugin/laydate/laydate.js"></script>
		<script>
			laydate.render({
				elem:"#startTime",
				type:"datetime"
			})
			$(document).on("click","#submit",function(){
				var form=$(this).parents("form");
				var imgs=$(".uploader-imgsdata-img");
				 
				if(imgs.length>0){
					var s="";
					for(var i=0;i<imgs.length;i++){
						if(i>0){
							s+=",";
						}
						s+=imgs.eq(i).attr("v");		
					}
					$("#imgsdata").val(s);
				}
				 
				$.post(form.attr("action")+"&ajax=1",form.serialize(),function(res){
					skyToast(res.message);
					if(!res.error){
						if(res.data.action=="finish"){
							goBack();
						}else if(res.data.action=="pay"){
							window.location=res.data.payurl;
						}
					}
				},"json")
			})
		</script>
	</body>
</html>
