<style type="text/css">
	.tips {right:-35px;}
</style>

<div class="main-right-box">
<h5>修改微信公众号菜单</h5>
<div class="blank20"></div>
<div class="box">


<script type="text/javascript">
var base_url = '{config::get('site_url')}';
</script>

<form method="post" name="form1" action="<?php if(front::$act=='edit') $id="/id/".$data['id']; else $id=''; echo modify("/act/".front::$act."/table/".$table.$id);?>"  onsubmit="return checkform();">
<input type="hidden" name="wid" id="wid" value="<?php echo intval($data['wid']);?>" />
<input type="hidden" name="pid" id="pid" value="<?php echo intval($data['pid']);?>" />
<input type="hidden" name="id" id="id" value="<?php echo intval($data['id']);?>" />
 
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-3 col-lg-2 text-right">名称</div>
<div class="col-xs-8 col-sm-7 col-md-7 col-lg-5 text-left">
<input type="text" name="name" id="name" value="{$data['name']}" class="form-control" />
</div>
</div>
<div class="clearfix blank20"></div>

<div class="row">
<div class="col-xs-4 col-sm-4 col-md-3 col-lg-2 text-right">排序</div>
<div class="col-xs-8 col-sm-7 col-md-7 col-lg-5 text-left">
<input type="text" name="sort" id="sort" value="{$data['sort']}" class="form-control" />
</div>
</div>
<div class="clearfix blank20"></div>

<div class="row">
<div class="col-xs-4 col-sm-4 col-md-3 col-lg-2 text-right">类型
</div>
<div class="col-xs-8 col-sm-7 col-md-7 col-lg-5 text-left">
<select name="typeid" id="typeid" onchange="changetype()" class="form-control select">
          {if !intval(front::$get['pid'])}
          <option value="1" {if $data['typeid']==1}selected{/if}>菜单</option>
          {/if}
          <option value="2" {if $data['typeid']==2}selected{/if}>打开网址</option>
          <option value="3" {if $data['typeid']==3}selected{/if}>文字回复</option>
          <option value="4" {if $data['typeid']==4}selected{/if}>图文回复</option>
          <option value="5" {if $data['typeid']==5}selected{/if}>网站内容推送</option>
        </select>
        <span class="caidantype_1 ">
		<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="设置为菜单则可以用于添加二级菜单，点击此菜单将会展开二级菜单"></span>
		</span>

		<div class="caidantype_3" style="display:{if $data['typeid']!=3}none{/if}">
		<dl>
			<dt><div class="blank10"></div></dt>
			<dd>
				<textarea name="txt" class="form-control textarea" value="{$data['txt']}" placeholder="请填写回复内容！">{$data['txt']}</textarea>
				<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="微信能够识别电话号码，支持点击电话号码直接拨打！"></span>
			</dd>
		</dl>
		</div>
		<div class="caidantype_5" style="display:{if $data['typeid']!=5}none{/if}">
		<dl>
			<dt><div class="blank10"></div></dt>
			<dd>
			
		<select name="catid" id="catid" class="form-control select">
        <?php
			$option = array(0=>'所有栏目');
			$catids = category::option(0,'tolast',$option);
			if (is_array($catids) && !empty($catids)){
            foreach ($catids as $catid=>$catname){
			?>
            <option  {if $data['catid']==$catid}selected{/if} value="{$catid}">{$catname}</option>
		<?php
		}
			}
			?>
		</select>
			</dd>
		</dl>
		<dl>
			<dt><div class="blank10"></div></dt>
			<dd>
				<input name='num' type='text'  value='{$data['num']}' class="form-control" placeholder="填写推送内容条数，最多10条！" />
				<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="填写推送内容条数，最多10条！"></span>
			</dd>
		</dl>
		</div>
        <?php
        $tmparr = explode('|',$data['imgtext']);
		$i = 1;
		if(is_array($tmparr) && !empty($tmparr)){
			foreach($tmparr as $str){
				$tmp = explode('*',$str);
		?>
		<div name="imgtext" class="caidantype_4" style="display:{if $data['typeid']!=4}none{/if}">
			<div class="blank30"></div>
			<h5 class="v52fmbx_hr metsliding" sliding="1">图文内容[{$i}]&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:deletdisplayimg({$i});' class='displayimg_del' title="删除"><i class="glyphicon glyphicon-trash"></i></a>
</h5>
			<dl>
				<dt><div class="blank10"></div></dt>
				<dd style='position:relative;'>
                  <script type="text/javascript">
                 $(function(){
					var swfu_{$i};
					var settings_{$i} = {
						callback_data_des: 'pic{$i}',
						flash_url : "{$base_url}/common/swfupload/swfupload.swf",
						upload_url: "{url('tool/uploadimage2/site/'.front::get('site'),false)}",
						post_params: {"PHPSESSID" : "<?php echo session_id();?>"},
						file_size_limit : "{ini_get('upload_max_filesize')}B",
						file_types : "*.jpg;*.gif;*.png;*.bmp",
						file_types_description : "图片", //All Files
						file_upload_limit : 100,
						file_queue_limit : 0,
						custom_settings : {
			                progressTarget : "fsUploadProgress",
			                cancelButtonId : "btnCancel1"
			            },
						debug: false,
			
						// Button settings
						//button_image_url: "/cmseasy/common/swfupload/botton.png",
						button_width: "39",
						button_height: "18",
						button_placeholder_id: "spanButtonPlaceHolder_{$i}",
						//button_text: '<span class="theFont">上传</span>',
						//button_text_style: ".theFont{float:left;display:block;color:#529fd0;font-size:14px;width:160px;height:40px;line-height:22px;font-weight:bold;}",
						//button_text_left_padding: 7,
						//button_text_top_padding: 5,
						button_disabled : false,
						button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
						button_cursor: SWFUpload.CURSOR.HAND,
			
						// The event handler functions are defined in handlers.js
						file_queued_handler : fileQueued,
						file_queue_error_handler : fileQueueError,
						file_dialog_complete_handler : fileDialogComplete,
						upload_start_handler : uploadStart,
						upload_progress_handler : uploadProgress,
						upload_error_handler : uploadError,
						upload_success_handler : uploadSuccess,
						upload_complete_handler : uploadComplete,
						queue_complete_handler : queueComplete	// Queue plugin event
					};
					swfu_{$i} = new SWFUpload(settings_{$i});
							 });
                </script>
<div class="img_upload">
            <input type="text" name="pic[]" id="pic{$i}"   class="form-control"  value="{$tmp['2']}" class="form-control" placeholder="请填写图片调用地址" />
		
                <span style="float:left;" id="spanButtonPlaceHolder_{$i}"></span>
                <input id="btnCancel{$i}" type="button" value="取消" disabled="disabled" style="display:none;" />
</div>
           
           
				</dd>
			</dl>
            <div style="clear:both;"></div>
			<dl>
				<dt><div class="blank10"></div></dt>
				<dd style='position:relative;'>
					<input name='twname[]' type='text'  class="form-control"  value='{$tmp['0']}' class="form-control" placeholder="请填写内容标题！" />
					<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="填写内容标题！"></span>
				</dd>
			</dl>
			<dl>
				<dt><div class="blank10"></div></dt>
				<dd style='position:relative;'>
				<input name='twurl[]' type='text' value='{$tmp['1']}'  class="form-control" placeholder="请填写内容链接" />
				<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="填写内容链接！"></span>
				</dd>
			</dl>
            <?php
			if($i == 1){
			?>
			<dl>
				<dt><div class="blank10"></div></dt>
				<dd style='position:relative;'>
					<textarea name="intro" class="form-control textarea"  value="{$data['intro']}" placeholder="请填写描述内容">{$data['intro']}</textarea>

					<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="多图文内容展示时候，将不会显示描述内容！"></span>
				</dd>
			</dl>
            <?php
			}
			?>
		</div>
        <?php
		$i++;
        }
		}
		?>
        <div id="moreimg"></div>
		<div class="caidantype_4" style="display:{if $data['typeid']!=4}none{/if}">
			<dl>
				<dt>
				</dt>
				<dd><div class="blank10"></div>
				<a href="javascript:void();" onclick="return weixin_adddisplayimg();" class="btn btn-info search-btn">添加图文内容</a>
				<span id="loadtxt"></span>
				<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="最多添加8个图文内容！"></span>
				</dd>
			</dl>
		</div>
        
		<div class="caidantype_2" style="{if !intval(front::$get['pid']) && $data['typeid']!=2}display:none{/if}">
		<dl>
			<dt><div class="blank10"></div></dt>
			<dd>
				<input name='twurl[]' type='text' value="{$data['url']}"  class="form-control" placeholder="请填写内容链接地址！" />
				<span class="tips" data-toggle="tooltip" data-html="ture" data-placement="right" title="请填写内容链接地址！"></span>
			</dd>
		</dl>
		</div>

</div>
</div>


	<div class="blank30"></div>
<div class="line"></div>
<div class="blank30"></div>

    <input type="submit" name="submit" value="提交" class="btn btn-primary" />

</form>
</div>
<script type="text/javascript">
var num = <?php echo count($tmparr)?count($tmparr):1;?>;
function weixin_adddisplayimg(){
	var i=0;
	$("input[name*='displayimg']").each(function(){
		i++;
	});
	if(i>7){
		alert('最多添加8个图文内容');
		return false;
	}
	return adddisplayimg();
}

function adddisplayimg() {
	$('#loadtxt').html('正在加载...');
	num++;
	$.ajax({
		url: '<?php echo url('weixinmenu/addtuwen');?>',
		type: "POST",
		data: 'num=' + num,
		success: function(data) {
			//alert(data);
			$('#moreimg').append(data);
			$('#loadtxt').html('');
		}
	});
	return false;
}

function deletdisplayimg(i){
	//alert($('#tuwen'+i));
	$('#tuwen'+i).remove();
	num--;
}

function changetype(){
	var type=$('#typeid').val();
	$("[class*=caidantype_]").hide();
	$(".caidantype_"+type).show();
}
</script>

<div class="blank30"></div>
</div>
</div>