jiuyiUniapp/jiuyi2/components/public/jy-commodity-address/index.vue

89 lines
1.6 KiB
Vue
Raw Normal View History

2025-01-11 03:51:29 +08:00
<script setup>
//
import util from '@/common/js/util.js'
//
import {
ref,
reactive,
computed,
watch,
onMounted,
2025-01-19 22:56:45 +08:00
onUnmounted,
defineEmits,
2025-01-11 03:51:29 +08:00
} from 'vue'
const props = defineProps({
shopEdit: {
type: Boolean,
default: true
},
address: {
type: Object,
default: () => ({})
}
})
2025-01-19 22:56:45 +08:00
//
const emit = defineEmits(['update:address'])
2025-01-11 03:51:29 +08:00
onMounted(() => {
2025-01-19 13:55:21 +08:00
// 开启监听
addListener()
2025-01-11 03:51:29 +08:00
})
2025-01-19 13:55:21 +08:00
2025-01-11 03:51:29 +08:00
onUnmounted(() => {
2025-01-19 13:55:21 +08:00
// 移除监听
2025-01-11 03:51:29 +08:00
removeListener()
})
// 开启监听
function addListener() {
// 选择收货地址
uni.$on('selectAddress', (event) => {
2025-01-19 22:56:45 +08:00
console.log('selectAddress', event)
emit('update:address', event);
2025-01-11 03:51:29 +08:00
})
}
// 移除监听
function removeListener() {
// 移除收货地址
uni.$off('selectAddress')
}
// 跳转
function link(url) {
uni.navigateTo({
url
})
}
</script>
2024-12-18 15:46:27 +08:00
<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">
2025-01-19 13:55:21 +08:00
<text class="c333">{{address.province}}{{address.city}}{{address.country}}{{address.detail}}</text>
2024-12-18 15:46:27 +08:00
</view>
<!-- 姓名电话 -->
<view class="name">
2025-01-19 13:55:21 +08:00
<text class="c999 f26">{{address.name}} {{address.mobile}}</text>
2024-12-18 15:46:27 +08:00
</view>
</view>
<!-- 选择地址 -->
2025-01-19 22:56:45 +08:00
<view v-if="shopEdit" class="btn ti warmHollow plr20 ml20" @click="link('/pages/mine/address/index?select=1')">
2024-12-18 15:46:27 +08:00
<text class="cFF9B27">选择地址</text>
</view>
</view>
</template>
2025-01-11 03:51:29 +08:00
<style lang="scss" scoped>
//
2024-12-18 15:46:27 +08:00
</style>