feat: 填充了组件
This commit is contained in:
@@ -21,7 +21,24 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- <template v-if="entry.key === LONG_TEXT_KEYS.questionSuggest">
|
||||
<image v-else-if="entry.type === 'content-image'" class="content-body-image" :src="entry.value.url"
|
||||
mode="widthFix" @click="handlePreviewClick(entry.value.url)" />
|
||||
|
||||
<template v-else-if="entry.type === 'spot-locate'">
|
||||
<view class="detail-action-zone">
|
||||
<view class="detail-action-label">查看景点详情</view>
|
||||
<view class="detail-action-card is-raised">
|
||||
<view v-if="entry.value.tag" class="poi-mini-tag">{{ entry.value.tag }}</view>
|
||||
<view class="poi-mini-body">
|
||||
<view v-if="entry.value.name" class="poi-mini-title">{{ entry.value.name }}</view>
|
||||
<view v-if="entry.value.description" class="poi-mini-desc">{{ entry.value.description }}</view>
|
||||
<button v-if="hasMapLocation(entry.value)" class="detail-solid-button" @click.stop="openMap(entry.value)">带我去</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else-if="entry.type === 'question-suggest'">
|
||||
<view class="detail-action-label">继续追问</view>
|
||||
<view class="detail-faq-wrap">
|
||||
<view v-for="question in entry.value" :key="question" class="detail-faq-chip" @click="sendReply(question)">
|
||||
@@ -30,23 +47,6 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<image v-if="entry.key === LONG_TEXT_KEYS.contentImage" class="content-body-image" :src="entry.value"
|
||||
mode="widthFix" @click="handlePreviewClick(entry.value)" />
|
||||
|
||||
<template v-if="entry.key === LONG_TEXT_KEYS.spotLocate">
|
||||
<view class="detail-action-zone">
|
||||
<view class="detail-action-label">查看景点详情</view>
|
||||
<view class="detail-action-card is-raised">
|
||||
<view v-if="poiTag" class="poi-mini-tag">{{ entry.value.sopt_tag }}</view>
|
||||
<view class="poi-mini-body">
|
||||
<view class="poi-mini-title">{{ entry.value.sopt_name }}</view>
|
||||
<view class="poi-mini-desc">{{ entry.value.spot_description }}</view>
|
||||
<button class="detail-solid-button" @click.stop="openMap(entry.value)">带我去</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template> -->
|
||||
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
@@ -55,7 +55,12 @@
|
||||
import { computed, defineProps, ref } from "vue";
|
||||
import { SEND_MESSAGE_CONTENT_TEXT } from "@/constant/constant";
|
||||
import { getRandomTagToneStyle } from "@/utils/tagTone";
|
||||
import { LONG_TEXT_KEYS } from "@/utils/longTextCard";
|
||||
import {
|
||||
LONG_TEXT_KEYS,
|
||||
normalizeLongTextContentImage,
|
||||
normalizeLongTextQuestionSuggest,
|
||||
normalizeLongTextSpotLocate,
|
||||
} from "@/utils/longTextCard";
|
||||
|
||||
const props = defineProps({
|
||||
fieldKey: {
|
||||
@@ -77,7 +82,7 @@ const contentBodyListTextStyle = computed(() => ({
|
||||
color: contentBodyListToneStyle.value.color,
|
||||
}));
|
||||
|
||||
const IGNORED_FIELD_KEYS = ["container_type", "content", "content_summary", "components"];
|
||||
const IGNORED_FIELD_KEYS = ["container_type", "content", "components"];
|
||||
|
||||
const isArrayValue = (value) => Array.isArray(value);
|
||||
|
||||
@@ -151,9 +156,49 @@ const createImageEntry = (key, value) => ({
|
||||
},
|
||||
});
|
||||
|
||||
const createSpecialFieldEntry = (key, value) => {
|
||||
if (key === LONG_TEXT_KEYS.contentImage) {
|
||||
const image = normalizeLongTextContentImage(value);
|
||||
return image.url
|
||||
? [{
|
||||
key,
|
||||
type: "content-image",
|
||||
value: image,
|
||||
}]
|
||||
: [];
|
||||
}
|
||||
|
||||
if (key === LONG_TEXT_KEYS.spotLocate) {
|
||||
const spot = normalizeLongTextSpotLocate(value);
|
||||
return hasDisplayValue(spot)
|
||||
? [{
|
||||
key,
|
||||
type: "spot-locate",
|
||||
value: spot,
|
||||
}]
|
||||
: [];
|
||||
}
|
||||
|
||||
if (key === LONG_TEXT_KEYS.questionSuggest) {
|
||||
const questions = normalizeLongTextQuestionSuggest(value);
|
||||
return questions.length
|
||||
? [{
|
||||
key,
|
||||
type: "question-suggest",
|
||||
value: questions,
|
||||
}]
|
||||
: [];
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const renderFieldEntries = computed(() => {
|
||||
if (isIgnoredField.value || !hasDisplayValue(props.value)) return [];
|
||||
|
||||
const specialFieldEntry = createSpecialFieldEntry(props.fieldKey, props.value);
|
||||
if (specialFieldEntry) return specialFieldEntry;
|
||||
|
||||
const value = sanitizeValue(props.value);
|
||||
if (isImageValue(value)) {
|
||||
return [createImageEntry(props.fieldKey, value)];
|
||||
@@ -200,14 +245,27 @@ const renderFieldEntries = computed(() => {
|
||||
const isIgnoredField = computed(() => IGNORED_FIELD_KEYS.includes(props.fieldKey));
|
||||
const shouldRenderField = computed(() => renderFieldEntries.value.length > 0);
|
||||
|
||||
const hasMapLocation = (spot) => {
|
||||
return Number.isFinite(spot?.latitude) && Number.isFinite(spot?.longitude);
|
||||
};
|
||||
|
||||
const openMap = (spot) => {
|
||||
if (!hasMapLocation(spot)) {
|
||||
uni.showToast({
|
||||
title: "暂无位置信息",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const latitude = spot.latitude;
|
||||
const longitude = spot.longitude;
|
||||
const address = spot.name || '';
|
||||
const name = spot.name || "";
|
||||
const address = spot.description || name;
|
||||
uni.getLocation({ type: 'gcj02', success: () => {
|
||||
uni.openLocation({ latitude, longitude, address });
|
||||
uni.openLocation({ latitude, longitude, name, address });
|
||||
}, fail: () => {
|
||||
uni.openLocation({ latitude, longitude, address });
|
||||
uni.openLocation({ latitude, longitude, name, address });
|
||||
}});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user