feat: 修复wiki样式问题
This commit is contained in:
@@ -59,6 +59,22 @@ const INITIAL_GROWTH_RECORDS = [
|
||||
title: '购入记录',
|
||||
content: '在花市购入,高度约30cm,有5片成熟叶子。',
|
||||
image: 'monstera_plant_1769757312755.png'
|
||||
},
|
||||
{
|
||||
id: '9',
|
||||
date: '2025-08-15',
|
||||
type: 'growth',
|
||||
title: '生机勃勃',
|
||||
content: '夏天长得飞快,已经是一盆茂盛的小森林了。',
|
||||
image: 'succulent_garden_1769757406309.png'
|
||||
},
|
||||
{
|
||||
id: '10',
|
||||
date: '2025-07-01',
|
||||
type: 'growth',
|
||||
title: '第一片叶子',
|
||||
content: '入手后的第一片新叶,浅绿色的非常娇嫩。',
|
||||
image: 'snake_plant_1769757638773.png'
|
||||
}
|
||||
];
|
||||
|
||||
@@ -99,7 +115,8 @@ Page({
|
||||
// Growth Modal
|
||||
showGrowthModal: false,
|
||||
newRecordType: 'growth',
|
||||
newRecordContent: ''
|
||||
newRecordContent: '',
|
||||
newRecordImage: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -198,7 +215,14 @@ Page({
|
||||
},
|
||||
|
||||
// Growth Record Logic
|
||||
openGrowthModal() { this.setData({ showGrowthModal: true, newRecordContent: '', newRecordType: 'growth' }); },
|
||||
openGrowthModal() {
|
||||
this.setData({
|
||||
showGrowthModal: true,
|
||||
newRecordContent: '',
|
||||
newRecordType: 'growth',
|
||||
newRecordImage: ''
|
||||
});
|
||||
},
|
||||
onGrowthPopupVisibleChange(e) { this.setData({ showGrowthModal: e.detail.visible }); },
|
||||
closeGrowthModal() { this.setData({ showGrowthModal: false }); },
|
||||
|
||||
@@ -214,6 +238,33 @@ Page({
|
||||
},
|
||||
onRecordContentInput(e) { this.setData({ newRecordContent: e.detail.value }); },
|
||||
|
||||
handleChooseRecordImage() {
|
||||
wx.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
this.setData({
|
||||
newRecordImage: res.tempFiles[0].tempFilePath
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handleRemoveRecordImage() {
|
||||
this.setData({ newRecordImage: '' });
|
||||
},
|
||||
|
||||
handlePreviewRecordImage(e) {
|
||||
const src = e.currentTarget.dataset.src;
|
||||
const fullPath = (src.indexOf('http') === 0 || src.indexOf('wxfile') === 0) ? src : `/assets/${src}`;
|
||||
|
||||
wx.previewImage({
|
||||
current: fullPath,
|
||||
urls: [fullPath]
|
||||
});
|
||||
},
|
||||
|
||||
handleAddRecord() {
|
||||
if (!this.data.newRecordContent.trim()) return;
|
||||
|
||||
@@ -226,7 +277,8 @@ Page({
|
||||
date: dateStr,
|
||||
type: this.data.newRecordType,
|
||||
title: mapTitle[this.data.newRecordType],
|
||||
content: this.data.newRecordContent
|
||||
content: this.data.newRecordContent,
|
||||
image: this.data.newRecordImage
|
||||
};
|
||||
|
||||
this.setData({
|
||||
|
||||
@@ -140,7 +140,15 @@
|
||||
<text>{{item.title}}</text>
|
||||
</view>
|
||||
<text class="timeline-desc">{{item.content}}</text>
|
||||
<t-image wx:if="{{item.image}}" src="{{tools.resolvePath(item.image)}}" mode="widthFix" width="100%" class="timeline-img" />
|
||||
<t-image
|
||||
wx:if="{{item.image}}"
|
||||
src="{{tools.resolvePath(item.image)}}"
|
||||
mode="widthFix"
|
||||
width="100%"
|
||||
class="timeline-img"
|
||||
bindtap="handlePreviewRecordImage"
|
||||
data-src="{{item.image}}"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -200,6 +208,22 @@
|
||||
auto-height
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- Image Upload -->
|
||||
<view class="form-group">
|
||||
<text class="form-label">添加照片</text>
|
||||
<view class="record-image-upload">
|
||||
<view wx:if="{{newRecordImage}}" class="uploaded-image-box">
|
||||
<t-image src="{{newRecordImage}}" mode="aspectFill" width="160rpx" height="160rpx" shape="round" />
|
||||
<view class="remove-img-btn" bindtap="handleRemoveRecordImage">
|
||||
<t-icon name="close" size="24rpx" color="#FFF" />
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else class="upload-add-btn" bindtap="handleChooseRecordImage">
|
||||
<t-icon name="add" size="48rpx" color="#999" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="modal-footer" catchtouchmove="preventTouchMove">
|
||||
|
||||
@@ -714,3 +714,50 @@ page {
|
||||
box-shadow: 0 0 0 6rpx rgba(85, 139, 47, 0.1);
|
||||
}
|
||||
|
||||
/* Record Image Upload */
|
||||
.record-image-upload {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.upload-add-btn {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
background: #FAFAFA;
|
||||
border: 2rpx dashed #d9d9d9;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.upload-add-btn:active {
|
||||
background: #F0F0F0;
|
||||
border-color: #558B2F;
|
||||
}
|
||||
|
||||
.uploaded-image-box {
|
||||
position: relative;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
.remove-img-btn {
|
||||
position: absolute;
|
||||
top: -12rpx;
|
||||
right: -12rpx;
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 10;
|
||||
backdrop-filter: blur(4rpx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user