first commit

This commit is contained in:
2026-02-26 09:32:03 +08:00
commit 36a8e4c51b
845 changed files with 116474 additions and 0 deletions
@@ -0,0 +1,129 @@
<script setup lang="ts">
import {
onMounted,
getCurrentInstance
} from 'vue';
import Search from "@/pages/home/components/tabbar-home/components/search.vue";
import useEventEmit from "@/hooks/useEventEmit";
import {EventEnum} from "@/constant/enums";
const { t } = useI18n();
import {useAddressStore} from "@/pages/address/store/address";
import {appUserAddressListPost} from "@/service";
const addressStore = useAddressStore()
const addressesList = ref([])
const currentAddressId = ref('')
function getAddressList() {
appUserAddressListPost({
params: {
pageNum: 1,
pageSize: 100,
}
}).then(res => {
console.log('获取用户地址列表', res)
addressesList.value = res.rows
if(res.rows.length > 0) {
currentAddressId.value = res.rows[0].id
}
})
}
function handleClickSearch() {
uni.navigateTo({
url: '/pages-user/pages/search-address/index',
});
}
useEventEmit(EventEnum.CHOOSE_ADDRESS, (data) => {
console.log('搜索的地址信息', data)
if(data) {
addressStore.setAddressLocation({
displayName: data.displayName,
formattedAddress: data.formattedAddress,
longitude: data.location.lng,
latitude: data.location.lat,
})
setTimeout(()=> {
uni.navigateTo({
url: '/pages/address/choose-type'
})
}, 300)
}
})
onShow(()=> {
getAddressList()
})
onLoad((options: any)=> {
if(options.id) {
currentAddressId.value = options.id
}
})
function chooseAddress(item: any) {
if(String(item.id) === String(currentAddressId.value)) return
currentAddressId.value = item.id
eventChannel.emit('acceptDataFromOpenedPage', {
data: currentAddressId.value,
deliveryRemark: item.deliveryRemark,
deliveryType: item.deliveryType,
});
setTimeout(()=> {
uni.navigateBack()
}, 300)
}
let instance = null
let eventChannel = null
onMounted(()=> {
instance = getCurrentInstance().proxy
eventChannel = instance.getOpenerEventChannel();
})
onUnload(()=> {
instance = null
eventChannel = null
})
</script>
<template>
<view>
<navbar :title="t('pages.address.title')" />
<view class="mt-32rpx px-30rpx">
<search :is-auto-jump="false" @clickSearch="handleClickSearch" />
</view>
<view class="mt-64rpx text-40rpx lh-40rpx text-#333 font-bold pl-30rpx pb-24rpx">
{{ t('pages.address.savedAddresses') }}
</view>
<template v-for="item in addressesList">
<view @click="chooseAddress(item)" :class="[String(item.id) === String(currentAddressId) ? 'bg-#F3F3F3' : '']" class="w-full h-156rpx flex-center-sb px-30rpx">
<view class="flex items-center">
<image v-if="String(item.id) === String(currentAddressId)" src="@img/chef/143.png" class="w-44rpx h-44rpx shrink-0 mr-28rpx"></image>
<image v-else src="@img/chef/145.png" class="w-44rpx h-44rpx shrink-0 mr-28rpx"></image>
<view class="flex-1 h-156rpx pt-40rpx">
<view class="text-32rpx lh-32rpx text-#333 font-500 mb-16rpx line-clamp-1">{{ item.formattedAddress }}</view>
<view class="text-28rpx lh-28rpx text-#6D6D6D">{{ item.displayName || '' }}</view>
</view>
</view>
<image
:src="
String(item.id) === String(currentAddressId)
? '/static/images/chef/133.png'
: '/static/images/chef/134.png'
"
class="w-44rpx h-44rpx shrink-0 pl-30rpx"
mode="aspectFit"
/>
</view>
</template>
<template v-if="addressesList.length === 0">
<view class="py-100rpx center">
<image class="w-250rpx h-250rpx" src="@img/chef/100.png"></image>
</view>
</template>
</view>
</template>
<style>
page {
background-color: #fff;
}
</style>