<style>
    body { background: #f7f7f7; }
    .login-reg .layui-form-select{ width: 100%; }
</style>

<div class="login login-reg">
    <div class="box">
        <a class="logo" href="{rrz:env name='rrz.cmsurl' /}">
            <img src="{rrz:env name='website.logo' /}"/>
        </a>
        <h1 class="title">{:__('账号注册')}</h1>
        <form class="layui-form" method="post" action="{:U('/user/reg')}">
            <div class="layui-form-item flex">
                <div class="bg-eee w50 tc flex-c cl-999">
                    <i class="layui-icon fb f18">&#xe66f;</i>
                </div>
                <input class="layui-input" type="text" name="user_name" vtype="required" vtips="{:__('用户名不能为空！')}" maxlength="20" autocomplete="off" placeholder="{:__('用户名')}" autofocus/>
            </div>
            <div class="layui-form-item flex">
                <div class="bg-eee w50 tc flex-c cl-999">
                    <i class="layui-icon fb f18">&#xe673;</i>
                </div>
                <input class="layui-input" type="password" name="password" vtype="required" vtips="{:__('密码不能为空！')}" autocomplete="off" placeholder="{:__('登陆密码')}"/>
            </div>
            <div class="layui-form-item flex">
                <div class="bg-eee w50 tc flex-c cl-999">
                    <i class="layui-icon fb f18">&#xe673;</i>
                </div>
                <input class="layui-input" type="password" name="password2" vtype="required" vtips="{:__('重复密码不能为空！')}" autocomplete="off" placeholder="{:__('重复密码')}"/>
            </div>
            {rrz:each list='$rrz.attr_config'}
            {if $item.dtype=='text'}
            <div class="layui-form-item flex">
                <div class="bg-eee w50 tc flex-c cl-999">
                    <i class="layui-icon fb f20"> &#xe609; </i>
                </div>
                <input class="layui-input" type="text" name="attr[{$item.name}]" maxlength="100" {if $item.is_required}vtype="required"{/if} autocomplete="off" placeholder="{:__($item['title'])}"/>
            </div>
            {elseif $item.dtype=='mobile' || $item.dtype=='email'}
            <div class="layui-form-item flex">
                <div class="bg-eee w50 tc flex-c cl-999">
                    <i class="layui-icon fb {$item.dtype=='email'?'f20':'f18'}">{$item.dtype=='mobile'?'&#xe678;':'&#xe618;'}</i>
                </div>
                <input class="layui-input" type="text" name="attr[{$item.name}]" vtype="{$item.dtype}{$item.is_required?'&&required':''}" maxlength="30" autocomplete="off" placeholder="{:__($item['title'])}"/>
            </div>
            {elseif $item.dtype=='multitext' /}
            <div class="layui-form-item">
                <textarea name="attr[{$item.name}]" class="layui-textarea" placeholder="{:__($item['title'])}" {if $item.is_required}vtype="required"{/if}></textarea>
            </div>
            {elseif $item.dtype=='radio' /}
            <fieldset class="layui-elem-field">
                <legend class="f14 fn">{:__($item['title'])}</legend>
                <?php $dfvalueArr = explode('|', $item['dfvalue']); ?>
                <div class="p15 pt10">
                    {foreach $dfvalueArr as $k=>$option}
                    <div>
                        <input type="radio" name="attr[{$item.name}]" value="{$option}" title="{$option}" {if !$k} checked {/if}/>
                    </div>
                    {/foreach}
                </div>
            </fieldset>
            {elseif $item.dtype=='checkbox' /}
            <fieldset class="layui-elem-field">
                <legend class="f14 fn">{:__($item['title'])}</legend>
                <?php $dfvalueArr = explode('|', $item['dfvalue']); ?>
                <div class="p15 pt10">
                    {foreach $dfvalueArr as $option}
                    <div class="layui-inline mt5">
                        <input type="checkbox" name="attr[{$item.name}][]" value="{$option}" title="{$option}"/>
                    </div>
                    {/foreach}
                </div>
            </fieldset>
            {elseif $item.dtype=='select' /}
            <div class="layui-form-item flex">
                <div class="bg-eee w50 tc flex-c cl-999">
                    <i class="layui-icon fb f20">&#xe609;</i>
                </div>
                <?php $dfvalueArr = explode('|', $item['dfvalue']); ?>
                <select name="attr[{$item.name}]" placeholder="{:__($item['title'])}">
                    {foreach $dfvalueArr as $option}
                    <option value="{$option}">{$option}</option>
                    {/foreach}
                </select>
            </div>
            {elseif $item.dtype=='img' /}
            <div class="layui-form-item flex">
                <div class="bg-eee w45 tc flex-c cl-999">
                    <i class="layui-icon fb f16"> &#xe64a; </i>
                </div>
                <input class="layui-input cell" type="text" name="attr[{$item.name}]" lay-upvalue {if $item.is_required}vtype="required"{/if} autocomplete="off" placeholder="{:__($item['title'])}"/>
                <button type="button" class="layui-btn layui-btn-normal w70 p0 tc g-background"  lay-data="{ url: '{:U('/upload/index')}?type=images' }" lay-upload
                        style="height: 43px;line-height: 43px;">{:__('上传')}</button>
            </div>
            {/if}
            {/rrz:each}
            {if $rrz.is_verify}
            <div class="layui-form-item pr flex">
                <div class="bg-eee w45 tc flex-c cl-999">
                    <i class="layui-icon fb f18"> &#xe679; </i>
                </div>
                <input class="layui-input cell" type="text" name="vertify" vtype="required" vtips="{:__('验证码不能为空！')}" autocomplete="off" value="" placeholder="{:__('验证码')}"/>
                <img class="pa js-verify" src="{:U('/user/reg_verify')}" style="right: 3px;top: 3px;height: 36px;">
            </div>
            {/if}
            <div class="tc mt20">
                <button type="submit" class="layui-btn layui-btn-normal layui-btn-lg layui-btn-fluid g-background">{:__('立即注册')}</button>
            </div>
            <div class="text-right mt10 cl-999">
                <a href="{:U('/user/login')}" class="cl-999">{:__('已有账号？')}</a>
            </div>
        </form>
    </div>
</div>


<script>
    $(function () {
        var $verify = $('.js-verify');
        function refshverify() {
            $verify.attr('src', '{:U("/user/reg_verify")}?v=' + Math.floor(Math.random() * 100));
        }
        $verify.on('click', refshverify);

        $('.layui-form').data('callback', function (rs) {
            rs.code == 0 && refshverify();
        });

    });
</script>