first
This commit is contained in:
107
pages/detail/detail.js
Normal file
107
pages/detail/detail.js
Normal file
@@ -0,0 +1,107 @@
|
||||
Page({
|
||||
data: {
|
||||
dream: {},
|
||||
dreamId: '',
|
||||
emotions: [
|
||||
{ name: '开心', value: 'happy', icon: 'smile' },
|
||||
{ name: '害怕', value: 'scared', icon: 'warn' },
|
||||
{ name: '治愈', value: 'healing', icon: 'like' },
|
||||
{ name: '怪异', value: 'strange', icon: 'question' },
|
||||
{ name: '悲伤', value: 'sad', icon: 'cry' },
|
||||
{ name: '愤怒', value: 'angry', icon: 'no' },
|
||||
{ name: '紧张', value: 'nervous', icon: 'waiting' },
|
||||
{ name: '平静', value: 'calm', icon: 'sleep' }
|
||||
]
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const id = options.id;
|
||||
this.setData({
|
||||
dreamId: id
|
||||
});
|
||||
this.loadDreamDetail(id);
|
||||
},
|
||||
|
||||
// 加载梦境详情
|
||||
loadDreamDetail(id) {
|
||||
wx.getStorage({
|
||||
key: 'dreamRecords',
|
||||
success: (res) => {
|
||||
const records = res.data || [];
|
||||
const dream = records.find(record => record.id === id);
|
||||
|
||||
if (dream) {
|
||||
this.setData({
|
||||
dream
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '未找到记录',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取情绪图标
|
||||
getEmotionIcon(emotion) {
|
||||
const emotionObj = this.data.emotions.find(item => item.value === emotion);
|
||||
return emotionObj ? emotionObj.icon : 'info';
|
||||
},
|
||||
|
||||
// 获取情绪名称
|
||||
getEmotionName(emotion) {
|
||||
const emotionObj = this.data.emotions.find(item => item.value === emotion);
|
||||
return emotionObj ? emotionObj.name : '';
|
||||
},
|
||||
|
||||
// 删除记录
|
||||
deleteRecord() {
|
||||
const that = this;
|
||||
wx.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除这条梦境记录吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
wx.getStorage({
|
||||
key: 'dreamRecords',
|
||||
success: (res) => {
|
||||
let records = res.data || [];
|
||||
records = records.filter(record => record.id !== that.data.dreamId);
|
||||
|
||||
wx.setStorage({
|
||||
key: 'dreamRecords',
|
||||
data: records,
|
||||
success: () => {
|
||||
wx.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 编辑记录
|
||||
editRecord() {
|
||||
// 在实际应用中,这里应该跳转到编辑页面
|
||||
// 并传递当前记录的数据
|
||||
wx.showToast({
|
||||
title: '编辑功能开发中',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
3
pages/detail/detail.json
Normal file
3
pages/detail/detail.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
82
pages/detail/detail.wxml
Normal file
82
pages/detail/detail.wxml
Normal file
@@ -0,0 +1,82 @@
|
||||
<view class="container">
|
||||
<view class="detail-header">
|
||||
<text class="dream-title">{{dream.title}}</text>
|
||||
<text class="dream-date">{{dream.date}}</text>
|
||||
|
||||
<!-- 情绪指示器 -->
|
||||
<view class="emotion-indicator" wx:if="{{dream.emotion}}">
|
||||
<icon
|
||||
type="{{getEmotionIcon(dream.emotion)}}"
|
||||
size="20"
|
||||
color="#4a6fa5"
|
||||
/>
|
||||
<text class="emotion-text">{{getEmotionName(dream.emotion)}}</text>
|
||||
</view>
|
||||
|
||||
<!-- 标签区域 -->
|
||||
<view class="tags-container" wx:if="{{dream.tags.length > 0}}">
|
||||
<view
|
||||
wx:for="{{dream.tags}}"
|
||||
wx:key="index"
|
||||
class="tag"
|
||||
>
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 详情内容 -->
|
||||
<view class="detail-content">
|
||||
<!-- 场景 -->
|
||||
<view class="content-section" wx:if="{{dream.scene}}">
|
||||
<view class="section-header">
|
||||
<icon type="location" size="18" color="#4a6fa5" />
|
||||
<text class="section-title">场景</text>
|
||||
</view>
|
||||
<text class="section-content">{{dream.scene}}</text>
|
||||
</view>
|
||||
|
||||
<!-- 人物 -->
|
||||
<view class="content-section" wx:if="{{dream.characters}}">
|
||||
<view class="section-header">
|
||||
<icon type="user" size="18" color="#4a6fa5" />
|
||||
<text class="section-title">人物</text>
|
||||
</view>
|
||||
<text class="section-content">{{dream.characters}}</text>
|
||||
</view>
|
||||
|
||||
<!-- 情节 -->
|
||||
<view class="content-section" wx:if="{{dream.plot}}">
|
||||
<view class="section-header">
|
||||
<icon type="list" size="18" color="#4a6fa5" />
|
||||
<text class="section-title">情节</text>
|
||||
</view>
|
||||
<text class="section-content">{{dream.plot}}</text>
|
||||
</view>
|
||||
|
||||
<!-- 其他细节 -->
|
||||
<view class="content-section" wx:if="{{dream.details}}">
|
||||
<view class="section-header">
|
||||
<icon type="info" size="18" color="#4a6fa5" />
|
||||
<text class="section-title">其他细节</text>
|
||||
</view>
|
||||
<text class="section-content">{{dream.details}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<view class="action-buttons">
|
||||
<button
|
||||
class="delete-btn"
|
||||
bindtap="deleteRecord"
|
||||
>
|
||||
删除记录
|
||||
</button>
|
||||
<button
|
||||
class="edit-btn"
|
||||
bindtap="editRecord"
|
||||
>
|
||||
编辑记录
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
1
pages/detail/detail.wxss
Normal file
1
pages/detail/detail.wxss
Normal file
@@ -0,0 +1 @@
|
||||
/* pages/detail/detail.wxss */
|
||||
Reference in New Issue
Block a user