图书馆小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

270 lines
7.0 KiB

2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
  1. <template>
  2. <view class="detail-container">
  3. <!-- 书籍头部信息 -->
  4. <view class="article-detail-container">
  5. <view class="article-detail-left">
  6. <view class="article-detail-title">名侦探柯南</view>
  7. <view class="article-detail-info">
  8. <view class="article-detail-author">青山刚昌 </view>
  9. <view class="article-detail-time">长春出版社</view>
  10. <view class="article-detail-time">ISBN7-80664-373-7</view>
  11. <view class="article-detail-time">出版时间2023</view>
  12. </view>
  13. </view>
  14. <view class="article-detail-right">
  15. <image
  16. src="https://qiniu.aiyxlib.com/1606124577077"
  17. mode="widthFix"
  18. />
  19. </view>
  20. </view>
  21. <!-- 馆藏信息 -->
  22. <view class="book-store-info">
  23. <view class="book-store-info-item">
  24. <text class="store-txt1">39</text>
  25. <text class="store-txt2">总馆藏量</text>
  26. </view>
  27. <view class="book-store-info-item">
  28. <text class="store-txt1">38</text>
  29. <text class="store-txt2">在馆</text>
  30. </view>
  31. <view class="book-store-info-item">
  32. <text class="store-txt1">1</text>
  33. <text class="store-txt2">借出</text>
  34. </view>
  35. </view>
  36. <!-- 索书号/条码号 -->
  37. <view class="store-info-list">
  38. <view class="store-info-item">
  39. <view>
  40. <text>索书号</text>
  41. <text>J238.7/5</text>
  42. </view>
  43. <view>
  44. <text>条码号</text>
  45. <text>14018019711</text>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- TAB 选项卡 -->
  50. <view class="content-tab">
  51. <view class="tab-item" :class="{active: currentTab === 0}" @click="currentTab = 0">
  52. 内容简介
  53. </view>
  54. <view class="tab-item" :class="{active: currentTab === 1}" @click="currentTab = 1">
  55. 作者简介
  56. </view>
  57. </view>
  58. <!-- TAB 内容 -->
  59. <view class="content-item" v-if="currentTab === 0">
  60. 名侦探柯南是日本漫画家青山刚昌创作的著名侦探漫画作品讲述了高中生侦探工藤新一被灌下毒药后身体缩小化名为江户川柯南秘密调查黑暗组织并解决无数离奇案件的故事作品兼具推理冒险情感与幽默元素是全球极具影响力的经典漫画
  61. </view>
  62. <view class="content-item" v-if="currentTab === 1">
  63. 青山刚昌日本著名漫画家1963 年生于鸟取县代表作包括名侦探柯南魔术快斗他擅长推理题材与人物塑造画风细腻剧情严谨作品在全球多个国家出版深受各年龄层读者喜爱
  64. </view>
  65. <view class="detail-bottom">
  66. <view class="detail-left">
  67. <!-- #ifdef MP-WEIXIN -->
  68. <button open-type="share" class="handle-btn">
  69. <uni-icons custom-prefix="iconfont" type="icon-fenxiang01" size="20"></uni-icons>
  70. <text class="share-text">分享</text>
  71. </button>
  72. <!-- #endif -->
  73. <button class="handle-btn" @click="toggleCollect">
  74. <!-- 已收藏 / 未收藏 自动切换图标 -->
  75. <uni-icons :type="isCollected ? 'heart-filled' : 'heart'" size="20" color="#ff4444"></uni-icons>
  76. <text class="share-text">{{ isCollected ? '已收藏' : '收藏' }}</text>
  77. </button>
  78. </view>
  79. <button class="join-btn">
  80. <text>我要借书</text>
  81. </button>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. export default {
  87. data() {
  88. return {
  89. currentTab: 0, // 0=内容简介 1=作者简介
  90. isCollected: false, // 收藏状态
  91. bookIsbn: "" // 图书唯一标识 ISBN
  92. };
  93. },
  94. onLoad(options) {
  95. // 接收从上一页传来的 ISBN
  96. this.bookIsbn = options.isbn || "7-80664-373-7";
  97. // 检查是否已收藏
  98. this.checkCollectStatus();
  99. },
  100. methods: {
  101. // 检查收藏状态
  102. checkCollectStatus() {
  103. const collectList = uni.getStorageSync("collectList") || [];
  104. this.isCollected = collectList.includes(this.bookIsbn);
  105. },
  106. // 切换收藏 / 取消收藏
  107. toggleCollect() {
  108. let collectList = uni.getStorageSync("collectList") || [];
  109. if (this.isCollected) {
  110. // 取消收藏
  111. collectList = collectList.filter((item) => item !== this.bookIsbn);
  112. uni.showToast({ title: "取消收藏成功", icon: "success" });
  113. } else {
  114. // 添加收藏
  115. collectList.push(this.bookIsbn);
  116. uni.showToast({ title: "收藏成功", icon: "success" });
  117. }
  118. // 保存到本地
  119. uni.setStorageSync("collectList", collectList);
  120. // 更新状态
  121. this.isCollected = !this.isCollected;
  122. }
  123. },
  124. // 微信分享
  125. onShareAppMessage() {
  126. return {
  127. title: '名侦探柯南',
  128. path: '/subpkg/pages/book-detail/book-detail?isbn=7-80664-373-7',
  129. imageUrl: 'https://qiniu.aiyxlib.com/1606124577077'
  130. };
  131. }
  132. };
  133. </script>
  134. <style lang="scss" scoped>
  135. .detail-container {
  136. padding: 15px;
  137. background-color: #f5f5f5;
  138. min-height: 100vh;
  139. padding-bottom: 60px;
  140. }
  141. /* 书籍信息 */
  142. .article-detail-container {
  143. display: flex;
  144. background-color: #fff;
  145. border-radius: 10px;
  146. padding: 20px;
  147. margin-bottom: 12px;
  148. }
  149. .article-detail-left {
  150. flex: 1;
  151. }
  152. .article-detail-title {
  153. font-size: 20px;
  154. font-weight: bold;
  155. color: #333;
  156. margin-bottom: 10px;
  157. }
  158. .article-detail-info {
  159. font-size: 14px;
  160. color: #666;
  161. line-height: 1.5;
  162. }
  163. .article-detail-right {
  164. width: 110px;
  165. height: 150px;
  166. margin-left: 15px;
  167. }
  168. .article-detail-right image {
  169. width: 100%;
  170. height: 100%;
  171. border-radius: 6px;
  172. box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  173. }
  174. /* 馆藏统计 */
  175. .book-store-info {
  176. background-color: #fff;
  177. border-radius: 10px;
  178. padding: 20px;
  179. display: flex;
  180. justify-content: space-around;
  181. margin-bottom: 12px;
  182. }
  183. .book-store-info-item {
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. }
  188. .store-txt1 {
  189. font-size: 22px;
  190. font-weight: bold;
  191. color: #2b85e4;
  192. }
  193. .store-txt2 {
  194. font-size: 13px;
  195. color: #999;
  196. margin-top: 4px;
  197. }
  198. /* 索书号 */
  199. .store-info-list {
  200. background-color: #fff;
  201. border-radius: 10px;
  202. padding: 20px;
  203. margin-bottom: 15px;
  204. }
  205. .store-info-item {
  206. display: flex;
  207. justify-content: space-between;
  208. font-size: 14px;
  209. color: #666;
  210. }
  211. .store-info-item view {
  212. display: flex;
  213. flex-direction: column;
  214. align-items: center;
  215. }
  216. /* TAB */
  217. .content-tab {
  218. display: flex;
  219. background-color: #fff;
  220. border-radius: 10px;
  221. overflow: hidden;
  222. margin-bottom: 12px;
  223. }
  224. .tab-item {
  225. flex: 1;
  226. text-align: center;
  227. padding: 15px 0;
  228. font-size: 15px;
  229. color: #666;
  230. position: relative;
  231. }
  232. .tab-item.active {
  233. color: #2b85e4;
  234. font-weight: bold;
  235. }
  236. .tab-item.active::after {
  237. content: "";
  238. position: absolute;
  239. bottom: 0;
  240. left: 50%;
  241. transform: translateX(-50%);
  242. width: 30px;
  243. height: 3px;
  244. background-color: #2b85e4;
  245. border-radius: 2px;
  246. }
  247. /* 内容区域 */
  248. .content-item {
  249. background-color: #fff;
  250. border-radius: 10px;
  251. padding: 20px;
  252. font-size: 15px;
  253. color: #333;
  254. line-height: 1.6;
  255. }
  256. </style>