Browse Source

0509999

master
xuhuajiao 1 month ago
parent
commit
3b68983f9e
  1. 32
      pages/search/search.vue
  2. 109
      subpkg/pages/book-detail/book-detail.vue

32
pages/search/search.vue

@ -134,7 +134,6 @@ export default {
this.selectValue = this.range[index].value; this.selectValue = this.range[index].value;
this.selectValueText = this.range[index].text; this.selectValueText = this.range[index].text;
}, },
//
async getBookList() { async getBookList() {
if (!this.value) { if (!this.value) {
uni.showToast({ title: '请输入搜索内容', icon: 'none' }); uni.showToast({ title: '请输入搜索内容', icon: 'none' });
@ -160,31 +159,17 @@ export default {
}; };
const res = await FetchBookSearch(params); const res = await FetchBookSearch(params);
console.log('res',res)
let result = {};
if (typeof res.data === 'string') {
try {
result = JSON.parse(res.data);
} catch (e) {}
} else {
result = res.data || {};
}
// {}
const isEmptyData = Object.keys(result).length === 0;
//
const apiData = res.data || {};
const list = apiData.bookList || [];
// list & total
let list = [];
let total = 0;
if (!isEmptyData) {
list = result.data || [];
total = Number(result.total || 0);
}
this.total = total;
//
this.total = apiData.totalCount || 0;
this.totalPage = Math.ceil(this.total / this.size); this.totalPage = Math.ceil(this.total / this.size);
//
if (this.page === 1) { if (this.page === 1) {
this.listData = list; this.listData = list;
} else { } else {
@ -194,8 +179,9 @@ export default {
this.isSearched = true; this.isSearched = true;
} catch (err) { } catch (err) {
console.error('搜索接口异常', err);
this.listData = []; this.listData = [];
uni.showToast({ title: '搜索失败', icon: 'none' });
this.isSearched = true;
} finally { } finally {
uni.hideLoading(); uni.hideLoading();
} }

109
subpkg/pages/book-detail/book-detail.vue

@ -8,19 +8,13 @@
<view class="article-detail-author">作者{{ bookInfo.author || '暂无' }}</view> <view class="article-detail-author">作者{{ bookInfo.author || '暂无' }}</view>
<view class="article-detail-time">出版社{{ bookInfo.publisher || '暂无' }}</view> <view class="article-detail-time">出版社{{ bookInfo.publisher || '暂无' }}</view>
<view class="article-detail-time">ISBN{{ bookInfo.isbn || '暂无' }}</view> <view class="article-detail-time">ISBN{{ bookInfo.isbn || '暂无' }}</view>
<!-- <view class="article-detail-time">出版时间{{ bookInfo.publishdate || '暂无' }}</view> -->
<view class="article-detail-time">出版时间{{ bookInfo.pubdate || '暂无' }}</view>
</view> </view>
</view> </view>
<view class="article-detail-right"> <view class="article-detail-right">
<!-- <image
:src="bookInfo.imgPath
? baseUrl + '/api/fileRelevant/getImg?imgType=2&imgId=' + bookInfo.imgPath
: bookInfo.cover || '/static/images/default-book.png'"
mode="widthFix"
/> -->
<image <image
class="img-item" class="img-item"
:src="bookInfo.cover || (bookInfo.imgPath ? baseUrl + '/api/fileRelevant/getImg?imgType=2&imgId=' + bookInfo.imgPath : '/static/images/default-book.png')"
:src="bookInfo.cover || '/static/images/default-book.png'"
mode="widthFix" mode="widthFix"
@error="onImgError" @error="onImgError"
></image> ></image>
@ -30,23 +24,22 @@
<!-- 馆藏信息 --> <!-- 馆藏信息 -->
<view class="book-store-info"> <view class="book-store-info">
<view class="book-store-info-item"> <view class="book-store-info-item">
<text class="store-txt1">{{ bookInfo.orglib || '暂无' }}</text>
<text class="store-txt2">所属</text>
<text class="store-txt1">{{ holdingsData.length || 0 }}</text>
<text class="store-txt2">藏总数</text>
</view> </view>
<view class="book-store-info-item"> <view class="book-store-info-item">
<text class="store-txt1">{{ bookInfo.loancount || 0 }}</text>
<text class="store-txt1">{{ inLibraryCount }}</text>
<text class="store-txt2">在馆</text> <text class="store-txt2">在馆</text>
</view> </view>
<!-- 编目=1,在馆=2,借出=3,丢失=4,剔除=5,交换=6,赠送=7,装订=8,锁定=9,预借=10 清点=12 -->
<view class="book-store-info-item"> <view class="book-store-info-item">
<text class="store-txt1">{{ stateText }}</text>
<text class="store-txt2">馆藏状态</text>
<text class="store-txt1">{{ lendCount }}</text>
<text class="store-txt2">借出</text>
</view> </view>
</view> </view>
<!-- 索书号/条码号 --> <!-- 索书号/条码号 -->
<view v-if="bookInfo.collection" class="store-info-list">
<view class="store-info-item" v-for="(item, index) in bookInfo.collection" :key="index">
<view class="store-info-list">
<view class="store-info-item" v-for="(item, index) in holdingsData" :key="index">
<view> <view>
<text>索书号</text> <text>索书号</text>
<text>{{ item.callno || '暂无' }}</text> <text>{{ item.callno || '暂无' }}</text>
@ -55,6 +48,10 @@
<text>条码号</text> <text>条码号</text>
<text>{{ item.barcode || '暂无' }}</text> <text>{{ item.barcode || '暂无' }}</text>
</view> </view>
<view>
<text>馆藏状态</text>
<text>{{ getStateText(item.state) }}</text>
</view>
</view> </view>
</view> </view>
@ -102,41 +99,39 @@ export default {
isCollected: false, isCollected: false,
bookrecno: '', bookrecno: '',
opacUrl: '', opacUrl: '',
bookInfo: {} //
bookInfo: {}, // biblios
holdingsData: [], // holdings
}; };
}, },
onLoad(options) { onLoad(options) {
//
// 1. / bookData
if (options.bookData) { if (options.bookData) {
const bookData = JSON.parse(decodeURIComponent(options.bookData)); const bookData = JSON.parse(decodeURIComponent(options.bookData));
this.bookInfo = bookData; //
this.bookInfo = bookData;
this.bookrecno = bookData.bookrecno || ""; this.bookrecno = bookData.bookrecno || "";
//
this.holdingsData = [];
this.checkCollectStatus(); this.checkCollectStatus();
return; return;
} }
// bookrecno
// 2. bookrecno
this.bookrecno = options.bookrecno || ""; this.bookrecno = options.bookrecno || "";
this.getOpacUrl(); this.getOpacUrl();
}, },
computed: { computed: {
//
stateText() {
const state = this.bookInfo.state || 0
const map = {
1: '编目',
2: '在馆',
3: '借出',
4: '丢失',
5: '剔除',
6: '交换',
7: '赠送',
8: '装订',
9: '锁定',
10: '预借',
12: '清点'
}
return map[state] || '未知'
//
inLibraryCount() {
return this.holdingsData.filter(item => item.state === 2).length;
},
//
lendCount() {
return this.holdingsData.filter(item => item.state === 3).length;
},
//
firstStateText() {
if (this.holdingsData.length === 0) return '无馆藏';
return this.getStateText(this.holdingsData[0].state);
} }
}, },
methods: { methods: {
@ -152,7 +147,7 @@ export default {
} catch (err) {} } catch (err) {}
}, },
//
//
async getBookDetail() { async getBookDetail() {
if (!this.bookrecno || !this.opacUrl) return; if (!this.bookrecno || !this.opacUrl) return;
@ -164,23 +159,37 @@ export default {
}; };
const res = await FetchFindbookByQuery(params); const res = await FetchFindbookByQuery(params);
//
let detail = {};
if (typeof res.data === 'string') {
detail = JSON.parse(res.data);
} else {
detail = res.data || {};
}
const apiData = res.data || {};
this.bookInfo = apiData.biblios || {};
this.holdingsData = apiData.holdings || [];
this.bookInfo = detail;
this.checkCollectStatus(); this.checkCollectStatus();
} catch (err) { } catch (err) {
console.log(err);
} finally { } finally {
uni.hideLoading(); uni.hideLoading();
} }
}, },
//
//
getStateText(state) {
const map = {
1: '编目',
2: '在馆',
3: '借出',
4: '丢失',
5: '剔除',
6: '交换',
7: '赠送',
8: '装订',
9: '锁定',
10: '预借',
12: '清点'
}
return map[state] || '未知';
},
//
checkCollectStatus() { checkCollectStatus() {
const list = uni.getStorageSync('collectList') || []; const list = uni.getStorageSync('collectList') || [];
this.isCollected = list.includes(this.bookrecno); this.isCollected = list.includes(this.bookrecno);
@ -217,7 +226,6 @@ export default {
padding-bottom: 60px; padding-bottom: 60px;
} }
/* 书籍信息 */
.article-detail-container { .article-detail-container {
display: flex; display: flex;
background-color: #fff; background-color: #fff;
@ -251,7 +259,6 @@ export default {
box-shadow: 0 2px 8px rgba(0,0,0,0.1); box-shadow: 0 2px 8px rgba(0,0,0,0.1);
} }
/* 馆藏统计 */
.book-store-info { .book-store-info {
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
@ -276,7 +283,6 @@ export default {
margin-top: 4px; margin-top: 4px;
} }
/* 索书号 */
.store-info-list { .store-info-list {
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
@ -288,6 +294,7 @@ export default {
justify-content: space-between; justify-content: space-between;
font-size: 14px; font-size: 14px;
color: #666; color: #666;
margin-bottom: 10px;
} }
.store-info-item view { .store-info-item view {
display: flex; display: flex;
@ -295,7 +302,6 @@ export default {
align-items: center; align-items: center;
} }
/* TAB */
.content-tab { .content-tab {
display: flex; display: flex;
background-color: #fff; background-color: #fff;
@ -327,7 +333,6 @@ export default {
border-radius: 2px; border-radius: 2px;
} }
/* 内容区域 */
.content-item { .content-item {
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;

Loading…
Cancel
Save