<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>代码调试</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-horizontal" role="form" method="post" action="debug/actionrequest" data-validate="validate" data-callBack="shworsdata" data-useDefaultCallBack="on">
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">请求环境</label>
                                            <div class="col-sm-4">
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="reqenv" value="local" checked>内网
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="reqenv" value="officia">正式
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        <hr />
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">请求类型</label>
                                            <div class="col-sm-4">
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="reqaddress" value="login.php" checked>登陆请求
                                                    </label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" name="reqaddress" value="gateway.php">接口请求
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        <hr />
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">sid</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="1" name="sid" value="1">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">lid</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="1" name="lid" value="1">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group moddiv hide">
                                            <label class="col-sm-2 control-label">mod</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="mod名" name="mod">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group actdiv hide">
                                            <label class="col-sm-2 control-label">act</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control" placeholder="act名" name="act">
                                            </div>
                                            <p class="col-sm-6 help-block">必填</p>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">详细参数</label>
                                            <div class="col-sm-5">
                                                <textarea rows="8" class="form-control" name='detailed'>{"version":"1.0.0.0","deviceModel":"deviceModel","simNum":"simNum","deviceName":"deviceName","sid":1,"mobile_request":"QzktMUYtNjYtMjItRTgtQTE1X3N1cGVyYW50=","location":"location","mtkey":"","ramSize":"ramSize","cpuInfo":"cpuInfo","pay":"android","sign":"f9b3e0a11aff233149d5596330c8fd94","lid":2,"udid":"852438d026c018c4307b916406f98c62","osVersion":"1.0.0","installInfo":"installInfo","channel_id":"test","deviceId":"deviceId","device":"android","macAddr":"getMacAddr","networkType":"networkType"}</textarea>
                                            </div>
                                        </div>
                                        <hr/>
                                        <div class="form-group">
                                            <div class=" col-sm-12">
                                                <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
                                            </div>
                                        </div>
                                    </form>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">返回数据</label>
                                        <div class="col-sm-8">
                                            <textarea rows="12" class="form-control" name='returndata'></textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>

</div>


<script>
    $("input[name='reqaddress']").click(function(){
        var reqaddress = $(this).val();
        if( reqaddress == 'login.php') {
            $(".moddiv").addClass('hide');
            $(".actdiv").addClass('hide');
        }else{
            $(".moddiv").removeClass('hide');
            $(".actdiv").removeClass('hide');
        }

    });

    function shworsdata(returnData, $from) {
        var rd = $('textarea[name="returndata"]');
        rd.val('');
        rd.val(returnData.retdata);
    }


    function validate($from) {
        var detailed = $from.find('textarea[name="detailed"]');
        if ($.trim(detailed.val()) == '') {
            return '详细参数不能为空';
        }

        return true;
    }
</script>