<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,user-scalable=no,minimum-scale=1,initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="applicable-device" content="mobile">
    <title></title>
    <script type="text/javascript" src="__PUBLIC__/js/do.js" charset="utf-8"></script>
    <script type="text/javascript" src="__PUBLIC__/js/moble.js" charset="utf-8"></script>
    <style>
        *{margin:0px; padding:0px;}
        body{font-family: 'Helvetica Neue', Helvetica, sans-serif;font-size: 17px;line-height: 21px;color: #333;padding: .28rem;}
        #card{box-sizing: border-box;background: #fafafa url(__STATIC__/guard/bg.jpg) no-repeat left top;background-size: 100% auto;}
        .title{font-size:20px;color: #FFF;padding:25px 10px;margin-bottom:125px;}
        .title span{color: #FF0000;}
        .cards{width: 100%;background: #fff;box-sizing: border-box;box-shadow: 0 0.03rem 0.07rem 0 rgba(0,49,91,0.16);border-radius: 10px;padding: 10px 0px;margin-top:.2rem;}
        .mart27{margin-top:2.5rem;}
        .tips{--weui-FG-1: #FF0000;margin:10px;padding: 10px;text-align:left;background: #d9edf7;border-radius: 10px;}
        .weui-padding{margin:20px 0px;}
        .gray{font-size:12px;color: #FF0000;float:right;}
        .red{font-size:19px;color: #FF0000;}
        .green{font-size:19px;color: #54C865;}
        .manage{position: absolute;top:20px;right: 20px;}
        .show{display: block;}
        .hide{display:none;}
        .weui-form-preview{border-bottom:5px #d9edf7 solid;}
        .weui-cells__group_form .weui-cells__title{padding:5px 15px;}
        .weui-cells__group_form .weui-cell {padding: 16px 15px;}
        .weui-cells__group_form .weui-cell::before, .weui-cells__group_form .weui-cells::before {left: 15px;right: 15px;}
        .weui-label {width:80px}
        #success{padding: .28rem;box-sizing: border-box;background: #fafafa url(__STATIC__/guard/bg.jpg) no-repeat left top;background-size: 100% auto;position: absolute;top: 0;right: 0;bottom: 0;left: 0;overflow-y: auto;-webkit-overflow-scrolling: touch;box-sizing: border-box;z-index:2;}
    </style>
</head>
<body id="card" ontouchstart>
    <div id="page">
    {if $guard}
    <div class="title">{$guard.company}</div>
    {if $user.id == $guard.uid}
        <div class="manage"><a href="{:urls('guard/manage/index',$guard.member_miniapp_id,['id' => $guard.id])}" class="weui-btn weui-btn_mini weui-btn_primary">管理数据</a></div>
    {/if}
    <form id="form" action="{:urls('guard/index/index',$guard.member_miniapp_id,['id' => $guard.id])}" method="post">
    <div class="cards mart27">
        <div class="weui-cells__group weui-cells__group_form">
            <div class="weui-cells__title">基本信息 <text class="gray">填写后禁止修改</text></div>
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                    <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
                    <div class="weui-cell__bd"><input {$info['name']?'readonly':''} value="{$info.name}" type="text" name="name" id="name" class="weui-input" placeholder="本人真实姓名" required></div>
                    <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div></div>
                <div class="weui-cell weui-cell_active">
                    <div class="weui-cell__hd"><label class="weui-label">身份证</label></div>
                    <div class="weui-cell__bd"><input {$info['name']?'readonly':''}  value="{$info.idcard}" type="text" name="idcard"  id="idcard" class="weui-input" maxlength="18" required pattern="REG_IDNUM" placeholder="本人身份证" emptyTips="请输入身份证号码" notMatchTips="请输入正确的身份证号码"></div>
                    <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div>
                </div>
                <div class="weui-cell weui-cell_active">
                    <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
                    <div class="weui-cell__bd"><input {$info['name']?'readonly':''}  value="{$info.phone}" required name="phone" id="phone" class="weui-input" type="tel" maxlength="11" pattern="REG_PHONE"  placeholder="手机号码" emptyTips="请输入手机号" notMatchTips="请输入正确的手机号" ></div>
                    <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div>
                </div>
            </div>
        </div>
    </div>
    <div class="cards">
        <div class="weui-cells__group weui-cells__group_form">
            <div class="weui-cells__title">信息登记</div>
            <div class="weui-cells weui-cells_form">
                <div class="weui-cells_radio">
                    <label class="weui-cell weui-check__label" for="r1">
                        <div class="weui-cell__bd">进去</div>
                        <div class="weui-cell__ft">
                            <input required type="radio" class="weui-check" name="pass_out" value="进" id="r1" tips="请选择进出" {$info.pass_out == '出' || empty($info)?'checked':''}>
                            <span class="weui-icon-checked"></span>
                        </div>
                    </label>
                    <label class="weui-cell weui-check__label" for="r2">
                        <div class="weui-cell__bd">出来</div>
                        <div class="weui-cell__ft">
                            <input type="radio" name="pass_out" class="weui-check" value="出" id="r2" {$info.pass_out == '进'?'checked':''}>
                            <span class="weui-icon-checked"></span>
                        </div>
                    </label>
                </div>
                <div class="weui-cell weui-cell_active">
                    <div class="weui-cell__hd"><label class="weui-label">车牌号</label></div>
                    <div class="weui-cell__bd"><input type="text" name="car_num" id="car_num" class="weui-input" placeholder="车牌号" value="{$info.car_num}" ></div>
                </div>
                <div class="weui-cell weui-cell_active">
                    <div class="weui-cell__hd"><label class="weui-label">实测体温</label></div>
                    <div class="weui-cell__bd"><input required type="number" name="temperature" id="temperature" class="weui-input" placeholder="当前实测体温" ></div>
                    <div class="weui-cell__ft"><i class="weui-icon-warn"></i></div>
                </div>
                <div class="weui-cell weui-cell_active weui-cell_switch">
                    <div class="weui-cell__bd">近期是否接触疫情</div>
                    <div class="weui-cell__ft"><input name="is_danger" class="weui-switch" type="checkbox"></div>
                </div>
                <div class="weui-form__tips-area tips">
                    <p class="weui-form__tips">两周内是否有湖北等重点疫情地区往来史、疫情地区人员接触史或与新型冠状病毒感染的肺炎病例有接触史</p>
                </div>
                <div class="weui-cell weui-cell_active">
                    <div class="weui-cell__bd">
                        <textarea name="why" class="weui-textarea" placeholder="简述通行事由" rows="3"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="weui-padding button-sp-area cell weui-btn-area_inline">
        <button id="formSubmitBtn" type="button" class="weui-btn weui-btn_primary">完 成</button>
    </div>
    </form>
    {else}
    <div class="title">免费开通,疫情出入控制信息系统</div>
    <div class="cards mart27">
        <div class="weui-cells__group weui-cells__group_form">
            <div class="weui-form__tips-area tips">
                <p class="weui-form__tips">我司免费提供开通,疫情出入控制信息系统</p>
            </div>
        </div>
    </div>
    <div class="weui-padding button-sp-area cell weui-btn-area_inline"></div>
    {/if}
    <div class="weui-form__tips-area"><p class="weui-form__tips">技术支持 古德科技</p></div>
    <div class="weui-form__extra-area">
        <div class="weui-footer"><p class="weui-footer__links"><a href="javascript:void(0);" class="weui-footer__link">免费开通小程序,助力林州实体商家</a></p>
          <p class="weui-footer__text">开通热线 18567770669 16638329860:</p>
        </div>
    </div>
    </div>
    <div id="success" class="hide">
        <div class="title">{$guard.company}</div>
        <div class="mart27">
            <div class="page__bd" id="history"></div>
        </div>
    </div>
</body>
<script id="history_tpl" type="text/html">
    {literal}
    {{each list value key}}
    <div class="weui-form-preview">
        <div class="weui-form-preview__hd"><div class="weui-form-preview__item"><label class="weui-form-preview__label">进出状态</label><em class="weui-form-preview__value">{{value.pass_out}}</em></div></div>
        <div class="weui-form-preview__bd">
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">姓名</label><span class="weui-form-preview__value">{{value.account.name}}</span></div>
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">手机号</label><span class="weui-form-preview__value">{{value.account.phone}}</span></div>
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">发生时间</label><span class="weui-form-preview__value">{{value.update_time}}</span></div>
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">车牌号</label><span class="weui-form-preview__value">{{value.car_num}}</span></div>
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">体温</label><span class="weui-form-preview__value red">{{value.temperature}}°c</span></div>
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">近期是否接触疫情</label><span class="weui-form-preview__value {{if value.is_danger == 0}}green{{else}}red{{/if}}">{{if value.is_danger == 0}}没有{{else}}接触{{/if}}</span></div>
            <div class="weui-form-preview__item"><label class="weui-form-preview__label">事由</label><span class="weui-form-preview__value">{{value.why}}</span></div>
        </div>
    </div>
    {/literal}
    {{/each}}
</script>
<script type="text/javascript">
    Do('weui', 'fastclick', 'tpl','jform',function () {
        $(function () {FastClick.attach(document.body);});
        var regexp = {
            regexp: {IDNUM: /(?:^\d{15}$)|(?:^\d{18}$)|^\d{17}[\dXx]$/,
            PHONE:/[0-9]{11}/}
	    };
        weui.form.checkIfBlur('#form',regexp);
        $('#formSubmitBtn').click(function(){
            weui.form.validate('#form', function (error) {
                if (!error) {
                    $('#form').ajaxSubmit({dataType:"json",success:function (rel) {
                        if(200 == rel.code){
                            weui.alert(rel.msg);
                            $('#page').hide();
                            $('#success').show();
                            $.ajax({
                                url:"{:urls('guard/index/history',$guard.member_miniapp_id)}",success:function(rel){
                                    $("#history").html(template("history_tpl",{list:rel.data}))
                                }
                            });
                        }else{
                            weui.topTips(rel.msg);
                        }
                    }});
                }
            },regexp);
        });
    });
</script>
</html>