open Location in journal-map
This commit is contained in:
@ -22,38 +22,23 @@ interface JournalDetailPanelData {
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
// 是否显示
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
// 标题(如 "2024 年 1 月 1 日" 或位置名称)
|
||||
title: {
|
||||
type: String,
|
||||
value: ""
|
||||
},
|
||||
// 日记列表
|
||||
journals: {
|
||||
type: Array,
|
||||
value: []
|
||||
},
|
||||
// 是否显示标题位置图标
|
||||
showLocationIcon: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
// 是否显示每条日记的日期
|
||||
showJournalDate: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
// 是否显示每条日记的位置
|
||||
showJournalLocation: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
mode: {
|
||||
type: String,
|
||||
value: "DATE"
|
||||
}
|
||||
},
|
||||
|
||||
data: <JournalDetailPanelData>{
|
||||
currentJournalIndex: 0,
|
||||
},
|
||||
@ -72,20 +57,21 @@ Component({
|
||||
methods: {
|
||||
/** 关闭详情 */
|
||||
closeDetail() {
|
||||
this.triggerEvent('close');
|
||||
this.triggerEvent("close");
|
||||
},
|
||||
|
||||
/** swiper 切换事件 */
|
||||
onSwiperChange(e: WechatMiniprogram.SwiperChange) {
|
||||
this.setData({
|
||||
currentJournalIndex: e.detail.current
|
||||
});
|
||||
},
|
||||
|
||||
openLocation(e: WechatMiniprogram.BaseEvent) {
|
||||
const { journalIndex } = e.currentTarget.dataset;
|
||||
if (!journalIndex && this.properties.mode !== "LOCATION") {
|
||||
return;
|
||||
}
|
||||
const journals = this.properties.journals as JournalInfo[];
|
||||
const journal = journals[journalIndex];
|
||||
const journal = journals[journalIndex || 0];
|
||||
if (journal.lat && journal.lng) {
|
||||
wx.openLocation({
|
||||
latitude: journal.lat,
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
<view class="detail-content">
|
||||
<view class="header">
|
||||
<view class="info">
|
||||
<view wx:if="{{title}}" class="title">
|
||||
<t-icon wx:if="{{showLocationIcon}}" class="icon" name="location-filled" />
|
||||
<view wx:if="{{title}}" class="title" catchtap="openLocation">
|
||||
<t-icon wx:if="{{mode === 'LOCATION'}}" class="icon" name="location-filled" />
|
||||
<text>{{title}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -27,7 +27,7 @@
|
||||
<view class="journal-item">
|
||||
<view class="journal-header">
|
||||
<view
|
||||
wx:if="{{item.location && showJournalLocation}}"
|
||||
wx:if="{{item.location && mode === 'DATE'}}"
|
||||
class="location"
|
||||
catchtap="openLocation"
|
||||
data-journal-index="{{currentJournalIndex}}"
|
||||
@ -35,7 +35,7 @@
|
||||
<t-icon class="icon" name="location-filled" />
|
||||
<text class="text">{{item.location}}</text>
|
||||
</view>
|
||||
<view wx:if="{{showJournalDate}}" class="date">{{item.date}}</view>
|
||||
<view wx:if="{{mode === 'LOCATION'}}" class="date">{{item.date}}</view>
|
||||
</view>
|
||||
<view wx:if="{{item.idea}}" class="idea">{{item.idea}}</view>
|
||||
<scroll-view wx:if="{{item.items && item.items.length > 0}}" scroll-y class="items-scroll">
|
||||
|
||||
Reference in New Issue
Block a user