lease.vue页面重构
This commit is contained in:
parent
9593e007e6
commit
d6ba3c40ee
81
components/custom-nav-bar2/custom-nav-bar2.vue
Normal file
81
components/custom-nav-bar2/custom-nav-bar2.vue
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
<template>
|
||||||
|
<view class="layout">
|
||||||
|
<view class="navbar">
|
||||||
|
<view :style="{ height: getStatusBarHeight() + 'px' }" class="statusBar"></view>
|
||||||
|
<view
|
||||||
|
:style="{ height: getTitleBarHeight() + 'px', marginLeft: getLeftIconLeft() + 'px' }"
|
||||||
|
class="titleBar"
|
||||||
|
>
|
||||||
|
<view class="title">{{ title }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view :style="{ height: getNavBarHeight() + 'px' }" class="fill"></view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import {
|
||||||
|
getStatusBarHeight,
|
||||||
|
getTitleBarHeight,
|
||||||
|
getNavBarHeight,
|
||||||
|
getLeftIconLeft,
|
||||||
|
} from '@/utils/system.js'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '壁纸',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.layout {
|
||||||
|
.navbar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 10;
|
||||||
|
background: #ffddca;
|
||||||
|
|
||||||
|
.statusBar {
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleBar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0 30rpx;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #3d3d3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
width: 220rpx;
|
||||||
|
height: 50rpx;
|
||||||
|
margin-left: 10rpx;
|
||||||
|
color: #3d3d3d;
|
||||||
|
font-size: 28rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-left: 5rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
padding-left: 10rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="lease-page">
|
<view class="lease-page">
|
||||||
<!-- 头部区域 -->
|
<!-- 头部区域 -->
|
||||||
|
<custom-nav-bar2 title="租赁申请"></custom-nav-bar2>
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<view class="header-content">
|
<view class="header-content">
|
||||||
<view class="title-section">
|
|
||||||
<text class="page-title">租赁申请</text>
|
|
||||||
</view>
|
|
||||||
<view class="product-info">
|
<view class="product-info">
|
||||||
<text class="product-name">渝锦汇节能灶燃烧器</text>
|
<text class="product-name">渝锦汇节能灶燃烧器</text>
|
||||||
<text class="product-slogan">租来节能,灶就省钱</text>
|
<text class="product-slogan">租来节能,灶就省钱</text>
|
||||||
|
|
@ -165,9 +163,9 @@ export default {
|
||||||
async getCurrentLocation() {
|
async getCurrentLocation() {
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '获取位置中...'
|
title: '获取位置中...',
|
||||||
})
|
})
|
||||||
|
|
||||||
const location = await getLocationWithPermission()
|
const location = await getLocationWithPermission()
|
||||||
console.log('位置信息:', location)
|
console.log('位置信息:', location)
|
||||||
this.reverseGeocode(location.latitude, location.longitude)
|
this.reverseGeocode(location.latitude, location.longitude)
|
||||||
|
|
@ -176,49 +174,50 @@ export default {
|
||||||
handleLocationError(err)
|
handleLocationError(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 处理位置信息
|
// 处理位置信息
|
||||||
reverseGeocode(latitude, longitude) {
|
reverseGeocode(latitude, longitude) {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|
||||||
// 直接使用坐标信息,避免依赖外部API
|
// 直接使用坐标信息,避免依赖外部API
|
||||||
this.currentLocation = {
|
this.currentLocation = {
|
||||||
company: '当前位置',
|
company: '当前位置',
|
||||||
address: `纬度: ${latitude.toFixed(6)}, 经度: ${longitude.toFixed(6)}`,
|
address: `纬度: ${latitude.toFixed(6)}, 经度: ${longitude.toFixed(6)}`,
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
longitude: longitude
|
longitude: longitude,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 尝试使用uni-app的地理编码(如果平台支持)
|
// 尝试使用uni-app的地理编码(如果平台支持)
|
||||||
// #ifdef APP-PLUS || MP-WEIXIN
|
// #ifdef APP-PLUS || MP-WEIXIN
|
||||||
uni.reverseGeocoder({
|
uni.reverseGeocoder({
|
||||||
location: {
|
location: {
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
longitude: longitude
|
longitude: longitude,
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: res => {
|
||||||
console.log('逆地理编码结果:', res)
|
console.log('逆地理编码结果:', res)
|
||||||
if (res.result) {
|
if (res.result) {
|
||||||
this.currentLocation = {
|
this.currentLocation = {
|
||||||
company: res.result.addressComponent?.city || '当前位置',
|
company: res.result.addressComponent?.city || '当前位置',
|
||||||
address: res.result.formatted_addresses?.recommend || res.result.address || '未知地址',
|
address:
|
||||||
|
res.result.formatted_addresses?.recommend || res.result.address || '未知地址',
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
longitude: longitude
|
longitude: longitude,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: err => {
|
||||||
console.log('逆地理编码不可用,使用坐标信息')
|
console.log('逆地理编码不可用,使用坐标信息')
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '位置获取成功',
|
title: '位置获取成功',
|
||||||
icon: 'success'
|
icon: 'success',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
selectAddress() {
|
selectAddress() {
|
||||||
// 选择地址逻辑
|
// 选择地址逻辑
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
@ -226,13 +225,13 @@ export default {
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
useCurrentLocation() {
|
useCurrentLocation() {
|
||||||
if (!this.currentLocation) {
|
if (!this.currentLocation) {
|
||||||
this.getCurrentLocation()
|
this.getCurrentLocation()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formData.address = this.currentLocation.company + ' ' + this.currentLocation.address
|
this.formData.address = this.currentLocation.company + ' ' + this.currentLocation.address
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '已使用当前定位',
|
title: '已使用当前定位',
|
||||||
|
|
@ -307,19 +306,6 @@ export default {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title-section {
|
|
||||||
padding-top: 20rpx;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 40rpx;
|
|
||||||
|
|
||||||
.page-title {
|
|
||||||
font-size: 36rpx;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.product-info {
|
.product-info {
|
||||||
margin-bottom: 40rpx;
|
margin-bottom: 40rpx;
|
||||||
//border: red solid 2rpx;
|
//border: red solid 2rpx;
|
||||||
|
|
@ -341,8 +327,8 @@ export default {
|
||||||
.header-graphic {
|
.header-graphic {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 58rpx;
|
top: 0;
|
||||||
//border: red solid 2rpx;
|
border: red solid 2rpx;
|
||||||
|
|
||||||
.fire {
|
.fire {
|
||||||
width: 252rpx;
|
width: 252rpx;
|
||||||
|
|
@ -538,7 +524,7 @@ export default {
|
||||||
box-shadow: 0 2rpx 8rpx rgba(255, 107, 107, 0.4);
|
box-shadow: 0 2rpx 8rpx rgba(255, 107, 107, 0.4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.get-location-btn {
|
.get-location-btn {
|
||||||
background: #ff6b6b;
|
background: #ff6b6b;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user