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

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