<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dianyando.aspx.cs" Inherits="stupingjia.app.dianyando" %>

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>市学生接送需求调研系统</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../weui/css/weui.css" />
    <link rel="stylesheet" href="../weui/css/weuix.css" />
    <script src="../weui/js/zepto.min.js"></script>
    <script src="../weui/js/zepto.weui.js"></script>
    <script src="../weui/js/php.js"></script>
    <script src="../weui/js/Method.js"></script>
    <script src="../weui/js/lrz.min.js"></script>
     <script src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script>
       
    </script>
</head>

<body ontouchstart>
    <div class="weui-header bg-blue">
        <div class="weui-header-left">  </div>
        <h1 class="weui-header-title"><b>请再次确认信息</b></h1>
        <div class="weui-header-right"></div>
    </div>
<form name="form" id="form">
    <div class="weui-cells weui-cells_form">
    <span class='weui-btn_default f-red'><b>温馨提醒：</b>根据市关于“双减”工作文件精神要求，完善并落实课后服务各项工作，全面解决学生上下学过程中的安全隐患和学校附近交通拥堵问题。为确保本次调研顺利完成，请各位家长务必认真仔细填写本调研表。<br /></span>
        <input id="id" name="id" value="" type="hidden" />
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">学校名称</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="xuexiao" id="xuexiao" type="text" placeholder="请选择所在学校">
                <input id="xuexiaoid" name="xuexiaoid" value="" type="hidden" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">所在班级</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="banji" id="banji" type="text" placeholder="请选择所在班级">
                <input id="banjiid" name="banjiid" value="" type="hidden" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">学生姓名</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="stuxm" id="stuxm" type="text" placeholder="请填写学生姓名">
            </div>
        </div>
       <!-- <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">学生学号</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="xuehao" id="xuehao" type="text" placeholder="请填写学生学号">
            </div>
        </div>-->
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">家长姓名</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="lianxiren" id="lianxiren" type="text" placeholder="请填写家长姓名">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">手机号码</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" maxlength="11" name="tel" id="tel" type="text" placeholder="请填写11位手机号码">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">乡镇街道</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="jiedao" id="jiedao" type="text" placeholder="请选择所在乡镇街道">
                <input name="jiedaoid" id="jiedaoid"  value="" type="hidden" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">所在社区</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="shequ" id="shequ" type="text" placeholder="请选择所在社区">
                <input name="shequid" id="shequid"  value="" type="hidden" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">小区(村)</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="xiaoqu" id="xiaoqu" type="text" placeholder="请填写所在小区(村)">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">交通方式</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="fangshi" id="fangshi" type="text" placeholder="请选择您的出行交通方式">
            </div>
        </div>
         <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">接送服务</label>
            </div>
            <div class="weui-cell__bd">
                <div class="weui-form-li iblock">
                    <input class="weui-form-checkbox" name="jiesong" id="j1" value="1" type="radio">
                    <label for="j1">
                        <i class="weui-icon-radio"></i>
                        <div class="weui-form-text">
                            <p>是</p>
                        </div>
                    </label>
                </div>
                <div class="weui-form-li iblock">
                    <input class="weui-form-checkbox" name="jiesong" id="j2" value="0" type="radio">
                    <label for="j2">
                        <i class="weui-icon-radio"></i>
                        <div class="weui-form-text">
                            <p>否</p>
                        </div>
                    </label>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">乘车地点</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="shangche" id="shangche" type="text" placeholder="请在地图中选择乘坐公交车的理想位置">
                <input class="weui-input" id="lng" name="lng" type="hidden" value="">
                            <input class="weui-input" id="lat" name="lat" type="hidden" value="">
            </div>
            <div class="weui-cell__ft">
            <a  href="javascript:;"  class="weui-vcode-btn  open-popup"  data-target="#full">地图点选</a>
        </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">短信服务</label>
            </div>
            <div class="weui-cell__bd">
                <div class="weui-form-li iblock">
                    <input class="weui-form-checkbox" name="duanxin" id="d1" value="1" type="radio">
                    <label for="d1">
                        <i class="weui-icon-radio"></i>
                        <div class="weui-form-text">
                            <p>是</p>
                        </div>
                    </label>
                </div>
                <div class="weui-form-li iblock">
                    <input class="weui-form-checkbox" name="duanxin" id="d2" value="0" type="radio">
                    <label for="d2">
                        <i class="weui-icon-radio"></i>
                        <div class="weui-form-text">
                            <p>否</p>
                        </div>
                    </label>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">车辆轨迹</label>
            </div>
            <div class="weui-cell__bd">
                 <div class="weui-form-li iblock">
            <input class="weui-form-checkbox"  name="guiji"  id="g1" value="1" type="radio">
            <label for="g1" >
                <i class="weui-icon-radio"></i>
                <div class="weui-form-text"><p>是</p></div>
            </label>
        </div>
        <div class="weui-form-li iblock">
            <input class="weui-form-checkbox"  name="guiji"  id="g2" value="0" type="radio">
            <label for="g2" >
                <i class="weui-icon-radio"></i>
                <div class="weui-form-text"><p>否</p></div>
            </label>
        </div>
            </div>
        </div>
        <!--
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label weui-start">车内视频（收费）</label>
            </div>
            <div class="weui-cell__bd">
                  <div class="weui-form-li iblock">
            <input class="weui-form-checkbox"  name="shipin"  id="s1" value="1" type="radio">
            <label for="s1" >
                <i class="weui-icon-radio"></i>
                <div class="weui-form-text"><p>是</p></div>
            </label>
        </div>
        <div class="weui-form-li iblock">
            <input class="weui-form-checkbox"  name="shipin"  id="s2" value="0" type="radio">
            <label for="s2" >
                <i class="weui-icon-radio"></i>
                <div class="weui-form-text"><p>否</p></div>
            </label>
        </div>
            </div>
        </div>
        !-->
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">备注</label>
            </div>
            <div class="weui-cell__bd">
                <textarea class="weui-textarea" name="beizhu" id="beizhu" placeholder="若有其它需求，请在此填写" rows="2" onkeyup="textarea(this);"></textarea>
            <div class="weui-textarea-counter"><span>0</span>/<i>300</i></div>
            </div>
        </div>
    </div>
<div class="weui-flex">
    <div class="weui-flex__item"><div class="placeholder"> <a  href="javascript:history.go(-1)"  class="weui-btn bg-red">取消</a></div></div>
    <div class="weui-flex__item"><div class="placeholder"><a id="btn"  class="weui-btn weui-btn_primary">确认提交</a></div></div>
</div>
    <br />
    <div class="weui-footer">
    <span class="padding-5"><b>本服务由市交通运输局、市教体局提供</br>系统开发：郸城县新翔软件科技有限公司</b></span>
</div>
</form>
<div id="full" class='weui-popup__container'>
    <div class="weui-popup__overlay">点击选择地点</div>
    <div class="weui-popup__modal">
        <iframe style="position: fixed;z-index:9999;bottom:0;height: 94%;" id="mapPage" width="100%" height="100%" frameborder=0
    src="map.html">
</iframe>
        <a href="javascript:" onclick="isxuanze();" class="weui-btn weui-btn_primary">确定</a>
    </div>
</div>
    <br>
    <br>
    <script src="../js/Method.js"></script>
    <script>
        $('#loading').hide();
        function isxuanze() {
                $.closePopup();
        }
        function textarea(input) {
            var content = $(input);
            var max = content.next().find('i').text();
            var value = content.val();
            if (value.length > 0) {
                value = value.replace(/\n|\r/gi, "");
                var len = value.length;
                content.next().find('span').text(len);
                if (len > max) {
                    return false;
                    content.next().addClass('f-red');
                } else {
                    content.next().removeClass('f-red');
                }
            }
        }
        $("#fangshi").select({
            title: "交通方式",
            items: [
                {
                    title: "公交车",
                    value: "公交车",
                } ,
                {
                    title: "私家车",
                    value: "私家车",
                },
                {
                    title: "电瓶车",
                    value: "电瓶车",
                },
                {
                    title: "步行",
                    value: "步行",
                }
            ]
        });
        $('input[name=jiesong]').change(function () {
            if ($(this).val() == 0) {
                $('input[name=shangche]').parent().parent().hide();
                $('input[name=duanxin]').parent().parent().parent().hide();
                $('input[name=guiji]').parent().parent().parent().hide();
                $('input[name=shipin]').parent().parent().parent().hide();
            } else {
                $('input[name=shangche]').parent().parent().show();
                $('input[name=duanxin]').parent().parent().parent().show();
                $('input[name=guiji]').parent().parent().parent().show();
                $('input[name=shipin]').parent().parent().parent().show();
            }
        })
        $(function () {
            var id = $_GET('id');
            if (id) {
                $("#id").val(id);
                $.ajax({
                    type: "post",
                    url: '?action=edit',
                    data: {id:id},
                    dataType: 'json',
                    success: function (res) {
                        $("#xuexiao").val(res.xuexiao);
                        $("#xuexiaoid").val(res.xuexiaoid);
                        $("#banji").val(res.banji);
                        $("#banjiid").val(res.banjiid);
                        $("#stuxm").val(res.stuxm);
                        $("#lianxiren").val(res.lianxiren);
                        $("#tel").val(res.tel);
                        $("#jiedao").val(res.jiedao);
                        $("#jiedaoid").val(res.jiedaoid);
                        $("#shequ").val(res.shequ);
                        $("#shequid").val(res.shequid);
                        $("#xiaoqu").val(res.xiaoqu);
                        $("#shangche").val(res.shangche);
                        $("#lng").val(res.lng);
                        $("#lat").val(res.lat);
                        $("#fangshi").val(res.fangshi);
                        $("input[name='jiesong'][value='"+ res.jiesong +"']").attr("checked", true);
                        $("input[name='duanxin'][value='"+ res.duanxin + "']").attr("checked", true);
                        $("input[name='guiji'][value='" + res.guiji + "']").attr("checked", true);
                        if (res.jiesong == 0) {
                            $('input[name=shangche]').parent().parent().hide();
                            $('input[name=duanxin]').parent().parent().parent().hide();
                            $('input[name=guiji]').parent().parent().parent().hide();
                            $('input[name=shipin]').parent().parent().parent().hide();
                        } else {
                            $('input[name=shangche]').parent().parent().show();
                            $('input[name=duanxin]').parent().parent().parent().show();
                            $('input[name=guiji]').parent().parent().parent().show();
                            $('input[name=shipin]').parent().parent().parent().show();
                        }
                        $("#beizhu").val(res.beizhu);
                    },
                    error: function (xhr) {
                        alert('获取数据出错');
                    }
                });
            }
            ajax('../api/Applist.ashx?action=jiedao', {}, function (data) {
           $("#jiedao").select({
               title: "选择街道",
               items: data,
               onChange: function (d) {
                   $("#jiedaoid").val(d.values);
                   ajax('../api/Applist.ashx?action=shequ&jiedaoid=' + d.values, {}, function (rewg) {
                       $("#shequ").select("update",{
                           title: "选择社区",
                           items: rewg,
                           onChange: function (dwg) {
                               $("#shequid").val(dwg.values);
                           },
                           onClose: function () {
                           },
                           onOpen: function () {
                           }
                       });
                   })
               },
               onClose: function () {
               },
               onOpen: function () {
               }
           });
         })
            ajax('../api/Applist.ashx?action=xuexiao', {}, function (data) {
                $("#xuexiao").select({
                    title: "选择学校",
                    items: data,
                    onChange: function (d) {
                        $("#xuexiaoid").val(d.values);
                        ajax('../api/Applist.ashx?action=banji&xuexiaoid=' + d.values, {}, function (rewg) {
                            $("#banji").select("update", {
                                title: "选择班级",
                                items: rewg,
                                onChange: function (dwg) {
                                    $("#banjiid").val(dwg.values);
                                },
                                onClose: function () {
                                },
                                onOpen: function () {
                                }
                            });
                        })
                    },
                    onClose: function () {
                    },
                    onOpen: function () {
                    }
                });
            })
            $(document).on("click", "#btn", function () {
                var stuxm = $("#stuxm").val();
                var xuexiaoid = $("#xuexiaoid").val();
                var banjiid = $("#banjiid").val();
                var jiedaoid = $("#jiedaoid").val();
                var shequid = $("#shequid").val();
                var lianxiren = $("#lianxiren").val();
                var tel = $("#tel").val();
                var xuehao = $("#xuehao").val();
                var fangshi = $("#fangshi").val();
                var id = $("#id").val();
                var jiesong = $('input[name=jiesong]:checked').val();
                if (stuxm == "" || stuxm.length < 2 || !is_chinese(stuxm)) {
                    $.toptip("学生姓名必须填写,且不能少于2个中文汉字");
                    return false;
                }
                if (lianxiren == "" || lianxiren.length < 2 || !is_chinese(lianxiren)) {
                    $.toptip("家长姓名必须填写，且不能少于2个中文汉字");
                    return false;
                }
                if (!is_phone(tel)) {
                    $.toptip("联系电话格式不正确");
                    return false;
                }
                if (xuexiaoid=="") {
                    $.toptip("所在学校必须选择");
                    return false;
                }
                /*if (!is_num(xuehao)) {
                    $.toptip("学生学号必须为数字");
                    return false;
                }*/
                if (banjiid=="") {
                    $.toptip("班级名称必须选择");
                    return false;
                }
                if (jiedaoid == "") {
                    $.toptip("乡镇街道必须选择");
                    return false;
                }
                if (shequid == "") {
                    $.toptip("社区名称必须选择");
                    return false;
                }
                if (xiaoqu == "") {
                    $.toptip("小区名称必须填写");
                    return false;
                }
                if (fangshi == "") {
                    $.toptip("交通方式必须选择");
                    return false;
                }
                if (jiesong == undefined) {
                    $.toptip("接送服务必须选择");
                    return false;
                }
                if (jiesong ==1) {
                    if ($("#shangche").val() == "" && $("#lng").val() == "" && $("#lat").val() == "") {
                        $.toptip("上下车地点必须点选");
                        return false;
                    }
                    if ($('input[name=duanxin]:checked').val() == undefined) {
                        $.toptip("短信服务必须选择");
                        return false;
                    }
                    if ($('input[name=guiji]:checked').val() == undefined) {
                        $.toptip("车辆轨迹服务必须选择");
                        return false;
                    }
                }
                $.post('?action=addsave', $("#form").serialize(), function (data, status) {
                    if (status == "success") {
                        var jsonData = data;
                        if (jsonData.isOk == 1) {
                            $.alert("提交成功", function () {
                                window.location.href = 'diaoyan.aspx';
                            });
                        } else {
                            $.alert(jsonData.message);
                        }
                    }
                }, 'json');
            })
        });
    </script>
</body>
</html>