<script setup>
	// 
	import util from '@/common/js/util.js'
	// 
	import {
		ref,
		reactive,
		computed,
		watch,
		onMounted,
		onUnmounted
	} from 'vue'

	const props = defineProps({
		shopEdit: {
			type: Boolean,
			default: true
		},
		address: {
			type: Object,
			default: () => ({})
		}
	})

	onMounted(() => {
		// 开启监听
		addListener()
	})

	onUnmounted(() => {
		// 移除监听
		removeListener()
	})

	// 开启监听
	function addListener() {
		// 选择收货地址
		uni.$on('selectAddress', (event) => {
			emit('update:value', event.target.value);
		})
	}

	// 移除监听
	function removeListener() {
		// 移除收货地址
		uni.$off('selectAddress')
	}

	// 跳转
	function link(url) {
		uni.navigateTo({
			url
		})
	}
</script>

<template>
	<view class="address df aic jcc">
		<!-- 图标 -->
		<view class="icon mr20">
			<image class="wh45" src="/static/address.png" mode="aspectFill" />
		</view>

		<!-- 收获地址 姓名电话 -->
		<view class="info f1">
			<!-- 收获地址 -->
			<view class="location f30">
				<text class="c333">{{address.province}}{{address.city}}{{address.country}}{{address.detail}}</text>
			</view>
			<!-- 姓名电话 -->
			<view class="name">
				<text class="c999 f26">{{address.name}} {{address.mobile}}</text>
			</view>
		</view>

		<!-- 选择地址 -->
		<view v-if="shopEdit" class="btn ti warmHollow plr20 ml20" @click="link('/pages/mine/address/index')">
			<text class="cFF9B27">选择地址</text>
		</view>
	</view>
</template>

<style lang="scss" scoped>
	// 
</style>