{{:ModuleInclude('public/header')}}

<!-- conntent start  -->
<div class="am-padding-sm">
    <!-- form start -->
    <form class="am-form form-validation am-form-full-screen am-form-popup-fixed" method="post" action="{{:MyUrl('index/useraddress/save')}}" request-type="ajax-reload" request-value="parent">
        <div class="am-form-group">
            <label>{{:MyLang('common_service.useraddress.form_item_name')}}<span class="am-form-group-label-tips-must">*</span></label>
            <input type="text" name="name" placeholder="{{:MyLang('common_service.useraddress.form_item_name_message')}}" minlength="1" maxlength="80" data-validation-message="{{:MyLang('common_service.useraddress.form_item_name_message')}}" class="am-radius" {{if !empty($data['name'])}} value="{{$data.name}}"{{/if}} required />
        </div>
        <div class="am-form-group">
            <label>{{:MyLang('common_service.useraddress.form_item_alias')}}</label>
            <input type="text" name="alias" placeholder="{{:MyLang('common_service.useraddress.form_item_alias_message')}}" minlength="0" maxlength="16" data-validation-message="{{:MyLang('common_service.useraddress.form_item_alias_message')}}" class="am-radius" {{if !empty($data['alias'])}} value="{{$data.alias}}"{{/if}} />
        </div>

        <div class="am-form-group">
            <label>{{:MyLang('common_service.useraddress.form_item_tel')}}<span class="am-form-group-label-tips-must">*</span></label>
            <input type="text" name="tel" placeholder="{{:MyLang('common_service.useraddress.form_item_tel')}}" minlength="6" maxlength="30" data-validation-message="{{:MyLang('common_service.useraddress.form_item_tel_message')}}" class="am-radius" {{if !empty($data['tel'])}} value="{{$data.tel}}"{{/if}} required />
        </div>

        {{:ModuleInclude('lib/region_linkage')}}
        <div class="am-form-group">
            <label>{{:MyLang('common_service.useraddress.form_item_address')}}<span class="am-form-group-label-tips-must">*</span></label>
            {{if MyC('home_user_address_map_status') eq 1}}
                <input type="hidden" name="lng" id="form-lng" {{if !empty($data['lng'])}} value="{{$data.lng}}"{{/if}} />
                <input type="hidden" name="lat" id="form-lat" {{if !empty($data['lat'])}} value="{{$data.lat}}"{{/if}} />
                <div class="am-input-group am-input-group-sm">
                    <input type="text" name="address" id="form-address" placeholder="{{:MyLang('common_service.useraddress.form_item_address_message')}}" minlength="2" maxlength="80" data-validation-message="{{:MyLang('common_service.useraddress.form_item_address_message')}}" class="am-radius am-form-field" {{if !empty($data['address'])}} value="{{$data.address}}"{{/if}} required />
                    <span class="am-input-group-btn">
                        <button type="button" class="am-btn am-btn-default am-radius" id="map-location-submit">
                            <i class="am-icon-map-marker"></i>
                            <span>{{:MyLang('location_title')}}</span>
                        </button>
                    </span>
                </div>
                <div id="map" data-level="17" class="am-margin-top-xs"></div>
            {{else /}}
                <input type="text" name="address" id="form-address" placeholder="{{:MyLang('common_service.useraddress.form_item_address_message')}}" minlength="2" maxlength="80" data-validation-message="{{:MyLang('common_service.useraddress.form_item_address_message')}}" class="am-radius" {{if !empty($data['address'])}} value="{{$data.address}}"{{/if}} required />
            {{/if}}
        </div>

        <div class="am-form-group">
            <label class="am-block">{{:MyLang('form_is_default_title')}}</label>
            <input name="is_default" value="1" type="checkbox" data-off-text="{{:MyLang('no_title')}}" data-on-text="{{:MyLang('yes_title')}}" data-size="xs" data-on-color="success" data-off-color="default" data-handle-width="49" data-am-switch {{if isset($data['is_default']) and $data['is_default'] eq 1}}checked="true"{{/if}} />
        </div>
        {{if MyC('home_user_address_idcard_status') eq 1}}
            <div class="am-alert am-alert-secondary">
                <div class="am-form-group">
                    <label>{{:MyLang('common_service.useraddress.form_item_idcard_name')}}<span class="am-form-group-label-tips-must">*</span><span class="am-form-group-label-tips">{{:MyLang('common_service.useraddress.form_item_idcard_name_tips')}}</span></label>
                    <input type="text" name="idcard_name" placeholder="{{:MyLang('common_service.useraddress.form_item_idcard_name')}}" minlength="0" maxlength="30" data-validation-message="{{:MyLang('common_service.useraddress.form_item_idcard_name_message')}}" class="am-radius" {{if !empty($data['idcard_name'])}} value="{{$data.idcard_name}}"{{/if}} required />
                </div>
                <div class="am-form-group">
                    <label>{{:MyLang('common_service.useraddress.form_item_idcard_number')}}<span class="am-form-group-label-tips-must">*</span><span class="am-form-group-label-tips">{{:MyLang('common_service.useraddress.form_item_idcard_number_tips')}}</span></label>
                    <input type="text" name="idcard_number" placeholder="{{:MyLang('common_service.useraddress.form_item_idcard_number')}}" minlength="0" maxlength="18" data-validation-message="{{:MyLang('common_service.useraddress.form_item_idcard_number_message')}}" class="am-radius" {{if !empty($data['idcard_number'])}} value="{{$data.idcard_number}}"{{/if}} required />
                </div>
                <div class="am-form-group plug-file-upload-view">
                    <label>{{:MyLang('common_service.useraddress.form_item_idcard_images')}}<span class="am-form-group-label-tips-must">*</span><span class="am-form-group-label-tips">{{:MyLang('common_service.useraddress.form_item_idcard_images_tips')}}</span></label>
                    <div class="am-nbfc user-address-idcard-images">
                        <div class="item am-fl am-margin-right-main">
                            <ul class="plug-file-upload-view images-idcard_front" data-form-name="idcard_front" data-max-number="1" data-delete="0" data-dialog-type="images">
                                <li>
                                    <input type="text" name="idcard_front" value="{{if !empty($data['idcard_front'])}}{{$data.idcard_front}}{{/if}}" data-validation-message="{{:MyLang('common_service.useraddress.form_item_idcard_front_message')}}" required />
                                    <img src="{{if empty($data['idcard_front'])}}{{:StaticAttachmentUrl('default-idcard-front.jpg')}}{{else /}}{{$data.idcard_front}}{{/if}}" />
                                </li>
                            </ul>
                            <div class="plug-file-upload-submit am-margin-top-sm" data-view-tag="ul.images-idcard_front">+{{:MyLang('common_service.useraddress.form_item_idcard_front_button_name')}}</div>
                        </div>
                        <div class="item am-fl">
                            <ul class="plug-file-upload-view images-idcard_back" data-form-name="idcard_back" data-max-number="1" data-dialog-type="images">
                                <li>
                                    <input type="text" name="idcard_back" value="{{if !empty($data['idcard_back'])}}{{$data.idcard_back}}{{/if}}" data-validation-message="{{:MyLang('common_service.useraddress.form_item_idcard_back_message')}}" required />
                                    <img src="{{if empty($data['idcard_back'])}}{{:StaticAttachmentUrl('default-idcard-back.jpg')}}{{else /}}{{$data.idcard_back}}{{/if}}" />
                                </li>
                            </ul>
                            <div class="plug-file-upload-submit am-margin-top-sm" data-view-tag="ul.images-idcard_back">+{{:MyLang('common_service.useraddress.form_item_idcard_back_button_name')}}</div>
                        </div>
                    </div>
                </div>
            </div>
        {{/if}}

        <div class="am-form-popup-submit">
            <input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
            <button type="button" class="am-btn am-btn-warning am-radius am-btn-xs am-margin-right-lg" data-am-modal-close>
                <i class="am-icon-paint-brush"></i>
                <span>{{:MyLang('cancel_title')}}</span>
            </button>
            <button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText:'{{:MyLang('save_title')}}'}">
                <i class="am-icon-save"></i>
                <span>{{:MyLang('save_title')}}</span>
            </button>
        </div>
    </form>
    <!-- form end -->
</div>
<!-- conntent end  -->

<!-- footer start -->
{{:ModuleInclude('public/footer')}}

<script type="text/javascript">
$(function()
{
    {{if MyC('home_user_address_map_status') eq 1}}
        // 百度地图初始化
        MapInit({{if !empty($data['lng'])}}{{$data['lng']}}{{else /}}116.400244{{/if}},{{if !empty($data['lat'])}}{{$data['lat']}}{{else /}}39.92556{{/if}});
    {{/if}}
});
</script>