图书馆小程序
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.

371 lines
9.8 KiB

2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month 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">{{ bookInfo.title || bookInfo.name || '暂无书名' }}</view>
  7. <view class="article-detail-info">
  8. <view class="article-detail-author">作者{{ bookInfo.author || '暂无' }}</view>
  9. <view class="article-detail-time">出版社{{ bookInfo.publisher || '暂无' }}</view>
  10. <view class="article-detail-time">ISBN{{ bookInfo.isbn || '暂无' }}</view>
  11. <view class="article-detail-time">出版时间{{ bookInfo.pubdate || '暂无' }}</view>
  12. </view>
  13. </view>
  14. <view class="article-detail-right">
  15. <image
  16. class="img-item"
  17. :src="bookInfo.cover || bookInfo.base64Cover || '/static/images/default-book.png'"
  18. mode="widthFix"
  19. @error="onImgError"
  20. ></image>
  21. </view>
  22. </view>
  23. <!-- 馆藏信息 -->
  24. <view v-if="holdingsData.length!==0" class="book-store-info">
  25. <view class="book-store-info-item">
  26. <text class="store-txt1">{{ holdingsData.length || 0 }}</text>
  27. <text class="store-txt2">馆藏总数</text>
  28. </view>
  29. <view class="book-store-info-item">
  30. <text class="store-txt1">{{ inLibraryCount }}</text>
  31. <text class="store-txt2">在馆</text>
  32. </view>
  33. <view class="book-store-info-item">
  34. <text class="store-txt1">{{ lendCount }}</text>
  35. <text class="store-txt2">借出</text>
  36. </view>
  37. </view>
  38. <!-- 索书号/条码号 -->
  39. <view v-if="holdingsData.length!==0" class="store-info-list">
  40. <view class="store-info-item" v-for="(item, index) in holdingsData" :key="index">
  41. <view>
  42. <text class="info-item-title">条码号</text>
  43. <text>{{ item.barcode || '暂无' }}</text>
  44. </view>
  45. <view >
  46. <text class="info-item-title">索书号</text>
  47. <text>{{ item.callno || '暂无' }}</text>
  48. </view>
  49. <view>
  50. <text class="info-item-title">馆藏状态</text>
  51. <text>{{ getStateText(item.state) }}</text>
  52. </view>
  53. <view>
  54. <text class="info-item-title">所在馆</text>
  55. <!-- item.orglib || '葛店经济技术开发区图书馆' -->
  56. <text>葛店经济技术开发区图书馆</text>
  57. </view>
  58. <view>
  59. <text class="info-item-title">当前馆藏地</text>
  60. <text>{{ item.orglocal || '葛店图书馆' }}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- TAB 选项卡 -->
  65. <view class="content-tab">
  66. <view class="tab-item" :class="{active: currentTab === 0}" @click="currentTab = 0">
  67. 内容简介
  68. </view>
  69. <view class="tab-item" :class="{active: currentTab === 1}" @click="currentTab = 1">
  70. 作者简介
  71. </view>
  72. </view>
  73. <!-- TAB 内容 -->
  74. <view class="content-item" v-if="currentTab === 0">
  75. {{ bookInfo.summary || bookInfo.explain || '暂无内容简介' }}
  76. </view>
  77. <view class="content-item" v-if="currentTab === 1">
  78. {{ bookInfo.authorbio || '暂无作者简介' }}
  79. </view>
  80. <view class="detail-bottom">
  81. <button open-type="share" class="handle-btn">
  82. <uni-icons custom-prefix="iconfont" type="icon-fenxiang01" size="20"></uni-icons>
  83. <text class="share-text">分享</text>
  84. </button>
  85. <button v-if="!fromRecommend" class="handle-btn" @click="toggleCollect">
  86. <uni-icons :type="isCollected ? 'heart-filled' : 'heart'" size="20" color="#ff4444"></uni-icons>
  87. <text class="share-text">{{ isCollected ? '已收藏' : '收藏' }}</text>
  88. </button>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import { FetchInitScreenSetting } from '@/api/user';
  94. import { FetchFindbookByQuery } from '@/api/book';
  95. import config from '@/utils/config';
  96. export default {
  97. data() {
  98. return {
  99. baseUrl: config.baseUrl,
  100. currentTab: 0,
  101. isCollected: false,
  102. bookrecno: '',
  103. opacUrl: '',
  104. fromRecommend: false,
  105. bookInfo: {},
  106. holdingsData: [],
  107. };
  108. },
  109. onLoad(options) {
  110. // 1. 首页/列表页 直接带完整 bookData 过来,优先走这个
  111. if (options.bookData) {
  112. const bookData = JSON.parse(decodeURIComponent(options.bookData));
  113. this.bookInfo = bookData;
  114. this.bookrecno = bookData.bookrecno || "";
  115. this.fromRecommend = options.fromRecommend === 'true';
  116. this.holdingsData = [];
  117. this.checkCollectStatus();
  118. return;
  119. }
  120. // 2. 检索页只传 bookrecno,请求接口拿详情
  121. this.bookrecno = options.bookrecno || "";
  122. this.fromRecommend = false;
  123. this.getOpacUrl();
  124. },
  125. computed: {
  126. // 在馆数量
  127. // 馆藏状态,编目=1,在馆=2,借出=3,丢失=4,剔除=5,交换=6,赠送=7,装订=8,锁定=9,预借=10, 清点=12
  128. inLibraryCount() {
  129. return this.holdingsData.filter(item => item.state === 2).length;
  130. },
  131. // 借出数量(新增)
  132. lendCount() {
  133. return this.holdingsData.filter(item => item.state === 3).length;
  134. },
  135. // 第一个馆藏状态
  136. firstStateText() {
  137. if (this.holdingsData.length === 0) return '无馆藏';
  138. return this.getStateText(this.holdingsData[0].state);
  139. }
  140. },
  141. methods: {
  142. onImgError(e) {
  143. e.target.src = "/static/images/default-book.png";
  144. },
  145. // 获取配置
  146. async getOpacUrl() {
  147. try {
  148. const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
  149. this.opacUrl = res.data.opac_url?.context || '';
  150. this.getBookDetail();
  151. } catch (err) {}
  152. },
  153. // 获取图书详情(适配新接口结构)
  154. async getBookDetail() {
  155. if (!this.bookrecno || !this.opacUrl) return;
  156. uni.showLoading({ title: '加载中...' });
  157. try {
  158. const params = {
  159. opacUrl: this.opacUrl,
  160. bookrecno: this.bookrecno
  161. };
  162. const res = await FetchFindbookByQuery(params);
  163. // console.log('bookrecno详情',res);
  164. const apiData = res.data || {};
  165. this.bookInfo = apiData.biblios || {};
  166. // console.log('bookrecno-bookInfo详情',this.bookInfo);
  167. this.holdingsData = apiData.holdings || [];
  168. // console.log('bookrecno-holdingsData详情',this.holdingsData);
  169. this.checkCollectStatus();
  170. } catch (err) {
  171. console.error(err);
  172. } finally {
  173. uni.hideLoading();
  174. }
  175. },
  176. // 馆藏状态文字
  177. getStateText(state) {
  178. const map = {
  179. 1: '编目',
  180. 2: '在馆',
  181. 3: '借出',
  182. 4: '丢失',
  183. 5: '剔除',
  184. 6: '交换',
  185. 7: '赠送',
  186. 8: '装订',
  187. 9: '锁定',
  188. 10: '预借',
  189. 12: '清点'
  190. }
  191. return map[state] || '未知';
  192. },
  193. // 收藏
  194. checkCollectStatus() {
  195. const list = uni.getStorageSync('collectList') || [];
  196. this.isCollected = list.includes(this.bookrecno);
  197. },
  198. toggleCollect() {
  199. let list = uni.getStorageSync('collectList') || [];
  200. if (this.isCollected) {
  201. list = list.filter(i => i !== this.bookrecno);
  202. uni.showToast({ title: '取消收藏', icon: 'success' });
  203. } else {
  204. list.push(this.bookrecno);
  205. uni.showToast({ title: '收藏成功', icon: 'success' });
  206. }
  207. uni.setStorageSync('collectList', list);
  208. this.isCollected = !this.isCollected;
  209. }
  210. },
  211. onShareAppMessage() {
  212. return {
  213. title: this.bookInfo.title || '图书详情',
  214. path: '/subpkg/pages/book-detail/book-detail?bookrecno=' + this.bookrecno,
  215. imageUrl: this.bookInfo.cover
  216. };
  217. }
  218. };
  219. </script>
  220. <style lang="scss" scoped>
  221. .detail-container {
  222. padding: 15px;
  223. background-color: #f5f5f5;
  224. min-height: 100vh;
  225. padding-bottom: 60px;
  226. }
  227. .article-detail-container {
  228. display: flex;
  229. background-color: #fff;
  230. border-radius: 10px;
  231. padding: 20px;
  232. margin-bottom: 12px;
  233. }
  234. .article-detail-left {
  235. flex: 1;
  236. }
  237. .article-detail-title {
  238. font-size: 20px;
  239. font-weight: bold;
  240. color: #333;
  241. margin-bottom: 10px;
  242. }
  243. .article-detail-info {
  244. font-size: 14px;
  245. color: #666;
  246. line-height: 1.5;
  247. }
  248. .article-detail-right {
  249. width: 110px;
  250. height: 150px;
  251. margin-left: 15px;
  252. }
  253. .article-detail-right image {
  254. width: 100%;
  255. height: 100%;
  256. border-radius: 6px;
  257. box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  258. }
  259. .book-store-info {
  260. background-color: #fff;
  261. border-radius: 10px;
  262. padding: 20px;
  263. display: flex;
  264. justify-content: space-around;
  265. margin-bottom: 12px;
  266. }
  267. .book-store-info-item {
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. }
  272. .store-txt1 {
  273. font-size: 22px;
  274. font-weight: bold;
  275. color: #2b85e4;
  276. }
  277. .store-txt2 {
  278. font-size: 13px;
  279. color: #999;
  280. margin-top: 4px;
  281. }
  282. .store-info-list {
  283. background-color: #fff;
  284. border-radius: 10px;
  285. padding: 10px;
  286. margin-bottom: 15px;
  287. }
  288. .store-info-item {
  289. display: flex;
  290. flex-direction: column;
  291. font-size: 14px;
  292. color: #666;
  293. padding: 10px;
  294. margin-bottom: 10px;
  295. border: 1px solid #eee;
  296. }
  297. .store-info-item view {
  298. display: flex;
  299. align-items: center;
  300. justify-content: flex-start;
  301. line-height: 28px;
  302. .info-item-title{
  303. width: 80px;
  304. font-weight: bold;
  305. color: #333;
  306. }
  307. }
  308. .content-tab {
  309. display: flex;
  310. background-color: #fff;
  311. border-radius: 10px;
  312. overflow: hidden;
  313. margin-bottom: 12px;
  314. }
  315. .tab-item {
  316. flex: 1;
  317. text-align: center;
  318. padding: 15px 0;
  319. font-size: 15px;
  320. color: #666;
  321. position: relative;
  322. }
  323. .tab-item.active {
  324. color: #2b85e4;
  325. font-weight: bold;
  326. }
  327. .tab-item.active::after {
  328. content: "";
  329. position: absolute;
  330. bottom: 0;
  331. left: 50%;
  332. transform: translateX(-50%);
  333. width: 30px;
  334. height: 3px;
  335. background-color: #2b85e4;
  336. border-radius: 2px;
  337. }
  338. .content-item {
  339. background-color: #fff;
  340. border-radius: 10px;
  341. padding: 20px;
  342. font-size: 15px;
  343. color: #333;
  344. line-height: 1.6;
  345. }
  346. .detail-bottom{
  347. justify-content: space-around;
  348. }
  349. </style>