{{include file="public/header" /}}

<!-- header top nav -->
{{include file="public/header_top_nav" /}}

<!-- search -->
{{include file="public/nav_search" /}}

<!-- header nav -->
{{include file="public/header_nav" /}}

<!-- goods category -->
{{include file="public/goods_category" /}}

<!-- conntent start  -->
<div class="am-g my-content user-register-container" {{if !empty($user_register_bg_images)}}style="background: #FAFAFA url({{:AttachmentPathViewHandle($user_register_bg_images)}});"{{/if}}>
    <div class="am-container">
        <!-- 用户注册页面顶部钩子 -->
        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
            <div class="plugins-tag">
                <span>plugins_view_user_reg_info_top</span>
            </div>
        {{/if}}
        {{if !empty($plugins_view_user_reg_info_top_data) and is_array($plugins_view_user_reg_info_top_data)}}
            {{foreach $plugins_view_user_reg_info_top_data as $hook}}
                {{if is_string($hook) or is_int($hook)}}
                    {{$hook|raw}}
                {{/if}}
            {{/foreach}}
        {{/if}}

        <div class="am-u-sm-12 am-u-md-6 am-u-lg-5 am-u-sm-centered">
            <div class="register-container">
                <div class="register-top">
                    {{if !empty($home_user_login_type)}}
                        <span>我已经注册，现在就</span>
                        <a href="{{:MyUrl('index/user/logininfo')}}" class="am-btn am-btn-secondary am-btn-xs am-radius">登录</a>
                    {{/if}}

                    <!-- 用户注册页面钩子 -->
                    {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                        <div class="plugins-tag">
                            <span>plugins_view_user_reg_info</span>
                        </div>
                    {{/if}}
                    {{if !empty($plugins_view_user_reg_info_data) and is_array($plugins_view_user_reg_info_data)}}
                        {{foreach $plugins_view_user_reg_info_data as $hook}}
                            {{if is_string($hook) or is_int($hook)}}
                                {{$hook|raw}}
                            {{/if}}
                        {{/foreach}}
                    {{/if}}
                </div>

                <div class="register-content">
                    {{if !empty($home_user_reg_type)}}
                        <div data-am-widget="tabs" class="am-tabs am-tabs-d2" data-am-tabs="{noSwipe: 1}">
                            <ul class="am-tabs-nav am-cf">
                                {{if in_array('username', $home_user_reg_type)}}
                                    <li class="am-active"><a href="[data-tab-panel-0]">账号注册</a></li>
                                {{/if}}
                                {{if in_array('sms', $home_user_reg_type)}}
                                    <li class="{{if !in_array('username', $home_user_reg_type)}}am-active{{/if}}"><a href="[data-tab-panel-1]">手机注册</a></li>
                                {{/if}}
                                {{if in_array('email', $home_user_reg_type)}}
                                    <li class="{{if !in_array('username', $home_user_reg_type) and !in_array('sms', $home_user_reg_type)}}am-active{{/if}}"><a href="[data-tab-panel-2]">邮箱注册</a></li>
                                {{/if}}
                            </ul>
                            <div class="am-tabs-bd am-padding-bottom-sm">
                                {{if in_array('username', $home_user_reg_type)}}
                                    <div data-tab-panel-0 class="am-tab-panel am-active">
                                        <!-- form start -->
                                        <form class="am-form form-validation-username" method="post" action="{{:MyUrl('index/user/reg')}}" request-type="ajax-fun" request-value="RegisterSuccessBack">
                                            <div class="am-form-group am-form-group-refreshing business-form-block">
                                                <label>用户名</label>
                                                <input type="text" name="accounts" class="am-radius" placeholder="请使用字母、数字、下划线 2~18 个字符" pattern="{{:lang('common_regex_username')}}" data-validation-message="用户名格式由 字母数字下划线 2~18 个字符" required />
                                            </div>

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-xs">
                                                <label>设置登录密码</label>
                                                <div class="am-input-group am-input-group-sm">
                                                    <input type="password" name="pwd" class="am-radius" placeholder="设置登录密码" pattern="{{:lang('common_regex_pwd')}}" data-validation-message="密码格式 6~18 个字符之间" required />
                                                    <span class="am-input-group-btn">
                                                        <button class="am-btn am-btn-default am-radius am-icon-eye eye-submit" type="button"></button>
                                                    </span>
                                                </div>
                                            </div>

                                            {{if MyC('home_user_register_img_verify_state') eq 1}}
                                                <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-xs">
                                                    <label>验证码</label>
                                                    <div class="am-input-group am-input-group-sm">
                                                        <input type="text" name="verify" class="am-radius" placeholder="验证码" minlength="4" maxlength="4" data-validation-message="请输入图片验证码" required />
                                                        <span class="am-input-group-btn">
                                                            <span class="am-btn am-btn-default am-radius form-verify">
                                                                <img src="{{:MyUrl('index/user/userverifyentry', ['type'=>'user_reg'])}}" class="am-radius c-p" id="form-verify-img" onClick="this.src=this.src+'#'+Math.random();" />
                                                                <a href="javascript:;" class="form-verify-tips" onClick="document.getElementById('form-verify-img').src='{{:MyUrl('index/user/userverifyentry', ['type'=>'user_reg'])}}#'+Math.random();">更换一张</a>
                                                            </span>
                                                        </span>
                                                    </div>
                                                </div>
                                            {{/if}}

                                            {{if MyC('home_is_enable_userregister_agreement') eq 1}}
                                                <div class="agreement am-padding-horizontal-sm">
                                                    <label class="am-checkbox am-success c-p">
                                                        <input type="checkbox" value="1" name="is_agree_agreement" data-validation-message="请同意注册协议" data-am-ucheck required /> 阅读并同意
                                                    </label>
                                                    <a href="{{:MyUrl('index/agreement/index', ['document'=>'userregister'])}}" target="_blank">《服务协议》</a>
                                                </div>
                                            {{/if}}
                                            
                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-sm">
                                                <input type="hidden" name="type" value="username" />
                                                <button type="submit" class="am-btn am-btn-primary am-btn-block am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">注册</button>
                                            </div>
                                        </form>
                                        <!-- form end -->
                                    </div>
                                {{/if}}
                                {{if in_array('sms', $home_user_reg_type)}}
                                    <div data-tab-panel-1 class="am-tab-panel {{if !in_array('username', $home_user_reg_type)}}am-active{{/if}}">
                                        <!-- form start -->
                                        <form class="am-form form-validation-sms" method="post" action="{{:MyUrl('index/user/reg')}}" request-type="ajax-fun" request-value="RegisterSuccessBack">
                                            <div class="am-form-group am-form-group-refreshing business-form-block">
                                                <label>手机号码</label>
                                                <input type="text" name="accounts" class="am-radius" placeholder="请输入手机号码" pattern="{{:lang('common_regex_mobile')}}" data-validation-message="手机号码格式错误" required />
                                            </div>

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-xs">
                                                <label>验证码</label>
                                                <div class="am-input-group am-input-group-sm">
                                                    <input type="number" name="verify" class="am-radius" placeholder="验证码" minlength="4" maxlength="4" data-validation-message="验证码格式 4 位数字" required />
                                                    <span class="am-input-group-btn">
                                                        <button class="am-btn am-btn-default am-radius btn-loading-example verify-submit" type="button" data-am-loading="{spinner:'circle-o-notch', loadingText:'发送中...'}" data-url="{{:MyUrl('index/user/regverifysend')}}" data-verify="{{:MyC('common_img_verify_state')}}" data-text="获取验证码" data-send-text="还有 {time} 秒" data-time="{{:MyC('common_verify_interval_time', 30, true)}}" data-form-tag="form.form-validation-sms">获取验证码</button>
                                                    </span>
                                                </div>
                                            </div>

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-xs">
                                                <label>设置登录密码</label>
                                                <div class="am-input-group am-input-group-sm">
                                                    <input type="password" name="pwd" class="am-radius" placeholder="设置登录密码" pattern="{{:lang('common_regex_pwd')}}" data-validation-message="密码格式 6~18 个字符之间" required />
                                                    <span class="am-input-group-btn">
                                                        <button class="am-btn am-btn-default am-radius am-icon-eye eye-submit" type="button"></button>
                                                    </span>
                                                </div>
                                            </div>

                                            {{if MyC('home_is_enable_userregister_agreement') eq 1}}
                                                <div class="agreement am-padding-horizontal-sm">
                                                    <label class="am-checkbox am-success c-p">
                                                        <input type="checkbox" value="1" name="is_agree_agreement" data-validation-message="请同意注册协议" data-am-ucheck required /> 阅读并同意
                                                    </label>
                                                    <a href="{{:MyUrl('index/agreement/index', ['document'=>'userregister'])}}" target="_blank">《服务协议》</a>
                                                </div>
                                            {{/if}}

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-sm">
                                                <input type="hidden" name="type" value="sms" />
                                                <button type="submit" class="am-btn am-btn-primary am-btn-block am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">注册</button>
                                            </div>
                                        </form>
                                        <!-- form end -->
                                    </div>
                                {{/if}}
                                {{if in_array('email', $home_user_reg_type)}}
                                    <div data-tab-panel-2 class="am-tab-panel {{if !in_array('username', $home_user_reg_type) and !in_array('sms', $home_user_reg_type)}}am-active{{/if}}">
                                        <!-- form start -->
                                        <form class="am-form form-validation-email" method="post" action="{{:MyUrl('index/user/reg')}}" request-type="ajax-fun" request-value="RegisterSuccessBack">
                                            <div class="am-form-group am-form-group-refreshing business-form-block">
                                                <label>电子邮箱</label>
                                                <input type="email" name="accounts" class="am-radius" placeholder="请输入电子邮箱" data-validation-message="电子邮箱格式错误" required />
                                            </div>

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-xs">
                                                <label>验证码</label>
                                                <div class="am-input-group am-input-group-sm">
                                                    <input type="number" name="verify" class="am-radius" placeholder="验证码" minlength="4" maxlength="4" data-validation-message="验证码格式 4 位数字" required />
                                                    <span class="am-input-group-btn">
                                                        <button class="am-btn am-btn-default am-radius btn-loading-example verify-submit" type="button" data-am-loading="{spinner:'circle-o-notch', loadingText:'发送中...'}" data-url="{{:MyUrl('index/user/regverifysend')}}" data-verify="{{:MyC('common_img_verify_state')}}" data-text="获取验证码" data-send-text="还有 {time} 秒" data-time="{{:MyC('common_verify_interval_time', 30, true)}}" data-form-tag="form.form-validation-email">获取验证码</button>
                                                    </span>
                                                </div>
                                            </div>

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-xs">
                                                <label>设置登录密码</label>
                                                <div class="am-input-group am-input-group-sm">
                                                    <input type="password" name="pwd" class="am-radius" placeholder="设置登录密码" pattern="{{:lang('common_regex_pwd')}}" data-validation-message="密码格式 6~18 个字符之间" required />
                                                    <span class="am-input-group-btn">
                                                        <button class="am-btn am-btn-default am-radius am-icon-eye eye-submit" type="button"></button>
                                                    </span>
                                                </div>
                                            </div>

                                            {{if MyC('home_is_enable_userregister_agreement') eq 1}}
                                                <div class="agreement am-padding-horizontal-sm">
                                                    <label class="am-checkbox am-success c-p">
                                                        <input type="checkbox" value="1" name="is_agree_agreement" data-validation-message="请同意注册协议" data-am-ucheck required /> 阅读并同意
                                                    </label>
                                                    <a href="{{:MyUrl('index/agreement/index', ['document'=>'userregister'])}}" target="_blank">《服务协议》</a>
                                                </div>
                                            {{/if}}

                                            <div class="am-form-group am-form-group-refreshing business-form-block am-margin-top-sm">
                                                <input type="hidden" name="type" value="email" />
                                                <button type="submit" class="am-btn am-btn-primary am-btn-block am-radius am-btn-sm btn-loading-example" data-am-loading="{loadingText: '处理中...'}">注册</button>
                                            </div>
                                        </form>
                                        <!-- form end -->
                                    </div>
                                {{/if}}
                            </div>
                        </div>
                    {{else /}}
                        <div class="am-text-center am-padding-vertical-lg register-close"><i class="am-icon-warning"></i> 暂时关闭了注册</div>
                    {{/if}}
                </div>
            </div>
        </div>

        <!-- 用户注册页面底部钩子 -->
        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
            <div class="plugins-tag">
                <span>plugins_view_user_reg_info_bottom</span>
            </div>
        {{/if}}
        {{if !empty($plugins_view_user_reg_info_bottom_data) and is_array($plugins_view_user_reg_info_bottom_data)}}
            {{foreach $plugins_view_user_reg_info_bottom_data as $hook}}
                {{if is_string($hook) or is_int($hook)}}
                    {{$hook|raw}}
                {{/if}}
            {{/foreach}}
        {{/if}}
    </div>
</div>
<!-- conntent end  -->

<!-- 图片验证码  -->
{{if MyC('common_img_verify_state') eq 1}}
    {{include file="user/images_verify" type="user_reg" /}}
{{/if}}

{{include file="public/footer" /}}

<script type="text/javascript">
// 注册成功回调
function RegisterSuccessBack(e)
{
    if(e.code == 0)
    {
        $.AMUI.progress.done();
        Prompt(e.msg, 'success');

        // 登录返回html处理
        if((e.data.body_html || null) != null)
        {
            $('body').append(e.data.body_html);
        }

        setTimeout(function()
        {
            window.location.href = '{{$referer_url}}';
        }, 1500);
    } else {
        $('.register-container form.am-form').find('button[type="submit"]').button('reset');
        $.AMUI.progress.done();
        Prompt(e.msg);
    }
}
</script>