no message
This commit is contained in:
parent
4ef6b6de2c
commit
7643b5d6d8
|
|
@ -381,6 +381,39 @@ public class GoodsController extends BaseController {
|
|||
|
||||
Shop shop=shopService.getShop(result.getShopId());
|
||||
result.setShop(shop);
|
||||
|
||||
// 获取用户当前位置
|
||||
Double userLatitude = goods.getLatitude();
|
||||
Double userLongitude = goods.getLongitude();
|
||||
|
||||
// 计算距离逻辑
|
||||
if (LocationUtils.isValidCoordinate(userLatitude, userLongitude) && shop != null) {
|
||||
try {
|
||||
if (LocationUtils.isValidCoordinate(shop.getLatitude(), shop.getLongitude())) {
|
||||
// 计算距离(米)
|
||||
double distanceInMeters = LocationUtils.getDistanceInMeters(
|
||||
userLatitude, userLongitude,
|
||||
shop.getLatitude(), shop.getLongitude()
|
||||
);
|
||||
|
||||
// 格式化距离并设置到商品对象
|
||||
result.setDistance(LocationUtils.formatDistance(distanceInMeters));
|
||||
|
||||
logger.debug("商品[{}]距离用户: {}", result.getGoodsName(), result.getDistance());
|
||||
} else {
|
||||
// 店铺坐标不完整
|
||||
result.setDistance(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("计算商品[{}]距离失败: {}", result.getGoodsName(), e.getMessage());
|
||||
// 计算异常时设为null
|
||||
result.setDistance(null);
|
||||
}
|
||||
} else {
|
||||
// 用户未提供位置或店铺信息不存在
|
||||
result.setDistance(null);
|
||||
}
|
||||
|
||||
// 补全商品类目及父级类目信息
|
||||
GoodsCategory goodsCategory = goodsCategoryService.selectById(result.getDeptGoodsCategoryId());
|
||||
result.setDeptGoodsCategoryName(goodsCategory.getGoodsCategoryName());
|
||||
|
|
|
|||
|
|
@ -955,12 +955,25 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 设置定时器,每隔一分钟执行一次 fetchData 函数
|
||||
setInterval(fetchData, 60000);
|
||||
|
||||
// 图片预览功能
|
||||
function showImagePreview(imageUrl) {
|
||||
if (!imageUrl || imageUrl.trim() === '') {
|
||||
$.modal.msgError("图片地址不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '图片预览',
|
||||
shadeClose: true,
|
||||
shade: 0.8,
|
||||
area: ['auto', 'auto'],
|
||||
content: '<div style="text-align: center; padding: 20px;"><img src="' + imageUrl + '" style="max-width: 800px; max-height: 600px; object-fit: contain;" /></div>'
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in New Issue