配置获取地址0.8

This commit is contained in:
WindowBird 2025-08-19 09:31:43 +08:00
parent 8d6e51af05
commit 76b2432e2b

View File

@ -40,9 +40,18 @@
<!-- 地址 -->
<view class="form-item address-form-item">
<text class="field-label">地址</text>
<view class="address-selector" @click="selectAddress">
<text class="address-text">{{ formData.address || '选择收货地址' }}</text>
<view class="map-icon-wrapper" title="点击打开地图">
<view class="address-input-wrapper">
<input
v-model="formData.address"
class="address-input"
placeholder="请输入或选择收货地址"
@focus="onAddressFocus"
/>
<view
class="map-icon-wrapper"
title="点击获取定位并打开地图"
@click="openMapWithLocation"
>
<text class="map-icon">🗺</text>
</view>
</view>
@ -151,6 +160,7 @@ export default {
currentLocation: null,
showDetails: false,
totalAmount: '100.10',
isMapTriggered: false,
}
},
methods: {
@ -172,14 +182,46 @@ export default {
}
uni.hideLoading()
uni.showToast({
title: '位置获取成功,点击地图图标查看',
icon: 'success',
duration: 3000,
})
//
if (!this.isMapTriggered) {
uni.showToast({
title: '位置获取成功,点击地图图标查看',
icon: 'success',
duration: 3000,
})
}
return this.currentLocation
} catch (err) {
uni.hideLoading()
handleLocationError(err)
throw err
}
},
//
onAddressFocus() {
//
console.log('地址输入框获得焦点')
},
//
async openMapWithLocation() {
try {
this.isMapTriggered = true
//
await this.getCurrentLocation()
//
this.openMap()
} catch (err) {
console.error('获取位置失败:', err)
uni.showToast({
title: '获取位置失败',
icon: 'error',
})
} finally {
this.isMapTriggered = false
}
},
@ -428,7 +470,62 @@ export default {
margin-bottom: 20rpx;
}
//
//
.address-input-wrapper {
flex: 3;
display: flex;
align-items: center;
height: 80rpx;
padding: 0 20rpx;
border-radius: 12rpx;
background: #fff;
//border: 1rpx solid #e0e0e0;
transition: all 0.3s ease;
&:focus-within {
border-color: #f15a04;
box-shadow: 0 0 0 2rpx rgba(241, 90, 4, 0.1);
}
.address-input {
flex: 1;
height: 100%;
font-size: 28rpx;
color: #333;
border: none;
outline: none;
background: transparent;
&::placeholder {
color: #999;
}
}
.map-icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
width: 48rpx;
height: 48rpx;
background: #f15a04;
border-radius: 50%;
transition: all 0.3s ease;
//box-shadow: 0 4rpx 12rpx rgba(241, 90, 4, 0.3);
margin-left: 16rpx;
&:active {
transform: scale(0.9);
box-shadow: 0 2rpx 8rpx rgba(241, 90, 4, 0.4);
}
.map-icon {
font-size: 28rpx;
color: white;
}
}
}
// 使
.address-selector {
flex: 3;
display: flex;
@ -533,7 +630,7 @@ export default {
}
.use-location-btn {
background: #f3f5f5;
background: #f15a04;
color: #000000;
border: none;
border-radius: 24rpx;