fix:修复bug

This commit is contained in:
2026-01-22 10:52:58 +08:00
parent b0daa7b59b
commit 6a1dff4b94
46 changed files with 3779 additions and 2522 deletions
+88 -77
View File
@@ -22,52 +22,52 @@
:class="{ available: isRentable(item), invalid: !isValidCoordinate(item.latitude, item.longitude) }"
v-for="(item, index) in filteredPositions" :key="item.positionId || index"
@click="goToPositionDetail(item)">
<view class="thumb">
<image v-if="item.deviceImg" :src="item.deviceImg" class="thumb-img" mode="aspectFill">
</image>
<image v-else src="/static/device-info.png" class="thumb-img" mode="aspectFit"></image>
</view>
<view class="info">
<view class="row top">
<view class="name">{{ item.name }}</view>
<!-- 第一行三列布局 -->
<view class="card-row-first">
<!-- 第一列缩略图 -->
<view class="thumb">
<image v-if="item.deviceImg" :src="item.deviceImg" class="thumb-img" mode="aspectFill">
</image>
<image v-else src="/static/device-info.png" class="thumb-img" mode="aspectFit"></image>
</view>
<!-- 第二列信息 -->
<view class="info">
<view class="row top">
<view class="name">{{ item.name }}</view>
</view>
<view class="row sub" v-if="item.location">
<text class="addr">{{ item.location }}</text>
</view>
<view class="row meta" v-if="item.workTime && item.workTime !== '0'">
<text class="time">{{ $t('location.businessHours') }}{{ item.workTime }}</text>
</view>
<view class="row meta" v-if="!isValidCoordinate(item.latitude, item.longitude)">
<text class="time" style="color: #ff6b6b;">{{ $t('location.coordinateError') }}</text>
</view>
</view>
<view class="row sub" v-if="item.location">
<text class="addr">{{ item.location }}</text>
</view>
<view class="row meta" v-if="item.workTime && item.workTime !== '0'">
<text class="time">{{ $t('location.businessHours') }}{{ item.workTime }}</text>
</view>
<view class="row meta" v-if="!isValidCoordinate(item.latitude, item.longitude)">
<text class="time" style="color: #ff6b6b;">{{ $t('location.coordinateError') }}</text>
</view>
<view class="row meta"
v-if="item.availablePowerBankCount !== undefined && item.availablePowerBankCount !== null">
<text class="time">可租借{{ item.availablePowerBankCount }} </text>
</view>
<view class="row meta"
v-if="item.availableEmptyGridCount !== undefined && item.availableEmptyGridCount !== null">
<text class="time">可归还{{ item.availableEmptyGridCount }} 个空位</text>
</view>
<view class="row meta remark-info" v-if="item.remark">
<text class="time">💰 {{ item.remark }}</text>
<!-- 第三列操作 -->
<view class="actions">
<view class="nav" :class="{ disabled: !isValidCoordinate(item.latitude, item.longitude) }"
@click.stop="navigateToPosition(item)">
<image src="/static/luxian.png" class="action-icon" mode="aspectFit"></image>
</view>
<view class="distance"
v-if="item.distance && isValidCoordinate(item.latitude, item.longitude)">
{{ item.distance }}
</view>
</view>
</view>
<!-- 第二行标签 -->
<view class="card-row-second">
<view class="tags">
<view class="tag rent" v-if="isRentable(item)">{{ $t('location.rent') }}</view>
<view class="tag return" v-if="isReturnable(item)">{{ $t('location.return') }}</view>
<view class="tag" v-if="isCoupon(item)">{{CouponOrmember(item)}}</view>
<view class="tag coupon" v-if="item.supportCouponOrMember">{{ $t('location.supportCouponOrMember') }}</view>
</view>
</view>
<view class="actions">
<view class="nav" :class="{ disabled: !isValidCoordinate(item.latitude, item.longitude) }"
@click.stop="navigateToPosition(item)">
<image src="/static/luxian.png" class="action-icon" mode="aspectFit"></image>
</view>
<view class="distance"
v-if="item.distance && isValidCoordinate(item.latitude, item.longitude)">
{{ item.distance }}</view>
</view>
</view>
<view class="empty-state" v-if="!isLoading && (!positionList || positionList.length === 0)">
@@ -101,13 +101,13 @@
} from '@/utils/i18n.js'
const {
t: $t
t
} = useI18n()
onMounted(() => {
uni.setNavigationBarTitle({
title: $t('search.title')
title: t('search.title')
})
// uni.showLoading({
// title:'11111',
@@ -132,11 +132,6 @@
if (typeof item?.canReturn !== 'undefined') return !!item.canReturn
return String(item?.status || '').toLowerCase() === 'online'
}
const isCoupon = (item)=>{
if(typeof item.canCoupon!=='undefined')return !!item.canCoupon
return String(item?.canCoupon||'').toLowerCase()==='true';
}
const formatDistance = (meters) => {
if (meters < 1000) return `${Math.round(meters)}m`
@@ -192,11 +187,6 @@
positionList.value.sort((a, b) => (a.distanceInMeters || 999999) - (b.distanceInMeters || 999999))
applyFilter()
}
const CouponOrmember= async(item)=>{
return "可使用优惠券、会员卡"
}
const loadPositions = async (center) => {
try {
@@ -227,8 +217,8 @@
return {
...transformed,
canRent: activeTab.value === 'rent' ? true : (device.availablePowerBankCount > 0),
canReturn: activeTab.value === 'return' ? true : (device.availableEmptyGridCount >
0)
canReturn: activeTab.value === 'return' ? true : (device.availableEmptyGridCount > 0),
supportCouponOrMember: device.supportCouponOrMember || false
}
})
@@ -267,7 +257,7 @@ const init = async () => {
positionList.value = []
filteredPositions.value = []
uni.showToast({
title: $t('home.getLocationFailed'),
title: t('home.getLocationFailed'),
icon: 'none'
})
} finally {
@@ -289,7 +279,7 @@ const init = async () => {
const navigateToPosition = (position) => {
if (!isValidCoordinate(position.latitude, position.longitude)) {
uni.showToast({
title: $t('search.invalidCoordinate'),
title: t('search.invalidCoordinate'),
icon: 'none'
})
return
@@ -307,7 +297,7 @@ const init = async () => {
const goToPositionDetail = (position) => {
if (!position.positionId) {
uni.showToast({
title: $t('search.positionInfoError'),
title: t('search.positionInfoError'),
icon: 'none'
})
return
@@ -403,9 +393,8 @@ const init = async () => {
}
.card {
display: grid;
grid-template-columns: 120rpx 1fr 72rpx;
align-items: center;
display: flex;
flex-direction: column;
gap: 16rpx;
padding: 20rpx;
border-radius: 20rpx;
@@ -424,6 +413,21 @@ const init = async () => {
background: #FFF9F9;
}
// 第一行:三列布局
.card-row-first {
display: grid;
grid-template-columns: 120rpx 1fr 72rpx;
align-items: center;
gap: 16rpx;
}
// 第二行:标签
.card-row-second {
width: 100%;
padding-top: 8rpx;
// border-top: 1rpx solid #F0F0F0;
}
.thumb {
width: 120rpx;
height: 120rpx;
@@ -453,7 +457,7 @@ const init = async () => {
font-size: 30rpx;
font-weight: 700;
color: #2A2A2A;
max-width: 70%;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -485,28 +489,34 @@ const init = async () => {
}
}
}
}
.tags {
display: flex;
gap: 10rpx;
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 10rpx;
}
.tag {
padding: 6rpx 14rpx;
border-radius: 16rpx;
font-size: 22rpx;
font-weight: 600;
}
.tag {
padding: 6rpx 14rpx;
border-radius: 16rpx;
font-size: 22rpx;
font-weight: 600;
}
.tag.rent {
background: #E8F5E8;
color: #3EAB64;
}
.tag.rent {
background: #E8F5E8;
color: #3EAB64;
}
.tag.return {
background: #E8F2FF;
color: #3578e5;
}
.tag.return {
background: #E8F2FF;
color: #3578e5;
}
.tag.coupon {
background: #FFF9F0;
color: #D4A574;
}
.actions {
@@ -514,6 +524,7 @@ const init = async () => {
align-items: center;
justify-content: center;
flex-direction: column;
gap: 8rpx;
}
.nav {