-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1303bd
commit 7f84c78
Showing
4 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Page({ | ||
data: { | ||
dogDiaries: [] | ||
}, | ||
|
||
onLoad: function () { | ||
this.getDogDiaries(); | ||
}, | ||
|
||
getDogDiaries: function () { | ||
const userId = wx.getStorageSync('userId'); // 获取存储的用户ID | ||
|
||
wx.cloud.callFunction({ | ||
name: 'getDogDiaries', | ||
data: { | ||
userId | ||
}, | ||
success: res => { | ||
if (res.result.success) { | ||
this.setData({ | ||
dogDiaries: res.result.data | ||
}); | ||
} else { | ||
console.error('Error:', res.result.error); | ||
} | ||
}, | ||
fail: err => { | ||
console.error('Call function failed:', err); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pages": [ | ||
"pages/diary/diary" | ||
] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<view class="container"> | ||
<!-- 上方可横向滑动区域 --> | ||
<scroll-view class="dog-scroll" scroll-x="true" scroll-with-animation> | ||
<block wx:for="{{dogs}}" wx:key="id"> | ||
<view class="dog-avatar-container" bindtap="selectDog" data-id="{{item._id}}"> | ||
<image class="dog-avatar" src="{{item.image}}" mode="cover"></image> | ||
</view> | ||
</block> | ||
</scroll-view> | ||
|
||
<!-- 下方竖向滑动的日记区域 --> | ||
<scroll-view class="diary-scroll" scroll-y="true" scroll-with-animation style="flex: 1;"> | ||
<block wx:for="{{posts}}" wx:key="id"> | ||
<view class="post-container" bindtap="viewPost" data-id="{{item.id}}"> | ||
<view class="post-header"> | ||
<image class="post-dog-avatar" src="{{item.dogAvatarUrl}}" mode="cover"></image> | ||
<text class="post-date">{{item.date}}</text> | ||
</view> | ||
<text class="post-content">{{item.content}}</text> | ||
<view class="post-footer"> | ||
<image class="like-icon" src="/images/like.png" bindtap="likePost" data-id="{{item.id}}"></image> | ||
<text class="like-count">{{item.likes}} likes</text> | ||
</view> | ||
</view> | ||
</block> | ||
</scroll-view> | ||
</view> | ||
<tabbar selected="index"></tabbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
html, body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
overflow: hidden; /* 禁止页面滚动 */ | ||
} | ||
|
||
.container { | ||
width: 100%; | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; /* 确保内容在容器中间 */ | ||
} | ||
|
||
.dog-scroll { | ||
display: flex; | ||
overflow-x: auto; /* 只允许横向滚动 */ | ||
padding: 10px 0; | ||
white-space: nowrap; | ||
margin-top: 20px; | ||
} | ||
|
||
.dog-avatar-container { | ||
display: inline-block; | ||
width: 100px; | ||
height: 100px; | ||
margin-right: 10px; | ||
} | ||
|
||
.dog-avatar { | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 50%; | ||
overflow: hidden; | ||
} | ||
|
||
.diary-scroll { | ||
width: 100%; | ||
margin-top: 20px; | ||
flex: 1; | ||
} | ||
|
||
.post-container { | ||
background-color: white; | ||
margin-bottom: 10px; | ||
padding: 10px; | ||
border-radius: 5px; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.post-header { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.post-dog-avatar { | ||
width: 40px; | ||
height: 40px; | ||
border-radius: 50%; | ||
margin-right: 10px; | ||
} | ||
|
||
.post-date { | ||
font-size: 14px; | ||
color: #888; | ||
} | ||
|
||
.post-content { | ||
margin-top: 10px; | ||
font-size: 16px; | ||
color: #333; | ||
white-space: normal; | ||
word-wrap: break-word; /* 确保文本自动换行 */ | ||
} | ||
|
||
.post-footer { | ||
margin-top: 10px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.like-icon { | ||
width: 20px; | ||
height: 20px; | ||
margin-right: 5px; | ||
} | ||
|
||
.like-count { | ||
font-size: 14px; | ||
color: #888; | ||
} |