/* * Copyright (c) Baidu, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import {Component} from 'san'; import type {LocationCardData, LocationCardProps} from './interface'; import Image from '@cosui/cosmic/image'; import Score from '@cosui/cosmic/score'; import Tag from '@cosui/cosmic/tag'; export default class LocationCard extends Component { static template = ` `; static trimWhitespace = 'all'; static components = { 'cos-image': Image, 'cos-score': Score, 'cos-tag': Tag }; static computed = { _tags(this: LocationCard) { const tags = this.data.get('tags'); const _tags = []; // 处理简写形式的标签,默认为灰色、线型 tags.forEach(item => { if (typeof item === 'string') { _tags.push({ text: item }); } else { _tags.push(item); } }); return _tags; } }; initData(): LocationCardProps { return { linkInfo: { href: '' }, thumbnail: '', title: '', score: undefined, address: '', category: '', averageCost: '', openingHours: '', tags: [] }; } }