添加编辑发布 页面

This commit is contained in:
浅念
2026-02-09 17:51:32 +08:00
parent ea2e2fec25
commit f9b199f6a6
4 changed files with 851 additions and 3 deletions
+85 -3
View File
@@ -1,6 +1,6 @@
<template>
<view class="card-item">
<view class="user" @click="handleUserClick">
<view class="card-item" @click="handleUserClick">
<view class="user" >
<image :src="item.user.avatar_pull || '/static/image/user.png'" class="avatar"></image>
<view class="info">
<view class="name">{{ item.user.nickname || '用户名' }}</view>
@@ -40,7 +40,7 @@
/>
</view>
<view class="location" v-if="item.location_name">
<view class="location" v-if="item.location_name" @click.stop="locationfn(item)">
<uni-icons type="location" color="#999" size="18"></uni-icons>
<text>{{ item.location_name }}</text>
</view>
@@ -48,6 +48,9 @@
<view class="comment" @click="handleComment">
评论({{ item.comment || 0 }})
</view>
<view v-if="ismysq" class="actions">
<view class="edit-btn" @click.stop="handleEdit">编辑</view>
</view>
</view>
</template>
@@ -139,6 +142,76 @@ export default {
},
handleComment() {
this.$emit('comment', this.item);
},
handleEdit() {
this.$emit('edit', this.item);
},
// 点击位置:获取(模糊)当前位置 -> 打开系统地图并可导航到店铺位置
async locationfn(item) {
try {
const lat = Number((item && item.latitude));
const lng = Number((item && item.longitude));
if (!Number.isFinite(lat) || !Number.isFinite(lng)) {
uni.showToast({ title: '该店铺未设置定位', icon: 'none' });
return;
}
// 1) 先尝试获取(模糊)当前位置,主要用于触发授权 & 让地图页显示“我的位置”
await this._getFuzzyCurrentLocationSafe();
// 2) 打开地图并指向店铺坐标;地图页自带“导航/到这去”
uni.openLocation({
latitude: lat,
longitude: lng,
name: (item && item.location_name) || '店铺位置',
address: (item && item.location_address) || (item && item.location_name) || '',
scale: 16,
fail: () => {
uni.showToast({ title: '打开地图失败', icon: 'none' });
}
});
} catch (e) {
// 兜底:即使定位授权失败,也尽量打开店铺位置
const lat = Number((item && item.latitude));
const lng = Number((item && item.longitude));
if (Number.isFinite(lat) && Number.isFinite(lng)) {
uni.openLocation({
latitude: lat,
longitude: lng,
name: (item && item.location_name) || '店铺位置',
address: (item && item.location_address) || (item && item.location_name) || '',
scale: 16
});
} else {
uni.showToast({ title: '打开地图失败', icon: 'none' });
}
}
},
// 获取模糊定位(不抛错版本):用于触发授权&让地图显示“我的位置”
_getFuzzyCurrentLocationSafe() {
return new Promise((resolve) => {
// 仅微信小程序支持 getFuzzyLocation
// #ifdef MP-WEIXIN
uni.authorize({
scope: 'scope.userFuzzyLocation',
success: () => {
// 直接调用微信的模糊定位
wx.getFuzzyLocation({
type: 'wgs84',
success: () => resolve(),
fail: () => resolve()
});
},
fail: () => resolve()
});
// #endif
// #ifndef MP-WEIXIN
// 其他端不处理,直接放过
resolve();
// #endif
});
}
}
}
@@ -254,4 +327,13 @@ export default {
font-size: 26rpx;
color: #666;
}
.actions{
display: flex;
justify-content: flex-end;
}
.edit-btn{
font-size: 26rpx;
color: #3BC6BD;
padding: 10rpx 0;
}
</style>