| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <template>
- <view class="container">
- <!-- 顶部导航栏 -->
- <view class="header">
- <view class="back-btn" @click="goBack">
- <text class="back-icon">←</text>
- </view>
- <text class="header-title">笔记</text>
- <view class="header-right"></view>
- </view>
-
- <!-- 笔记列表 -->
- <scroll-view class="scroll-content" scroll-y>
- <view
- class="note-item"
- v-for="(item, index) in noteList"
- :key="index"
- @click="goToBookNotes(item)"
- >
- <image class="book-cover" :src="item.cover" mode="aspectFill" :lazy-load="true"></image>
- <view class="book-info">
- <text class="book-title">{{ item.title }}</text>
- <text class="note-count">{{ item.noteCount }}个笔记</text>
- </view>
- </view>
-
- <!-- 空状态 -->
- <view class="empty-state" v-if="noteList.length === 0">
- <text class="empty-text">暂无笔记</text>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- export default {
- data() {
- const getRandomImage = (seed) => {
- return `https://picsum.photos/seed/${seed}/200/300`;
- };
-
- return {
- noteList: [
- {
- id: 1,
- title: '西游记',
- cover: getRandomImage('notes1'),
- noteCount: 3
- },
- {
- id: 2,
- title: '孝经 (中华经典诵读)',
- cover: getRandomImage('notes2'),
- noteCount: 10
- },
- {
- id: 3,
- title: '西游记',
- cover: getRandomImage('notes3'),
- noteCount: 4
- },
- {
- id: 4,
- title: '孝经 (中华经典诵读)',
- cover: getRandomImage('notes4'),
- noteCount: 10
- },
- {
- id: 5,
- title: '红楼梦',
- cover: getRandomImage('notes5'),
- noteCount: 5
- },
- {
- id: 6,
- title: '三国演义',
- cover: getRandomImage('notes6'),
- noteCount: 8
- }
- ]
- }
- },
- onLoad() {
- // 可以在这里加载用户的笔记列表
- this.loadNotes()
- },
- methods: {
- goBack() {
- uni.navigateBack()
- },
- goToBookNotes(item) {
- // 跳转到该书籍的笔记详情页
- uni.navigateTo({
- url: `/pages/book-notes/book-notes?bookId=${item.id}&title=${encodeURIComponent(item.title)}&cover=${encodeURIComponent(item.cover)}`
- })
- },
- loadNotes() {
- // 这里可以调用API获取用户的笔记列表
- // uni.request({
- // url: '/api/notes/list',
- // success: (res) => {
- // this.noteList = res.data
- // }
- // })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- width: 100%;
- height: 100vh;
- min-height: 100vh;
- background-color: #FFFFFF;
- display: flex;
- padding-top: 30px;
- box-sizing: border-box;
- flex-direction: column;
- box-sizing: border-box;
- overflow: hidden;
- }
-
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20rpx 30rpx;
- padding-top: calc(20rpx + env(safe-area-inset-top));
- background-color: #FFFFFF;
- border-bottom: 1rpx solid #F0F0F0;
- position: relative;
- flex-shrink: 0;
- box-sizing: border-box;
- }
-
- .back-btn {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 10;
- }
-
- .back-icon {
- font-size: 40rpx;
- color: #333333;
- font-weight: bold;
- }
-
- .header-title {
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- font-size: 36rpx;
- font-weight: bold;
- color: #333333;
- }
-
- .header-right {
- width: 60rpx;
- }
-
- .scroll-content {
- flex: 1;
- width: 100%;
- height: 0;
- overflow: hidden;
- padding-bottom: calc(env(safe-area-inset-bottom));
- background-color: #FFFFFF;
- box-sizing: border-box;
- }
-
- .note-item {
- display: flex;
- align-items: center;
- padding: 30rpx;
- border-bottom: 1rpx solid #F0F0F0;
- background-color: #FFFFFF;
- width: 100%;
- box-sizing: border-box;
- }
-
- .note-item:last-child {
- border-bottom: none;
- }
-
- .book-cover {
- width: 120rpx;
- height: 160rpx;
- border-radius: 8rpx;
- margin-right: 30rpx;
- flex-shrink: 0;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
- background-color: #F5F5F5;
- }
-
- .book-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- min-width: 0;
- }
-
- .book-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333333;
- margin-bottom: 15rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .note-count {
- font-size: 26rpx;
- color: #999999;
- }
-
- .empty-state {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 200rpx 0;
- }
-
- .empty-text {
- font-size: 28rpx;
- color: #999999;
- }
- </style>
|