<nav
 type="back"
 title="添加地址"
 backgroundColor="{{activeColor ? activeColor : '#ffffff'}}"
 frontColor="{{titleColor?titleColor:'#000000'}}"
></nav>
<view class="container">
	<view class='edit-container'>
		<view class="a-item">
			<view class="icon">
				<image class="img" src="https://file-cloud.fmode.cn/receiver.png"></image>
			</view>
			<view class="input-wrap">
				<input
				 cursor-spacing='100'
				 class='a-input'
				 bindinput="bindinputName"
				 placeholder='姓名'
				 value="{{address.name}}"
				></input>
			</view>
		</view>
		<view class="a-item">
			<view class="icon">
				<image class="img" src="https://file-cloud.fmode.cn/mobile.png"></image>
			</view>
			<view class="input-wrap">
				<input
				 cursor-spacing='100'
				 class='a-input'
				 type='number'
				 bindblur="mobilechange"
				 value="{{address.mobile}}"
				 placeholder='手机号码'
				 maxlength='12'
				></input>
			</view>
		</view>
		<!--
        
        <view class="a-item">
			<view class="icon">
				<image class="img" src="/nova-shop/images/icon/position.png"></image>
			</view>
			<view class="input-wrap" bindtap="chooseRegion">
				<input
				 cursor-spacing='100'
				 class="a-input"
				 value="{{address.full_region}}"
				 disabled="true"
				 placeholder="选择省份、城市、区县"
				/>
				<view class="arrow"></view>
			</view>
		</view>

        -->
		<view class="a-item">
			<view class="icon">
				<image class="img" src="https://file-cloud.fmode.cn/address.png"></image>
			</view>
			<view class="input-wrap" bindtap="showAddress">
				<input
				 cursor-spacing='100'
				 class="a-input"
				 value="{{address.full_region}}"
				 disabled="true"
				 placeholder="选择省份、城市、区县"
				/>
				<view class="arrow"></view>
			</view>
		</view>

		<view class="a-item">
			<view class="icon">
				<image class="img" src="https://file-cloud.fmode.cn/address.png"></image>
			</view>
			<view class="input-wrap">
				<input
				 cursor-spacing='100'
				 class="a-input"
				 bindinput="bindinputAddress"
				 value="{{address.address}}"
				 placeholder="详细地址, 如街道、小区或写字楼等"
				/>
			</view>
		</view>

		<!-- <view class="a-item">
            <view class="default-input {{address.is_default == 1 ? 'checked' : 'unchecked'}}" bindtap="bindIsDefault" >点击设为默认地址</view>
        </view> -->
	</view>
	<view class="default-wrap">
		<view class="text">设为默认地址</view>
		<switch
		 class="switch"
		 checked="{{address.is_default}}"
		 bindchange="switchChange"
		></switch>
	</view>
	<view
	 wx:if="{{type==1}}"
	 class='btn-wrap'
	 bindtap="saveAddress"
	>
		<view class="btn active">新增</view>
	</view>
	<view
	 wx:if="{{type==2}}"
	 class='btn-wrap'
	 bindtap="saveEditAddress"
	>
		<view class="btn active">保存</view>
	</view>
	<view
	 class='delete-wrap'
	 wx:if="{{addressId > 0}}"
	 bindtap='deleteAddress'
	>
		<view class='btn'>删除</view>
	</view>
	<view class="region-select" wx:if="{{openSelectRegion}}">
		<view class="hd">
			<view class="region-selected">
				<view
				 class="item {{item.id == 0 ? 'disabled' : ''}} {{(regionType -1) === index ? 'selected' : ''}}"
				 bindtap="selectRegionType"
				 data-region-type-index="{{index}}"
				 wx:for="{{selectRegionList}}"
				 wx:key="id"
				>{{item.name}}
				</view>
			</view>
			<view class="done {{selectRegionDone ? '' : 'disabled'}}" bindtap="doneSelectRegion">确定</view>
		</view>
		<view class="bd">
			<scroll-view scroll-y class="region-list">
				<view
				 class="item {{item.selected ? 'selected' : ''}}"
				 bindtap="selectRegion"
				 data-region-index="{{index}}"
				 wx:for="{{regionList}}"
				 wx:key="id"
				>{{item.name}}
				</view>
			</scroll-view>
		</view>
	</view>
</view>
<view
 class="bg-mask"
 bindtap="cancelSelectRegion"
 wx:if="{{openSelectRegion}}"
></view>

<van-popup
 show="{{ isAddress }}"
 closeable
 position="bottom"
 custom-style="height: 20%"
 bind:close="onClose"
>

	<view style="width:100%;position:fixed;bottom:0;left:0;z-index:10000;height:500rpx;background-color:white">
		<!-- 仿原生picker的“确定”和“取消”按钮 -->
		<view style="display:flex;width:100%;height:100%">
			<view style="position: absolute;top:0;width:100%;height:100rpx;z-index:1000000;display:flex;justify-content:space-between;align-items:center;">
				<view style="width:calc(100% / 3);text-align:center;color:rgba(0,0,0,.6);font-size:28rpx" bindtap="onClose">取消
				</view>
				<view style="width:calc(100% / 3);text-align:center;color:#ff3456;font-size:28rpx" bindtap="confirm">确定
				</view>
			</view>

			<picker-view
			 indicator-style="height: 200rpx;"
			 style="width: 100%;height: 300rpx;text-align: center;margin-top:150rpx"
			 value="{{pIndex}}"
			 bindchange="changeProvince"
			>
				<picker-view-column>
					<view
					 wx:for="{{placeArray}}"
					 wx:key="name"
					 style="line-height: 77rpx"
					>{{item.name}}
					</view>
				</picker-view-column>
			</picker-view>
			<picker-view
			 indicator-style="height: 200rpx;"
			 style="width: 100%;height: 300rpx;text-align: center;margin-top:150rpx"
			 value="{{cIndex}}"
			 bindchange="changeCity"
			>
				<picker-view-column>
					<view
					 wx:for="{{placeArray[pIndex].city}}"
					 wx:key="name"
					 style="line-height: 77rpx"
					>{{item.name}}
					</view>
				</picker-view-column>
			</picker-view>
			<picker-view
			 indicator-style="height: 200rpx;"
			 style="width: 100%;height: 300rpx;text-align: center;margin-top:150rpx"
			 value="{{aIndex}}"
			 bindchange="changeArea"
			>
				<picker-view-column>
					<view
					 wx:for="{{placeArray[pIndex].city[cIndex].area}}"
					 wx:key="*this"
					 style="line-height: 77rpx"
					>{{item}}
					</view>
				</picker-view-column>
			</picker-view>

		</view>
	</view>
</van-popup>

