notes.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航栏 -->
  4. <view class="header">
  5. <view class="back-btn" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <text class="header-title">笔记</text>
  9. <view class="header-right"></view>
  10. </view>
  11. <!-- 笔记列表 -->
  12. <scroll-view class="scroll-content" scroll-y>
  13. <view
  14. class="note-item"
  15. v-for="(item, index) in noteList"
  16. :key="index"
  17. @click="goToBookNotes(item)"
  18. >
  19. <image class="book-cover" :src="item.cover" mode="aspectFill" :lazy-load="true"></image>
  20. <view class="book-info">
  21. <text class="book-title">{{ item.title }}</text>
  22. <text class="note-count">{{ item.noteCount }}个笔记</text>
  23. </view>
  24. </view>
  25. <!-- 空状态 -->
  26. <view class="empty-state" v-if="noteList.length === 0">
  27. <text class="empty-text">暂无笔记</text>
  28. </view>
  29. </scroll-view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. const getRandomImage = (seed) => {
  36. return `https://picsum.photos/seed/${seed}/200/300`;
  37. };
  38. return {
  39. noteList: [
  40. {
  41. id: 1,
  42. title: '西游记',
  43. cover: getRandomImage('notes1'),
  44. noteCount: 3
  45. },
  46. {
  47. id: 2,
  48. title: '孝经 (中华经典诵读)',
  49. cover: getRandomImage('notes2'),
  50. noteCount: 10
  51. },
  52. {
  53. id: 3,
  54. title: '西游记',
  55. cover: getRandomImage('notes3'),
  56. noteCount: 4
  57. },
  58. {
  59. id: 4,
  60. title: '孝经 (中华经典诵读)',
  61. cover: getRandomImage('notes4'),
  62. noteCount: 10
  63. },
  64. {
  65. id: 5,
  66. title: '红楼梦',
  67. cover: getRandomImage('notes5'),
  68. noteCount: 5
  69. },
  70. {
  71. id: 6,
  72. title: '三国演义',
  73. cover: getRandomImage('notes6'),
  74. noteCount: 8
  75. }
  76. ]
  77. }
  78. },
  79. onLoad() {
  80. // 可以在这里加载用户的笔记列表
  81. this.loadNotes()
  82. },
  83. methods: {
  84. goBack() {
  85. uni.navigateBack()
  86. },
  87. goToBookNotes(item) {
  88. // 跳转到该书籍的笔记详情页
  89. uni.navigateTo({
  90. url: `/pages/book-notes/book-notes?bookId=${item.id}&title=${encodeURIComponent(item.title)}&cover=${encodeURIComponent(item.cover)}`
  91. })
  92. },
  93. loadNotes() {
  94. // 这里可以调用API获取用户的笔记列表
  95. // uni.request({
  96. // url: '/api/notes/list',
  97. // success: (res) => {
  98. // this.noteList = res.data
  99. // }
  100. // })
  101. }
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. .container {
  107. width: 100%;
  108. height: 100vh;
  109. min-height: 100vh;
  110. background-color: #FFFFFF;
  111. display: flex;
  112. padding-top: 30px;
  113. box-sizing: border-box;
  114. flex-direction: column;
  115. box-sizing: border-box;
  116. overflow: hidden;
  117. }
  118. .header {
  119. display: flex;
  120. align-items: center;
  121. justify-content: space-between;
  122. padding: 20rpx 30rpx;
  123. padding-top: calc(20rpx + env(safe-area-inset-top));
  124. background-color: #FFFFFF;
  125. border-bottom: 1rpx solid #F0F0F0;
  126. position: relative;
  127. flex-shrink: 0;
  128. box-sizing: border-box;
  129. }
  130. .back-btn {
  131. width: 60rpx;
  132. height: 60rpx;
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. z-index: 10;
  137. }
  138. .back-icon {
  139. font-size: 40rpx;
  140. color: #333333;
  141. font-weight: bold;
  142. }
  143. .header-title {
  144. position: absolute;
  145. left: 50%;
  146. transform: translateX(-50%);
  147. font-size: 36rpx;
  148. font-weight: bold;
  149. color: #333333;
  150. }
  151. .header-right {
  152. width: 60rpx;
  153. }
  154. .scroll-content {
  155. flex: 1;
  156. width: 100%;
  157. height: 0;
  158. overflow: hidden;
  159. padding-bottom: calc(env(safe-area-inset-bottom));
  160. background-color: #FFFFFF;
  161. box-sizing: border-box;
  162. }
  163. .note-item {
  164. display: flex;
  165. align-items: center;
  166. padding: 30rpx;
  167. border-bottom: 1rpx solid #F0F0F0;
  168. background-color: #FFFFFF;
  169. width: 100%;
  170. box-sizing: border-box;
  171. }
  172. .note-item:last-child {
  173. border-bottom: none;
  174. }
  175. .book-cover {
  176. width: 120rpx;
  177. height: 160rpx;
  178. border-radius: 8rpx;
  179. margin-right: 30rpx;
  180. flex-shrink: 0;
  181. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
  182. background-color: #F5F5F5;
  183. }
  184. .book-info {
  185. flex: 1;
  186. display: flex;
  187. flex-direction: column;
  188. justify-content: center;
  189. min-width: 0;
  190. }
  191. .book-title {
  192. font-size: 32rpx;
  193. font-weight: bold;
  194. color: #333333;
  195. margin-bottom: 15rpx;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. white-space: nowrap;
  199. }
  200. .note-count {
  201. font-size: 26rpx;
  202. color: #999999;
  203. }
  204. .empty-state {
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. padding: 200rpx 0;
  209. }
  210. .empty-text {
  211. font-size: 28rpx;
  212. color: #999999;
  213. }
  214. </style>