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

368 lines
9.8 KiB

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
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
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
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
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
2 months 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 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. bookInfo: {}, // 图书基础信息(biblios)
  105. holdingsData: [], // 馆藏列表(holdings)
  106. };
  107. },
  108. onLoad(options) {
  109. // 1. 首页/列表页 直接带完整 bookData 过来,优先走这个
  110. if (options.bookData) {
  111. const bookData = JSON.parse(decodeURIComponent(options.bookData));
  112. this.bookInfo = bookData;
  113. this.bookrecno = bookData.bookrecno || "";
  114. // 没有馆藏数据就置空
  115. this.holdingsData = [];
  116. this.checkCollectStatus();
  117. return;
  118. }
  119. // 2. 检索页只传 bookrecno,请求接口拿详情
  120. this.bookrecno = options.bookrecno || "";
  121. this.getOpacUrl();
  122. },
  123. computed: {
  124. // 在馆数量
  125. // 馆藏状态,编目=1,在馆=2,借出=3,丢失=4,剔除=5,交换=6,赠送=7,装订=8,锁定=9,预借=10, 清点=12
  126. inLibraryCount() {
  127. return this.holdingsData.filter(item => item.state === 2).length;
  128. },
  129. // 借出数量(新增)
  130. lendCount() {
  131. return this.holdingsData.filter(item => item.state === 3).length;
  132. },
  133. // 第一个馆藏状态
  134. firstStateText() {
  135. if (this.holdingsData.length === 0) return '无馆藏';
  136. return this.getStateText(this.holdingsData[0].state);
  137. }
  138. },
  139. methods: {
  140. onImgError(e) {
  141. e.target.src = "/static/images/default-book.png";
  142. },
  143. // 获取配置
  144. async getOpacUrl() {
  145. try {
  146. const res = await FetchInitScreenSetting({ libcode: '1201' });
  147. this.opacUrl = res.data.opac_url?.context || '';
  148. this.getBookDetail();
  149. } catch (err) {}
  150. },
  151. // 获取图书详情(适配新接口结构)
  152. async getBookDetail() {
  153. if (!this.bookrecno || !this.opacUrl) return;
  154. uni.showLoading({ title: '加载中...' });
  155. try {
  156. const params = {
  157. opacUrl: this.opacUrl,
  158. bookrecno: this.bookrecno
  159. };
  160. const res = await FetchFindbookByQuery(params);
  161. console.log('bookrecno详情',res);
  162. const apiData = res.data || {};
  163. this.bookInfo = apiData.biblios || {};
  164. console.log('bookrecno-bookInfo详情',this.bookInfo);
  165. this.holdingsData = apiData.holdings || [];
  166. console.log('bookrecno-holdingsData详情',this.holdingsData);
  167. this.checkCollectStatus();
  168. } catch (err) {
  169. console.log(err);
  170. } finally {
  171. uni.hideLoading();
  172. }
  173. },
  174. // 馆藏状态文字
  175. getStateText(state) {
  176. const map = {
  177. 1: '编目',
  178. 2: '在馆',
  179. 3: '借出',
  180. 4: '丢失',
  181. 5: '剔除',
  182. 6: '交换',
  183. 7: '赠送',
  184. 8: '装订',
  185. 9: '锁定',
  186. 10: '预借',
  187. 12: '清点'
  188. }
  189. return map[state] || '未知';
  190. },
  191. // 收藏
  192. checkCollectStatus() {
  193. const list = uni.getStorageSync('collectList') || [];
  194. this.isCollected = list.includes(this.bookrecno);
  195. },
  196. toggleCollect() {
  197. let list = uni.getStorageSync('collectList') || [];
  198. if (this.isCollected) {
  199. list = list.filter(i => i !== this.bookrecno);
  200. uni.showToast({ title: '取消收藏', icon: 'success' });
  201. } else {
  202. list.push(this.bookrecno);
  203. uni.showToast({ title: '收藏成功', icon: 'success' });
  204. }
  205. uni.setStorageSync('collectList', list);
  206. this.isCollected = !this.isCollected;
  207. }
  208. },
  209. onShareAppMessage() {
  210. return {
  211. title: this.bookInfo.title || '图书详情',
  212. path: '/subpkg/pages/book-detail/book-detail?bookrecno=' + this.bookrecno,
  213. imageUrl: this.bookInfo.cover
  214. };
  215. }
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. .detail-container {
  220. padding: 15px;
  221. background-color: #f5f5f5;
  222. min-height: 100vh;
  223. padding-bottom: 60px;
  224. }
  225. .article-detail-container {
  226. display: flex;
  227. background-color: #fff;
  228. border-radius: 10px;
  229. padding: 20px;
  230. margin-bottom: 12px;
  231. }
  232. .article-detail-left {
  233. flex: 1;
  234. }
  235. .article-detail-title {
  236. font-size: 20px;
  237. font-weight: bold;
  238. color: #333;
  239. margin-bottom: 10px;
  240. }
  241. .article-detail-info {
  242. font-size: 14px;
  243. color: #666;
  244. line-height: 1.5;
  245. }
  246. .article-detail-right {
  247. width: 110px;
  248. height: 150px;
  249. margin-left: 15px;
  250. }
  251. .article-detail-right image {
  252. width: 100%;
  253. height: 100%;
  254. border-radius: 6px;
  255. box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  256. }
  257. .book-store-info {
  258. background-color: #fff;
  259. border-radius: 10px;
  260. padding: 20px;
  261. display: flex;
  262. justify-content: space-around;
  263. margin-bottom: 12px;
  264. }
  265. .book-store-info-item {
  266. display: flex;
  267. flex-direction: column;
  268. align-items: center;
  269. }
  270. .store-txt1 {
  271. font-size: 22px;
  272. font-weight: bold;
  273. color: #2b85e4;
  274. }
  275. .store-txt2 {
  276. font-size: 13px;
  277. color: #999;
  278. margin-top: 4px;
  279. }
  280. .store-info-list {
  281. background-color: #fff;
  282. border-radius: 10px;
  283. padding: 10px;
  284. margin-bottom: 15px;
  285. }
  286. .store-info-item {
  287. display: flex;
  288. flex-direction: column;
  289. font-size: 14px;
  290. color: #666;
  291. padding: 10px;
  292. margin-bottom: 10px;
  293. border: 1px solid #eee;
  294. }
  295. .store-info-item view {
  296. display: flex;
  297. align-items: center;
  298. justify-content: flex-start;
  299. line-height: 28px;
  300. .info-item-title{
  301. width: 80px;
  302. font-weight: bold;
  303. color: #333;
  304. }
  305. }
  306. .content-tab {
  307. display: flex;
  308. background-color: #fff;
  309. border-radius: 10px;
  310. overflow: hidden;
  311. margin-bottom: 12px;
  312. }
  313. .tab-item {
  314. flex: 1;
  315. text-align: center;
  316. padding: 15px 0;
  317. font-size: 15px;
  318. color: #666;
  319. position: relative;
  320. }
  321. .tab-item.active {
  322. color: #2b85e4;
  323. font-weight: bold;
  324. }
  325. .tab-item.active::after {
  326. content: "";
  327. position: absolute;
  328. bottom: 0;
  329. left: 50%;
  330. transform: translateX(-50%);
  331. width: 30px;
  332. height: 3px;
  333. background-color: #2b85e4;
  334. border-radius: 2px;
  335. }
  336. .content-item {
  337. background-color: #fff;
  338. border-radius: 10px;
  339. padding: 20px;
  340. font-size: 15px;
  341. color: #333;
  342. line-height: 1.6;
  343. }
  344. .detail-bottom{
  345. justify-content: space-around;
  346. }
  347. </style>