Files
YGChatCS/src/pages/ChatModule/PoiCompareCard/index.vue
duanshuwen 157b4f7e22 refactor: remove font-size utility file and replace with inline text classes
Delete the src/static/scss/font-size.scss utility file, and replace all legacy `font-size-*` class usages across the codebase with inline `text-[numberpx]` styling to consolidate font size definitions and remove redundant utility code.
2026-07-24 22:10:16 +08:00

163 lines
6.0 KiB
Vue

<template>
<view class="poi-compare-card w-full">
<view v-if="!isDetail" class="poi-compare-card__overview bg-white rounded-[24px] overflow-hidden">
<view class="poi-compare-card__head flex flex-items-center">
<view class="poi-compare-card__mark flex flex-items-center flex-justify-center rounded-full flex-shrink-0">
{{ data.icon }}
</view>
<view class="poi-compare-card__title text-[#1e293b] text-[18px] font-bold ellipsis-1 flex-full">
{{ data.title }}
</view>
</view>
<view class="poi-compare-card__columns grid grid-cols-2 gap-[16px]">
<view v-for="item in items" :key="item.id || item.name" class="poi-compare-card__place"
:class="{ 'is-disabled': disabled }" @click="handleSelect(item)">
<image class="poi-compare-card__image block w-full" :src="item.image" mode="aspectFill" />
<view v-for="field in item.fields" :key="field.label" class="poi-compare-card__field">
<view class="poi-compare-card__field-label text-[#94a3b8] text-[12px] font-bold">
{{ field.label }}
</view>
<view v-if="field.tone" class="poi-compare-card__chip text-[12px] font-bold"
:class="getToneClass(field.tone)">
{{ field.value }}
</view>
<view v-else class="poi-compare-card__field-value text-[#1e293b] text-[14px] font-bold">
{{ field.value }}
</view>
</view>
</view>
</view>
<view
class="poi-compare-card__primary flex flex-items-center flex-justify-center bg-[#0f172a] text-white text-[15px] font-bold"
:class="{ 'is-disabled': disabled }" @click="openDetail">
{{ data.detailButtonText }}
</view>
</view>
<view v-else class="poi-compare-card__detail-card bg-white rounded-[24px] overflow-hidden">
<view class="poi-compare-card__detail-head flex flex-items-center">
<view class="poi-compare-card__back flex flex-items-center flex-justify-center rounded-full flex-shrink-0"
@click="closeDetail">
<uni-icons type="left" size="16" color="#CBD5E1"></uni-icons>
</view>
<view class="poi-compare-card__detail-title text-[#1e293b] text-[20px] font-bold flex-full">
{{ detail.title }}
</view>
<view class="poi-compare-card__compare-label text-[#94a3b8] text-[12px] font-bold">
{{ detail.compareLabel }}
</view>
</view>
<view class="poi-compare-card__table">
<view class="poi-compare-card__table-head poi-compare-card__table-row">
<view></view>
<view v-for="item in items" :key="item.id || item.name"
class="poi-compare-card__table-title text-[#1e293b] text-[14px] font-bold">
{{ item.name }}
</view>
</view>
<view v-for="row in detail.rows" :key="row.label"
class="poi-compare-card__table-row poi-compare-card__data-row">
<view class="poi-compare-card__row-label text-[#94a3b8] text-[12px] font-bold">
{{ row.label }}
</view>
<view v-for="cell in row.values" :key="row.label + '-' + cell.text"
class="poi-compare-card__cell text-[#1e293b] text-[14px] font-bold" :class="getCellClass(cell.tone)">
{{ cell.text }}
</view>
</view>
</view>
<view class="poi-compare-card__recommend">
<view class="poi-compare-card__recommend-title text-[#94a3b8] text-[12px] font-bold">
{{ detail.recommendTitle }}
</view>
<view class="poi-compare-card__tips">
<view v-for="tip in detail.tips" :key="tip.text" class="poi-compare-card__tip flex gap-[10px]">
<view class="poi-compare-card__dot rounded-full flex-shrink-0" :class="getDotClass(tip.tone)" />
<view class="poi-compare-card__tip-text text-[#334155] text-[14px] font-bold">
{{ tip.text }}
</view>
</view>
</view>
</view>
<view class="poi-compare-card__actions grid grid-cols-2 gap-14">
<view v-for="action in detail.actions" :key="action.id || action.text"
class="poi-compare-card__action flex flex-items-center flex-justify-center text-[15px] font-bold"
:class="[action.primary ? 'poi-compare-card__action--primary bg-[#0f172a] text-white' : 'poi-compare-card__action--secondary text-[#334155]', { 'is-disabled': disabled }]"
@click="handleAction(action)">
<text class="poi-compare-card__action-icon">{{ action.icon }}</text>
<text>{{ action.text }}</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed, ref } from "vue";
const props = defineProps({
data: {
type: Object,
default: () => ({}),
},
disabled: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(["select", "back", "action"]);
const isDetail = ref(false);
const items = computed(() => props.data.items || []);
const detail = computed(() => props.data.detail || {});
const getToneClass = (tone) => {
const toneMap = {
green: "poi-compare-card__chip--green text-[#047857] bg-[#ecfdf5]",
amber: "poi-compare-card__chip--amber text-[#d97706] bg-[#fffbeb]",
};
return toneMap[tone] || "";
};
const getCellClass = (tone) => {
if (tone === "green") return "poi-compare-card__cell--green";
return "";
};
const getDotClass = (tone) => {
if (tone === "blue") return "poi-compare-card__dot--blue";
return "poi-compare-card__dot--green";
};
const handleSelect = (item) => {
if (props.disabled) return;
emit("select", item);
};
const openDetail = () => {
if (props.disabled) return;
isDetail.value = true;
emit("select", { type: "detail", items: items.value });
};
const closeDetail = () => {
isDetail.value = false;
emit("back");
};
const handleAction = (action) => {
if (props.disabled) return;
emit("action", action);
};
</script>
<style scoped lang="scss">
@import "./styles/index.scss";
</style>