feat: 改造商品详情的位置组件样式

This commit is contained in:
2026-03-10 23:04:42 +08:00
parent b69d24b96a
commit e3fa4b6a02
2 changed files with 77 additions and 43 deletions

View File

@@ -1,14 +1,26 @@
<template>
<view class="store-address" @click="openMap">
<view class="text-container">
<view class="store-address">
<view class="text-container" @click.stop="openMap">
<text class="location-label">位于 {{ orderData.oneLevelAddress }}</text>
<text class="address-text">{{ orderData.commodityAddress }}</text>
</view>
<image
class="loc-icon"
src="./images/loc_icon_img.png"
mode="aspectFit"
></image>
<view class="actions">
<view>
<view class="actions-btn" @click.stop="openMap">
<text class="actions-icon">📞</text>
</view>
<text class="actions-text">导航</text>
</view>
<view>
<view class="actions-btn" @click.stop="callPhone">
<text class="actions-icon">📞</text>
</view>
<text class="actions-text">电话</text>
</view>
</view>
</view>
</template>
@@ -30,21 +42,38 @@ const openMap = () => {
const longitude = Number(props.orderData.commodityLongitude);
uni.getLocation({
type: "gcj02", //返回可以用于uni.openLocation的经纬度
success: (res) => {
console.log("当前经纬度", latitude, longitude);
type: "gcj02",
success: () => {
uni.openLocation({
latitude: latitude,
longitude: longitude,
address: address,
success: () => {
console.log("success");
});
},
fail: () => {
uni.openLocation({
latitude: latitude,
longitude: longitude,
address: address,
});
},
});
};
// 拨打电话
const getPhoneNumber = () => {
const o = props.orderData || {};
return o.commodityPhone || o.phone || o.contactPhone || "";
};
const callPhone = () => {
const phone = getPhoneNumber();
if (!phone) {
uni.showToast({ title: "未提供电话号码", icon: "none" });
return;
}
uni.makePhoneCall({ phoneNumber: String(phone) });
};
</script>
<style scoped lang="scss">

View File

@@ -1,51 +1,56 @@
.store-address {
display: flex;
align-items: center;
margin: 6px 12px;
padding: 16px 12px;
background-image: url("./images/loc_bg_img.png"); // 预留背景图片位置,用户手动导入
background-size: cover;
background-position: center;
border-radius: 20px;
font-size: $uni-font-size-base;
color: $uni-text-color;
position: relative;
overflow: hidden;
margin-top: 12px;
padding: 12px 12px 0 12px;
background-color: #ffffff;
border-top: 1px solid #e0e0e0;
// 左侧文本容器
.text-container {
display: flex;
flex-direction: column;
flex: 1;
position: relative;
z-index: 2;
}
// 确保内容在遮罩层之上
.location-label,
.address-text,
.loc-icon {
position: relative;
z-index: 2;
}
.location-label {
color: $uni-text-color;
color: $text-color-800;
font-size: $uni-font-size-base;
font-weight: 500;
}
.address-text {
margin-top: 4px;
color: #666;
color: $text-color-600;
font-size: $uni-font-size-sm;
font-weight: 400;
}
// 右侧图标样式
.loc-icon {
width: 24px;
height: 24px;
margin-left: 12px;
// 右侧操作按钮组
.actions {
display: flex;
align-items: center;
gap: 10px;
margin-left: 16px;
}
.actions-btn {
width: 28px;
height: 28px;
border-radius: 10px;
background-color: #F5F5F5;
display: flex;
align-items: center;
justify-content: center;
}
.actions-icon {
font-size: 16px;
line-height: 16px;
}
.actions-text {
font-size: $uni-font-size-sm;
color: $text-color-600;
}
}