<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="https://www.thymeleaf.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="https://www.thymeleaf.org ">
<head>
    <title>采美365网--医疗美容生活美容正品采购平台</title>
    <template th:replace="components/head-link"></template>
    <link th:href="@{/css/base/center.css(v=${version})}" rel="stylesheet" type="text/css">
    <link th:href="@{/css/base/form.css(v=${version})}" rel="stylesheet" type="text/css">
    <link th:href="@{/css/user-center/address/list.css(v=${version})}" rel="stylesheet" type="text/css">
</head>
<body>
<!-- 引用头部 -->
<template th:replace="components/header"></template>
<!-- 我的地址 -->
<div id="orderPage">
    <div class="navLayout" v-cloak>
        <div v-if="isPC" class="crumbs">
            <span>我的交易</span>
            <span>&gt;</span>
            <span>收货地址管理</span>
        </div>
        <div class="wrap clear">
            <!--左侧导航-->
            <template th:replace="user-center/components/tableft"></template>
            <div class="right">
                <div class="order-header">
                    <div class="header-bt">
                        <p>已保存<span>{{addressList.length}}</span>条地址,还能保存 <span>{{20-(addressList.length)}}</span>条地址</p>
                    </div>
                    <div class="header-button">
                        <a class="btn-server" href="javascript: void(0);" @click="createAddress()">新增地址</a>
                    </div>
                </div>
                <!--loading-->
                <div v-if="isRequset" class="loading">
                    <img src="/img/base/loading.gif">
                </div>
                <div class="container clear" v-else>
                    <div class="section address-none" v-show="isShwoAddModel">
                        <div class="addressWrap">
                            <div class="form">
                                <div class="formLine">
                                    <p class="label"><em>*</em>收货人：</p>
                                    <input type="text" v-model.trim="addressForm.name" placeholder="请输入收货人姓名" :rule="rule.name" maxlength="10" @blur="blurHandle($event)" needverify>
                                    <i class="checked icon mIcon"></i>
                                    <span class="errTips icon mIcon" tips="请输入正确的联系人姓名"></span>
                                </div>
                                <div class="formLine">
                                    <p class="label"><em>*</em>联系方式：</p>
                                    <input type="text" v-model.trim="addressForm.mobile" placeholder="请输入您的常用手机号" :rule="rule.mobile" maxlength="11" @blur="blurHandle($event)" needverify>
                                    <i class="checked icon mIcon"></i>
                                    <span class="errTips icon mIcon" tips="请输入有效电话号码"></span>
                                </div>
                                <div class="formLine">
                                    <p class="label"><em>*</em>联系地址：</p>
                                    <select name="province" v-model="addressForm.provinceId" @change="getCityOptions(addressForm.provinceId)">
                                        <option value="" >请选择</option>
                                        <option v-for="(item ,index) in provinceOptions" :key="index" :value='item.provinceID'>{{item.name}}</option>
                                    </select>
                                    <select name="city" v-model="addressForm.cityId" @change="getTownOptions(addressForm.cityId)">
                                        <option value="" >请选择</option>
                                        <option v-for="(item ,index) in cityOptions" :key="index" :value="item.cityID">{{item.name}}</option>
                                    </select>
                                    <select name="town" v-model="addressForm.townId">
                                        <option value="" >请选择</option>
                                        <option v-for="(item ,index) in townOptions" :key="index" :value="item.townID">{{item.name}}</option>
                                    </select>
                                    <textarea v-model.trim="addressForm.desc" placeholder="建议您如实填写详细地址，例如：街道名称，门牌号码，楼层和房间号等信息"  @blur="blurHandle($event)" needverify></textarea>
                                    <span class="errTips icon mIcon" tips="请输入正确的联系地址"></span>
                                </div>
                                <div class="btnBox">
                                    <div class="group">
                                        <p>
                                            <label class="check"><input v-model="addressForm.default" name="default" type="checkbox">设为默认地址</label>
                                        </p>
                                        <p>
                                            <a class="btn save"  href="javascript:void(0)" @click="saveAddressForm()">保存</a>
                                            <a class="btn con"  href="javascript:void(0)" @click="hideAddressForm()">取消</a>
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="section" v-if="addressList.length > 0">
                        <div class="list" v-for="(item, index) in addressList" :key="index">
                            <div class="list-left">
                                <p><span class="label">收货人:</span>{{item.shouHuoRen}}</p>
                                <p><span class="label">联系方式:</span>{{item.mobile}}</p>
                                <p><span class="label">收货地址:</span><span class="prov">{{item.province}}</span>{{item.city}}{{item.town}}{{item.address}}</p>
                            </div>
                            <div class="list-right  mfbt">
                                <div class="list-defalut">
                                    <template v-if="item.defaultFlag == 1">
                                        <i class="icon mIcon"></i>
                                        <span class="span-s">默认地址</span>
                                    </template>
                                    <a v-else @click="setDefaultAddress(item.addressID)" href="javascript:void(0)">设为默认地址</a>
                                </div>
                                <div class="list-button">
                                    <a class="list-btn ico" href="javascript:void(0)" @click.stop="deleteAddress(item.addressID)">
                                        <i class="icon mIcon">
                                            <span>删除</span>
                                        </i>
                                    </a>
                                    <a class="list-btn" href="javascript:void(0)" @click.stop="editAddress(item)">修改</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--数据为空-->
                    <div v-else class="empty">
                        <img src="/img/common/empty.png">
                        <div class="msg"><p>暂无数据</p></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 引入底部 -->
<template th:replace="components/footer"></template>
<template th:replace="components/foot-link"></template>
<script charset="utf-8" type="text/javascript" th:src="@{/js/center.js(v=${version})}"></script>
<script charset="utf-8" type="text/javascript" th:src="@{/js/common/serviceapi/order.service.js(v=${version})}"></script>
<script charset="utf-8" type="text/javascript" th:src="@{/js/user-center/address/list.js(v=${version})}"></script>
</body>
</html>
