<?php if (!defined('ROOT')){ echo 'Deny ...'; exit; } extract($data); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>MAIN</title>
        <link href="<?php echo $base_url; ?>static/css/style.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo $base_url; ?>static/css/select.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="<?php echo $base_url; ?>static/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo $base_url; ?>static/js/select-ui.min.js"></script>
        <script type="text/javascript" src="<?php echo $base_url; ?>static/js/common.js"></script>
    </head>
    <body>
<?php
$default = '{
    "button": [
        {
            "name": "点击跳转",
            "sub_button": [
                {
                    "type": "click",
                    "name": "点击推事件",
                    "key": "MIZHU"
                },
                {
                    "type": "view",
                    "name": "跳转URL",
                    "url": "http://mp.weixin.qq.com/s?__biz=MzA5NzM2MTI4OA==&mid=205215861&idx=1&sn=890e36a114827cb510542315dd706c9d#rd"
                }
            ]
        },
        {
            "name": "点击跳转",
            "sub_button": [
                {
                    "type": "click",
                    "name": "点击推事件",
                    "key": "MIZHU"
                },
                {
                    "type": "view",
                    "name": "跳转URL",
                    "url": "http://mp.weixin.qq.com/s?__biz=MzA5NzM2MTI4OA==&mid=205215861&idx=1&sn=890e36a114827cb510542315dd706c9d#rd"
                }
            ]
        },
        {
            "name": "点击跳转",
            "type": "click",
            "key": "MIZHU"
        }
    ]
}';
$wxMenuParams = service::get_option('wxMenuParams');
if (empty($wxMenuParams)){
    $wxMenuParams = $default;
}
?>        
        <div class="place">
            <span>位置：</span>
            <ul class="placeul">
                <li><a href="<?php echo $base->get_model_url(array('c' => 'frame', 'm' => 'main')); ?>">首页</a></li>
                <li>自定义菜单</li>
            </ul>
        </div>
        <div class="formbody">
            <div class="usual">
                <div class="tabson">
                    <?php echo form::tip($admin['username'], '您正在使用微信自定义菜单生成器');?>
                    <ul class="forminfo">
                        <li>
                            <label>菜单内容</label>
                            <textarea name="content" id="content" class="dfarea" style="height: 400px; width: 90%;"><?php echo $wxMenuParams;?></textarea>
                        </li>
                        <li><label>&nbsp;</label><input name="btn88" type="button" class="btn btn88" value="生成菜单"/></li>
                    </ul>
                </div>
                <div style="line-height: 22px; margin-bottom: 24px; height: auto;" class="formtext">
                    <p><b>相关链接:</b></p>
                    <p>首页：<?php echo $host.PROJECT.'/';?></p>
                    <p>会员：<?php echo $host.PROJECT.'/index.php?c=welcome&view=user';?></p>
                    <p>购买：<?php echo $host.PROJECT.'/index.php?c=welcome&view=user&pay=1';?></p>
                    <p>发布：<?php echo $host.PROJECT.'/index.php?c=welcome&view=post';?></p>
                    <p><b>相关命令:</b></p>
                    <p>二维码海报：“二维码”</p>
                    <p>在线客服：“客服”</p>
                </div>                
            </div>
        </div>
        <script>
            $(function(){
                $(".btn88").click(function(){
                    var c = $('#content').val();
                    $.post('<?php echo $base->get_model_url(array('c' => 'menu', 'm' => 'create'));?>', {content: c}, function (ret){
                        alert(ret);
                    });
                });
            });
        </script>
    </body>
</html>
