<template>
	<view class="search-address-page">
		<!-- 自定义导航栏 -->
		<custom-navbar title="选择地址" :showBack="true" backgroundColor="#FFFFFF"></custom-navbar>

		<!-- 搜索框 -->
		<!-- <view class="search-container">
			<text class="search-container-text" @click="goSelectCity">{{ city.name }}</text>
			<search-box v-model="searchKeyword" placeholder="请输入地址" width="571rpx" height="68rpx"
				border="1px solid #E8101E" style="padding: 0;" @confirm="onSearch" :showBack="false"></search-box>
		</view> -->
		<view class="search-container">
			<text class="search-container-text" @click="goSelectCity">
				{{ city.name }}
			</text>
			<image src="/static/images/Fill.jpg" mode="aspectFit" class="text-img"></image>
			<view class="address-header" @click="goSelectAddress">
				<image src="/static/images/search_1.png" mode="aspectFit" class="search-icon"></image>
				<text class="search-text">请输入你的服务地址</text>
			</view>
		</view>

		<view class="current-locate">
			<view class="current-locate__heard">
				<image src="/static/images/locate.jpg" mode="aspectFit" class="current-locate__heard__img"></image>
				<text class="current-locate__heard__text">当前定位</text>
			</view>
			<view class="current-locate__contact">
				<text class="current-locate__contact__left" @click="selectNowAdress(nowCity)">{{nowAddress}}</text>
				<image class="current-locate__contact__refresh" src="/static/images/refresh.jpg" mode="aspectFit"
					v-if="isLocation" @click="refreshAdress"></image>
				<text class="current-locate__contact__right" @click="startLocate" v-else>开启定位</text>

			</view>
		</view>


		<!-- 地图容器 -->
		<!-- <view class="map-container" v-if="showMap">
		
      <map 
        id="map"
        class="map"
        :latitude="latitude"
        :longitude="longitude"
        :markers="markers"
		scale="19"
        @tap="onMapTap"
		@regionchange="changeMap"
      ></map>
    </view> -->
		<!-- 地址列表 -->
		<scroll-view scroll-y class="address-list" :style="'height: ' + listHeight + 'px'" v-if="searchResults">
			<view class="address-list-box address-list__cut" v-if="addressList.length>0">
				<view class="address-list__heard" v-if="addressList.length>0">
					<view class="address-list__heard__left">
						<image src="/static/images/locate.jpg" mode="aspectFit" class="address-list__heard__left__img">
						</image>
						<text class="address-list__heard__left__text">常用位置</text>
					</view>
					<image src="/static/images/revise.png" mode="aspectFit" class="address-list__heard__img"
						@click="goList"></image>
				</view>

				<view class="address-item" v-for="(item, index) in addressList" :key="`${index}_a`"
					@click="selectCommonAddress(item)">

					<view class="address-info">
						<view class="address-info__user">
							<view v-if="item.is_default==1" class="address-default">
								<text class="address-default__text">默认</text>
							</view>

							<text class="address-name">{{item.name}}</text>
							<text class="address-name">{{item.call_phone}}</text>
						</view>
						<text class="address-detail">{{item.server_address}}</text>
					</view>
				</view>
			</view>

			<view class="address-list-box ">
				<view class="address-list__heard">
					<view class="address-list__heard__left">
						<image src="/static/images/locate.jpg" mode="aspectFit" class="address-list__heard__left__img">
						</image>
						<text class="address-list__heard__left__text">附近地址</text>
					</view>
				</view>

				<view class="address-item" v-for="(item, index) in searchResults" :key="index"
					@click="selectAddress(item)">

					<view class="address-info">
						<view class="address-info__left">
							<!-- <view class="address-default"
								v-if="userAdress.longitude == item.longitude && userAdress.latitude == item.latitude">
								<text class="address-default__text">当前</text>
							</view> -->

							<text class="address-name">{{item.name}}</text>
						</view>

						<text class="address-detail">{{item.address}}</text>
					</view>
					<view class="address-distance" v-if="item.distance">
						<text class="distance-text">{{item.distance}}m</text>
					</view>
				</view>
			</view>
		</scroll-view>

		<!-- 空状态 -->
		<view class="empty-state" v-else>
			<image src="/static/images/empty.png" class="empty-icon"></image>
			<text class="empty-text">未找到相关地址</text>
		</view>

		<!-- 获取权限提示匡内容 -->
		<view class="permission" :class="{ transform: isShowPer }">
			<text class="per-tit">美融融plus 对精确定位权限申请说明</text>
			<text class="per-cont">便于您使用该功能获取您附近的手艺人以及店铺下的服务内容。</text>
		</view>

	</view>
</template>
<script>
	import searchBox from '@/components/search/search-box.vue'
	import request from '@/utils/request'
	import permissionUtils from '../../utils/per.js'
	import ChinaCitys from '../../static/data/newChinaCitys.json'
	import pinyin from 'js-pinyin'
	import locationService from '../../utils/locationService.js'
	export default {
		components: {
			searchBox
		},
		data() {
			return {
				firstRun: true, //是否第一次进入
				userAdress: uni.getStorageSync('userAdrees'), //当前定位
				nowAddress: '开启后才能看到周边服务',
				nowCity: [],
				isLocation: false, //是否开启定位
				isShowPer: false,
				noClick: true,
				addressList: [],
				searchKeyword: '',
				searchResults: [],
				showMap: true,
				latitude: 0, // 38.351942
				longitude: 0, // 117.320266
				markers: [],
				currentDistance: '0m',
				pageHeight: 0,
				listHeight: 0,
				city: {
					center: '',
					name: ''
				},
			}
		},
		onShow() {
			//判断缓存中是否存有城市数据
			let searchCity = uni.getStorageSync('searchCity')
			// 获取当前位置
			this.getCurrentLocation()
		},
		async onLoad() {
			
			// //城市转化
			// //引入jspinyin
			// let pinyin = require('js-pinyin');
			// //配置jspinyin
			// pinyin.setOptions({
			// 	checkPolyphone: false,
			// 	charCase: 0
			// });
			// const pinyinMap = {
			// 	'A': [],
			// 	'B': [],
			// 	'C': [],
			// 	'D': [],
			// 	'E': [],
			// 	'F': [],
			// 	'G': [],
			// 	'H': [],
			// 	'I': [],
			// 	'J': [],
			// 	'K': [],
			// 	'L': [],
			// 	'M': [],
			// 	'N': [],
			// 	'O': [],
			// 	'P': [],
			// 	'Q': [],
			// 	'R': [],
			// 	'S': [],
			// 	'T': [],
			// 	'U': [],
			// 	'V': [],
			// 	'W': [],
			// 	'X': [],
			// 	'Y': [],
			// 	'Z': []
			// }
			// ChinaCitys.districts[0].districts.forEach((item) => {
			// 	if (item.name == '台湾省') {
			// 		let fistName = item.name.charAt(0)
			// 		let cityObj = {
			// 			"name": '台湾',
			// 			"areaId": item.adcode,
			// 			"center": item.center,
			// 			"citycode": item.citycode,
			// 		}
			// 		pinyinMap[pinyin.getFullChars(fistName).charAt(0)].push(cityObj)
			// 	} else if (item.name == '香港特别行政区') {
			// 		let fistName = item.name.charAt(0)
			// 		let cityObj = {
			// 			"name": '香港',
			// 			"adcode": item.adcode,
			// 			"center": item.center,
			// 			"citycode": item.citycode,
			// 		}
			// 		pinyinMap[pinyin.getFullChars(fistName).charAt(0)].push(cityObj)
			// 	} else if (item.name == '澳门特别行政区') {
			// 		let fistName = item.name.charAt(0)
			// 		let cityObj = {
			// 			"name": '澳门',
			// 			"adcode": item.adcode,
			// 			"center": item.center,
			// 			"citycode": item.citycode,
			// 		}
			// 		pinyinMap[pinyin.getFullChars(fistName).charAt(0)].push(cityObj)
			// 	} else if (item.name == '重庆市') {
			// 		let fistName = item.name.charAt(0)
			// 		let cityObj = {
			// 			"name": '重庆',
			// 			"adcode": item.adcode,
			// 			"center": item.center,
			// 			"citycode": item.citycode,
			// 		}
			// 		pinyinMap[pinyin.getFullChars(fistName).charAt(0)].push(cityObj)
			// 	} else if (item.name == '天津市') {
			// 		let fistName = item.name.charAt(0)
			// 		let cityObj = {
			// 			"name": '天津',
			// 			"adcode": item.adcode,
			// 			"center": item.center,
			// 			"citycode": item.citycode,
			// 		}
			// 		pinyinMap[pinyin.getFullChars(fistName).charAt(0)].push(cityObj)
			// 	}else{
			// 		item.districts.forEach(item2 => {
			// 			let fistName = item2.name.charAt(0)
			// 			if (item2.name.slice(-1) == '市') {
			// 				item2.name = item2.name.slice(0, -1)
			// 			}
			// 			let cityObj = {
			// 				"name": item2.name,
			// 				"adcode": item2.adcode,
			// 				"center": item2.center,
			// 				"citycode": item2.citycode,
			// 			}
			// 			pinyinMap[pinyin.getFullChars(fistName).charAt(0)].push(cityObj)
			// 		})
			// 	}
			// })
			// for(let key in pinyinMap){
			// 	if(pinyinMap[key].length == 0){
			// 		delete pinyinMap[key]
			// 	}
			// }
			if (!uni.getStorageSync('startLocate')) {
				this.startLocate()
			}

			//根据是否有定位权限赋值
			if (this.$store.state.isLocation) {
				this.isLocation = true
				let userAdrees = uni.getStorageSync('userAdrees')
				// if (userAdrees) {
				// 	this.nowAddress = userAdrees.address
				// 	this.nowCity = userAdrees
				// } else {
				// 	this.nowAddress = getApp().globalData.address
				// 	this.nowCity = getApp().globalData
				// }

			}
			// 获取视图高度
			this.pageHeight = uni.getWindowInfo().safeArea.height;
			this.listHeight = parseInt(this.pageHeight) - 44 - 145
			//获取常用地址
			this.getAddressList()
		},
		methods: {
			// 显示权限说明弹窗
			showPermissionDialog(title, content) {
				return new Promise((resolve) => {
					uni.showModal({
						title,
						content,
						confirmText: '去开启',
						success(res) {
							resolve(res.confirm);
						}
					});
				});
			},
			//开启定位
			async startLocate() {
				//存储是否第一次开启定位

				console.log('this.granted', this.granted)
				const systemInfo = uni.getSystemInfoSync()
				console.log(systemInfo.platform)
				let permission = '';
				if (systemInfo.platform === 'ios') {
					permission = 'location'
				} else {
					permission = 'android.permission.ACCESS_FINE_LOCATION'
				}

				const firstRequest = !plus.storage.getItem(`perm_${permission}`)
				if (firstRequest) {
					this.isShowPer = true;
				}

				// 1. 检查权限
				const {
					granted
				} = await permissionUtils.checkPermission('location', '需要位置权限用于推荐附近服务');
				console.log('granted==============', granted)
				if (granted) {
					if (this.isShowPer || plus.storage.getItem(`perm_${permission}_no`)) {
						// this.getLocationCont();
					} else {
						// uni.navigateTo({
						// 	url: '/pages/address/search'
						// })
					}
					this.isShowPer = false;
					uni.setStorageSync('startLocate', 1)
					return;
				}


				this.isShowPer = false;
				if (!uni.getStorageSync('startLocate')) {
					uni.setStorageSync('startLocate', 1)
					return;
				}
				// 2. 显示权限说明弹窗
				const confirm = await this.showPermissionDialog(
					'位置权限申请',
					'我们需要位置权限，用于为您推荐附近服务'
				);

				if (!confirm) return;

				// 3. 请求权限
				const result = await permissionUtils.requestPermission('location', '需要位置权限用于推荐附近服务');
				if (result) {
					if (this.isShowPer || plus.storage.getItem(`perm_${permission}_no`)) {

						// this.getLocationCont();
					} else {
						// uni.navigateTo({
						// 	url: '/pages/address/search'
						// })
					}
				} else {
					locationService.openAppSettings();
					// uni.showToast({ title: '相机权限被拒绝', icon: 'none' });
				}
			},
			// 获取地址列表
			getAddressList() {
				// TODO: 调用接口获取地址列表
				// this.addressList = res.data
				if (uni.getStorageSync('refreshToken')) {
					request.post('/user/addresslist', {
						id: this.id
					}).then(res => {
						this.addressList = res.data;
					})
				}

			},

			//坐标转换
			convert(item) {
				let data = {
					key: '30b7eb1a1b2f88edc085b9b3ee9a2188',
					locations: `${item.longitude},${item.latitude}`,
					coordsys: 'gps',
				}

				return new Promise((resolve, reject) => {
					uni.request({
						url: 'https://restapi.amap.com/v3/assistant/coordinate/convert',
						method: "GET",
						data: data,
						success(res) {
							resolve(res.data)
						}
					})
				})
			},
			async getLocation() {
				let that = this

				if (uni.getStorageSync('setVersion').DeviceBrand == 'ios') {
					return new Promise((resolve, reject) => {
						uni.getLocation({
							type: 'wgs84',
							geocode: true,
							isHighAccuracy: true,
							success: async function(res) {
								let convert = await that.convert(res)
								let locations = convert.locations.split(',')
								res.longitude = locations[0]
								res.latitude = locations[1]
								that.isLocation = true
								uni.setStorageSync("isLocation",true)
								resolve(res)
							},
							fail(err) {
								console.log(err)
								// uni.showToast({
								// 	title: '获取位置失败',
								// 	icon: 'none'
								// })
								that.isLocation = false
								uni.setStorageSync("isLocation",false)
								reject(err)
							}
						})

					})
				} else {
					return new Promise((resolve, reject) => {
						uni.getLocation({
							type: 'gcj02',
							geocode: true,
							success: function(res) {
								that.isLocation = true
								uni.setStorageSync("isLocation",true)
								resolve(res)
							},
							fail(err) {
								console.log(err)
								// uni.showToast({
								// 	title: '获取位置失败',
								// 	icon: 'none'
								// })
								that.isLocation = false
								uni.setStorageSync("isLocation",false)
								reject(err)
							}
						})
					})
				}


			},
			//刷新地址
			async refreshAdress() {

				let that = this;
				let nowLocation = await that.getLocation()
				that.longitude = nowLocation.longitude;
				that.latitude = nowLocation.latitude;
				// that.markers = [{
				// 	latitude: that.latitude,
				// 	longitude: that.longitude,
				// 	iconPath: '/static/images/position_icon_3x.png'
				// }]
				let city = {
					location: nowLocation.longitude + ',' + nowLocation.latitude,
					cityname: nowLocation.address.city,
				}
				that.setSelectCity(city)
				// 请求附近地址
				// types: '060000|070000|080000|090000|100000|120000|170000'
				that.getPlaceAround(true);
			},
			// 获取当前位置
			async getCurrentLocation() {
				let that = this;
				let longitude = '';
				let latitude = '';
				// const locationRes = await that.getLocation();

				//判断是否开启定位
				let searchCity = uni.getStorageSync('searchCity')
				if (that.firstRun) {
					try {
						let nowLocation = await that.getLocation()
						that.longitude = nowLocation.longitude;
						that.latitude = nowLocation.latitude;
						let nowSearchCity = {
							'center': nowLocation.longitude + ',' + nowLocation.latitude,
							'name': nowLocation.address.city
						}
						// uni.setStorageSync('searchCity', searchCity)
						that.city = nowSearchCity

					} catch (error) {
						if (searchCity) {
							that.city = searchCity
							let locationRes = searchCity.center.split(','); //调用默认地址
							that.longitude = locationRes[0];
							that.latitude = locationRes[1];
						} else {
							that.city = {
								center: '117.330043,38.372266',
								name: '黄骅'
							}
							that.longitude = '117.330043';
							that.latitude = '38.372266';
						}
					}
				} else {
					if (searchCity) {
						that.city = searchCity
						let locationRes = searchCity.center.split(','); //调用默认地址
						that.longitude = locationRes[0];
						that.latitude = locationRes[1];
					} else {
						that.city = {
							center: '117.330043,38.372266',
							name: '黄骅'
						}
						that.longitude = '117.330043';
						that.latitude = '38.372266';
					}

				}
				// try {
				// 	let nowLocation = await that.getLocation()
				// 	if (that.firstRun) {
				// 		that.longitude = nowLocation.longitude;
				// 		that.latitude = nowLocation.latitude;
				// 		let nowSearchCity = {
				// 			'center': nowLocation.longitude + ',' + nowLocation.latitude,
				// 			'name': nowLocation.address.city
				// 		}
				// 		// uni.setStorageSync('searchCity', searchCity)
				// 		that.city = nowSearchCity
				// 	} else {
				// 		if (searchCity) {
				// 			that.city = searchCity
				// 			let locationRes = searchCity.center.split(','); //调用默认地址
				// 			that.longitude = locationRes[0];
				// 			that.latitude = locationRes[1];
				// 		} else {
				// 			that.city = {
				// 				center: '117.330043,38.372266',
				// 				name: '黄骅'
				// 			}
				// 			that.longitude = '117.330043';
				// 			that.latitude = '38.372266';
				// 		}

				// 	}

				// } catch (error) {
				// 	if (searchCity) {
				// 		that.city = searchCity
				// 		let locationRes = searchCity.center.split(','); //调用默认地址
				// 		that.longitude = locationRes[0];
				// 		that.latitude = locationRes[1];
				// 	} else {
				// 		that.city = {
				// 			center: '117.330043,38.372266',
				// 			name: '黄骅'
				// 		}
				// 		let locationRes = getApp().globalData.addressRes; //调用默认地址
				// 		that.longitude = locationRes.longitude;
				// 		that.latitude = locationRes.latitude;
				// 	}
				// }
				// that.markers = [{
				// 	latitude: that.latitude,
				// 	longitude: that.longitude,
				// 	iconPath: '/static/images/position_icon_3x.png'
				// }]
				// 请求附近地址
				// types: '060000|070000|080000|090000|100000|120000|170000'
				that.getPlaceAround();
			},
			getPlaceAround(refresh) {
				let that = this;
				let data;
				if (!that.searchKeyword) {
					data = {
						key: '30b7eb1a1b2f88edc085b9b3ee9a2188',
						location: `${that.longitude},${that.latitude}`,
						page: 1,
						offset: 10
					}
				} else {
					data = {
						key: '30b7eb1a1b2f88edc085b9b3ee9a2188',
						location: `${that.longitude},${that.latitude}`,
						keywords: that.searchKeyword,
						page: 1,
						offset: 10
					}
				}
				return new Promise((resolve, reject) => {
					uni.request({
						url: 'https://restapi.amap.com/v5/place/around',
						method: "GET",
						data: data,
						success(res) {
							that.searchResults = res.data.pois;
							that.searchResults.forEach(item => {
								let locations = item.location.split(',')
								item.latitude = locations[1]
								item.longitude = locations[0]
							})
							//如果第一次进入当前定位名字赋值
							if (that.isLocation == true && that.firstRun) {
								that.firstRun = false
								that.nowAddress = res.data.pois[0].name
								that.nowCity = res.data.pois[0]
							}
							if (that.isLocation == true && refresh == true) {
								that.nowAddress = res.data.pois[0].name
								that.nowCity = res.data.pois[0]

								let pages = getCurrentPages()
								let prevPage = pages[pages.length - 2]
								prevPage.$vm.isNeedLocation = false;
								prevPage.$vm.updateAddress(that.searchResults[0])
								getApp().updateAddress(that.searchResults[0]);
							}
						}
					})
				})
			},
			// 更新地图标记
			updateMarkers() {
				this.markers = [{
					latitude: this.latitude,
					longitude: this.longitude,
					iconPath: '/static/images/position_icon_3x.png'
				}]
			},
			// 搜索地址
			async onSearch() {
				let that = this;
				if (!that.searchKeyword.trim()) {
					uni.showToast({
						title: '请输入搜索关键词',
						icon: 'none'
					})
					return
				}

				try {
					await that.getPlaceAround();
				} catch (error) {
					uni.showToast({
						title: '搜索失败',
						icon: 'none'
					})
				}
			},
			selectNowAdress(item) {
				if (this.nowAddress != '开启后才能看到周边服务') {
					this.selectAddress(item)
				}
			},
			selectCommonAddress(item) {
				let that = this;
				let data;
				data = {
					key: '30b7eb1a1b2f88edc085b9b3ee9a2188',
					location: `${item.longitude},${item.latitude}`,
					page: 1,
					offset: 1
				}
				return new Promise((resolve, reject) => {
					uni.request({
						url: 'https://restapi.amap.com/v5/place/around',
						method: "GET",
						data: data,
						success(res) {
							let name = that.removeDependencyFromAddress(item.server_address, item
								.dependency)
							res.data.pois[0].name = name
							res.data.pois[0].location = `${item.longitude},${item.latitude}`
							console.log("around:", res)

							that.selectAddress(res.data.pois[0])
						}
					})
				})
			},
			//去除字段中对应的区域
			removeDependencyFromAddress(serverAddress, dependency) {
				// 将dependency按分隔符拆分并过滤空值
				const dependencyParts = dependency.split('-').map(part => part.trim()).filter(Boolean);

				let result = serverAddress;

				// 依次移除每个层级的内容
				dependencyParts.forEach(part => {
					// 创建正则表达式，匹配包含该部分的内容（考虑可能的标点和空格）
					const regex = new RegExp(`${part}[\\s\\(\\)，,]*`, 'g');
					result = result.replace(regex, '');
				});

				// 去除可能的首尾空格
				return result.trim();
			},
			setSelectCity(item) {
				let that = this;
				let searchCity = {
					'center': item.location,
					'name': item.cityname,
				}
				that.city = searchCity
				uni.setStorageSync('searchCity', searchCity)
			},
			// 选择地址
			selectAddress(item) {
				if (item) {
					this.setSelectCity(item)
				}

				// 返回上一页并传递选中的地址信息
				const pages = getCurrentPages()
				const prevPage = pages[pages.length - 2]

				if (prevPage) {
					if (prevPage.route === 'pages/home/home') {
						prevPage.$vm.isNeedLocation = false;
						prevPage.$vm.updateAddress(item)
						uni.navigateBack()
						getApp().updateAddress(item);
					} else if (prevPage.route === 'pages/artisan/profile') {
						prevPage.$vm.editAddress(item)
						uni.navigateBack()
					} else if (prevPage.route === 'pages/ruzhu/complete') {
						prevPage.$vm.editAddress(item)
						uni.navigateBack()
					} else if (prevPage.route === 'pages/address/add') {
						prevPage.$vm.editAddress(item)
						uni.navigateBack()
					}

				}

			},
			// 点击地图
			onMapTap(e) {
				let that = this;
				that.latitude = e.detail.latitude;
				that.longitude = e.detail.longitude;
				that.updateMarkers()
				that.getPlaceAround()
			},
			//滑动了地图
			changeMap(e) {
				// let type = '';  
				// const { platform } = uni.getSystemInfoSync();  
				// switch (platform) {  
				// 	case 'android':  
				// 		type = e.type;  
				// 		break;  
				// 	case 'ios':  
				// 		type = e.detail.type;  
				// 		break;  
				// }
				// 	console.log("滑动");
				// 	console.log(e);
				// if (type === 'end') {  
				// 处理拖拽结束时的逻辑  
				// console.log("结束了");
				let mapCtx = uni.createMapContext('map', this);
				mapCtx.getCenterLocation({
					success: res => {
						console.log(res)
						// 当前中心经纬度位置
						this.latitude = res.latitude;
						this.longitude = res.longitude;
						this.updateMarkers()
						this.getPlaceAround()
					}
				})
				// }  
			},
			// 去选择地图列表页
			goAddress() {
				uni.navigateTo({
					url: '/pages/address/list'
				})
			},
			//跳转城市选择页
			goSelectCity() {
				uni.navigateTo({
					url: '/pages/address/selectCity'
				})
			},
			//跳转地址选择页
			goSelectAddress() {
				uni.navigateTo({
					url: '/pages/address/selectAddress'
				})
			},
			//跳转地址编辑页
			goList() {
				uni.navigateTo({
					url: '/pages/address/list'
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.search-address-page {
		flex: 1;
		height: 100vh;
		overflow: hidden;
	}

	.search-container {
		background-color: #FFFFFF;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 32rpx 30rpx 20rpx 30rpx;

		.search-container-text {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #333333;
			line-height: 45rpx;
			text-align: left;
			font-style: normal;
		}

		.text-img {
			width: 20rpx;
			height: 12rpx;
			margin-left: 8rpx;
			margin-right: 26rpx;
		}

		.address-header {
			flex: 1;
			height: 68rpx;
			background: #FFFFFF;
			border: 2rpx solid #E8101E;
			border-radius: 60rpx;
			position: relative;

			.search-icon {
				width: 29rpx;
				height: 32rpx;
				position: absolute;
				top: 18rpx;
				left: 22rpx;
			}

			.search-text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #CCCCCC;
				text-align: left;
				font-style: normal;
				position: absolute;
				top: 16rpx;
				left: 72rpx;
			}
		}
	}

	.current-locate {
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.05);
		padding: 22rpx 30rpx;
		margin-bottom: 20rpx;

		&__heard {
			display: flex;
			flex-wrap: wrap;
			justify-content: flex-start;
			align-items: flex-end;
			flex-direction: row;
			margin-bottom: 24rpx;

			&__text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #666666;
				line-height: 40rpx;
				text-align: left;
				font-style: normal;
			}

			&__img {
				height: 32rpx;
				width: 32rpx;
				margin-right: 12rpx;
				margin-bottom: 7rpx;
			}
		}

		&__contact {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			flex-direction: row;

			&__left {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #000000;
				line-height: 40rpx;
				text-align: center;
				font-style: normal;
			}

			&__right {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #E8101E;
				line-height: 34rpx;
				text-align: center;
				font-style: normal;
			}

			&__refresh {
				height: 30rpx;
				width: 30rpx;
			}
		}
	}

	.address-list {
		background-color: #FAFAFA;
		padding-bottom: 40rpx;

		.address-list-box {
			background-color: #FFFFFF;
			box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.05);
			;
		}

		&__cut {
			margin-bottom: 20rpx;
		}

		&__heard {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			align-items: flex-end;
			flex-direction: row;
			padding: 16rpx 30rpx 0rpx 30rpx;


			&__left {
				display: flex;
				flex-wrap: wrap;
				justify-content: flex-start;
				align-items: flex-end;
				flex-direction: row;

				&__text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #666666;
					line-height: 40rpx;
					text-align: left;
					font-style: normal;
				}

				&__img {
					height: 32rpx;
					width: 32rpx;
					margin-right: 12rpx;
					margin-bottom: 7rpx;
				}
			}

			&__img {
				height: 28rpx;
				width: 30rpx;
				margin-right: 12rpx;
				margin-bottom: 7rpx;
			}
		}
	}

	.address-item {
		display: flex;
		flex-flow: row nowrap;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 0rpx;
		margin: 0 30rpx;
		border-bottom: 1rpx solid #EEEEEE;
	}

	.address-info {
		flex: 1;
		margin-right: 24rpx;

		&__user {
			display: flex;
			flex-direction: row;
		}

		.address-info__user {
			margin-bottom: 8rpx;
			align-items: center;
		}

		.address-info__left {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: flex-start;
			margin-bottom: 10rpx;
		}
	}

	.address-name {
		max-height: 600rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
		padding-right: 20rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		/* 显示的行数 */
		lines: 1;
		/* NVUE下要用这个属性，来让文字超出隐藏变省略号 */
	}

	.address-detail {
		width: 500rpx;
		height: 34rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 26rpx;
		color: #999999;
		line-height: 34rpx;
		text-align: left;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		/* 显示的行数 */
		lines: 1;
		/* NVUE下要用这个属性，来让文字超出隐藏变省略号 */
	}

	.distance-text {
		font-size: 24rpx;
		color: #999999;
	}

	.map-container {
		width: 750rpx;
		height: 500rpx;
		position: relative;
		z-index: 1;
	}

	.map {
		width: 750rpx;
		height: 500rpx;
	}

	.empty-state {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-top: 200rpx;
	}

	.empty-icon {
		width: 240rpx;
		height: 240rpx;
		margin-bottom: 32rpx;
	}

	.empty-text {
		font-size: 30rpx;
		color: #999999;
	}

	.address-default {
		display: flex;
		justify-content: center;
		align-items: center;
		align-content: center;
		flex-direction: row;
		flex-wrap: nowrap;
		width: 48rpx;
		height: 26rpx;
		border-radius: 6rpx;
		background: #E8101E;
		margin-right: 10rpx;

		&__text {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 16rpx;
			line-height: 24rpx;
			color: #FFFFFF;
			text-align: center;
			font-style: normal;

		}

	}

	/* APP适配 */
	/* #ifdef APP-PLUS */
	.permission.transform {
		// top: calc(var(--status-bar-height) + 88rpx + 80rpx);
		top: 220rpx;
		opacity: 1;
		visibility: visible;
	}

	/* #endif */


	/* 平台适配 */
	/* #ifdef H5 */
	.search-address-page {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	/* #endif */

	/* #ifdef MP-WEIXIN */
	.map-container {
		overflow: hidden;
	}

	/* #endif */
</style>