|
|
|
@ -4,12 +4,15 @@ |
|
|
|
<uni-icons class="erweima-top" custom-prefix="iconfont" type="icon-erweima" size="22" color="#fff" @click="showTopImgPopup"></uni-icons> |
|
|
|
<image class="top-bar-bg" src="@/static/images/mingqi-beij@2x.png" mode="aspectFill"></image> |
|
|
|
<view class="library-info"> |
|
|
|
<image class="avatar" src="@/static/images/logo.jpg" mode="aspectFill"></image> |
|
|
|
<!-- 动态logo,兜底本地静态图 --> |
|
|
|
<image class="avatar" :src="libraryLogo || '/static/images/logo.jpg'" mode="aspectFill"></image> |
|
|
|
<view class="library-name">葛店经济技术开发区图书馆</view> |
|
|
|
</view> |
|
|
|
<uni-icons class="search-icon" type="search" size="24" @click="onToSearch"></uni-icons> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<view class="status-cards"> |
|
|
|
<view class="status-card" @click="toBorrowPage(0)"> |
|
|
|
<view class="status-icon icon-color1" > |
|
|
|
@ -37,12 +40,17 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<swiper class="banner-swiper" interval="3000" circular :vertical="false" :indicator-dots="true" :autoplay="true"> |
|
|
|
<swiper-item> |
|
|
|
<image data-post-id="3" src="https://mmbiz.qpic.cn/mmbiz_jpg/bVyA57fUOMicbQqItawJwQlR2oCoYql1icEbuH45ibSAzZsk2T3aDbUOIdMyOOc2CzkYouok0El5u5U3LONACaeNw/640?wx_fmt=jpeg&from=appmsg&tp=webp&wxfrom=5&wx_lazy=1#imgIndex=1"></image> |
|
|
|
</swiper-item> |
|
|
|
<swiper-item> |
|
|
|
<image data-post-id="4" src="https://mmbiz.qpic.cn/sz_mmbiz_gif/tuyGibvSXrsqqiaNpAFJ7lbfGL5vibHtUdV5SUk1RWnlq3QqDe9liaWhdS91L0orEsFxZMiaHOFxDOzINmkiby24fYmmWstiayUgywfVia1pwMcNpBA/640?wx_fmt=gif&from=appmsg&tp=webp&wxfrom=5&wx_lazy=1#imgIndex=3"></image> |
|
|
|
<swiper |
|
|
|
v-if="bannerList.length" |
|
|
|
class="banner-swiper" |
|
|
|
interval="3000" |
|
|
|
circular |
|
|
|
:vertical="false" |
|
|
|
:indicator-dots="true" |
|
|
|
:autoplay="true" |
|
|
|
> |
|
|
|
<swiper-item v-for="(item, idx) in bannerList" :key="idx"> |
|
|
|
<image :src="item.imgUrl" mode="aspectFill"></image> |
|
|
|
</swiper-item> |
|
|
|
</swiper> |
|
|
|
|
|
|
|
@ -108,6 +116,8 @@ |
|
|
|
</swiper-item> |
|
|
|
</swiper> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 已有绑定:滑动切换多个借阅证 --> |
|
|
|
<view v-if="isBindLibraryCard" class="library-card-has"> |
|
|
|
<view class="section-title">我的借阅证</view> |
|
|
|
@ -135,6 +145,8 @@ |
|
|
|
</swiper> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 未绑定借阅证 --> |
|
|
|
<view class="library-card-section" @click="toCheckLogin" v-else> |
|
|
|
<view class="section-title">借阅证</view> |
|
|
|
@ -143,6 +155,8 @@ |
|
|
|
<button class="bind-btn">立即绑定</button> |
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<root-portal> |
|
|
|
<uni-popup |
|
|
|
ref="popup" |
|
|
|
@ -164,6 +178,8 @@ |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<uni-popup |
|
|
|
ref="erweimapopup" |
|
|
|
type="center" |
|
|
|
@ -186,6 +202,8 @@ |
|
|
|
</root-portal> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<view class="recommendation-section"> |
|
|
|
<view class="section-title"> |
|
|
|
<text class="left-txt">图书推荐</text> |
|
|
|
@ -215,12 +233,16 @@ |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
import { FetchInitScreenSetting, FetchOpenId, FetchFindAllReaderBindByOpenId} from '@/api/user'; |
|
|
|
import { FetchInitScreenBookRecommend } from '@/api/book'; |
|
|
|
import config from '@/utils/config'; |
|
|
|
import { STORAGE_KEYS } from '@/utils/storage'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -232,7 +254,9 @@ export default { |
|
|
|
baseUrl: config.baseUrl, |
|
|
|
qrcodeText: '', // 二维码内容 |
|
|
|
popupFixedStyle: 'position:fixed;top:0;left:0;right:0;bottom:0;', |
|
|
|
wecharQRCode: null |
|
|
|
wecharQRCode: null, |
|
|
|
libraryLogo: null, // 新增:图书馆logo图片地址 |
|
|
|
bannerList: [] // 新增 banner轮播数组 |
|
|
|
}; |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
@ -246,18 +270,42 @@ export default { |
|
|
|
async getScreenSetting() { |
|
|
|
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE }); |
|
|
|
|
|
|
|
|
|
|
|
// 处理微信二维码 |
|
|
|
if (res.data.wechat_qr_code && res.data.wechat_qr_code.context) { |
|
|
|
// const imageUrl = this.baseUrl + '/api/fileRelevant/getImg?imgType=1&imgId=' + res.data.wechat_qr_code.context; |
|
|
|
const imageUrl = this.baseUrl + '/files/' + res.data.wechat_qr_code.context; |
|
|
|
try { |
|
|
|
const base64 = await this.urlToBase64(imageUrl); |
|
|
|
this.wecharQRCode = base64; |
|
|
|
this.wecharQRCode = imageUrl; |
|
|
|
} catch (err) { |
|
|
|
this.wecharQRCode = null; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.wecharQRCode = null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 新增:处理图书馆logo |
|
|
|
if(res.data.library_logo && res.data.library_logo.context){ |
|
|
|
this.libraryLogo = this.baseUrl + '/files/' + res.data.library_logo.context; |
|
|
|
}else{ |
|
|
|
this.libraryLogo = null; |
|
|
|
} |
|
|
|
|
|
|
|
// ========== 解析vx_banner1 ~ vx_banner5 最多5张 ========== |
|
|
|
const banners = [] |
|
|
|
for(let i = 1; i <=5; i++){ |
|
|
|
const key = `vx_banner${i}` |
|
|
|
const bannerItem = res.data[key] |
|
|
|
if(bannerItem && bannerItem.context){ |
|
|
|
banners.push({ |
|
|
|
id: bannerItem.id, |
|
|
|
code: bannerItem.code, |
|
|
|
imgUrl: this.baseUrl + '/files/' + bannerItem.context |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
this.bannerList = banners |
|
|
|
|
|
|
|
}, |
|
|
|
// 显示顶部微信二维码弹窗 |
|
|
|
showTopImgPopup() { |
|
|
|
@ -268,12 +316,16 @@ export default { |
|
|
|
this.$refs.erweimapopup.open() |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 格式化读者证号 |
|
|
|
formatCardNo(cardNo) { |
|
|
|
if (!cardNo) return ''; |
|
|
|
const str = String(cardNo); |
|
|
|
const len = str.length; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len > 8) { |
|
|
|
// 前2位 + 中间全部* + 后2位 |
|
|
|
const front = str.substring(0, 2); |
|
|
|
@ -303,31 +355,43 @@ export default { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!loginRes.code) { |
|
|
|
uni.showToast({ title: '授权失败', icon: 'none' }); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 获取 openId |
|
|
|
const openRes = await FetchOpenId({ |
|
|
|
libcode: config.LIB_CODE, |
|
|
|
code: loginRes.code |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (openRes.code !== 200 || !openRes.data) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openId = openRes.data; |
|
|
|
uni.setStorageSync('wx_login_code', openId); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 有了 openId → 查绑定状态 |
|
|
|
const res = await FetchFindAllReaderBindByOpenId({ |
|
|
|
libcode: config.LIB_CODE, |
|
|
|
openId: openId |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (res.code === 200 && res.data.length > 0) { |
|
|
|
this.isBindLibraryCard = true; |
|
|
|
// 默认证排第一位 |
|
|
|
@ -345,6 +409,8 @@ export default { |
|
|
|
uni.setStorageSync(STORAGE_KEYS.CURRENT_READER_CARD, null); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
console.error('初始化失败:', err); |
|
|
|
const list = uni.getStorageSync(STORAGE_KEYS.READER_CARD_LIST) || []; |
|
|
|
@ -353,6 +419,8 @@ export default { |
|
|
|
const otherCards = list.filter(item => !item.bindDefault); |
|
|
|
this.readerCardList = defaultCard ? [defaultCard, ...otherCards] : list; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isBindLibraryCard = list.length > 0; |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -362,6 +430,8 @@ export default { |
|
|
|
const res = await FetchInitScreenBookRecommend({ libcode: config.LIB_CODE }); |
|
|
|
let books = res.data || []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只处理并展示前3条,避免setData数据过大 |
|
|
|
const limit = 3; |
|
|
|
const displayBooks = books.slice(0, limit); |
|
|
|
@ -384,6 +454,8 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只将展示所需的前3条数据放入响应式,减少setData传输量 |
|
|
|
this.recommendedBooks = displayBooks; |
|
|
|
this.isLoading = false; |
|
|
|
@ -548,7 +620,6 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
.top-bar{ |
|
|
|
.erweima-top{ |
|
|
|
@ -567,7 +638,6 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.status-cards { |
|
|
|
display: flex; |
|
|
|
background-color: #fff; |
|
|
|
@ -621,7 +691,6 @@ swiper.menu-swiper{ |
|
|
|
margin-top: 10px; |
|
|
|
background-color: #fff; |
|
|
|
} |
|
|
|
|
|
|
|
.menu-grid { |
|
|
|
display: grid; |
|
|
|
grid-template-columns: repeat(4, 1fr); |
|
|
|
@ -716,10 +785,8 @@ swiper.menu-swiper{ |
|
|
|
font-size: 11px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.library-card-has { |
|
|
|
width: 100%; |
|
|
|
padding: 20px 10px; |
|
|
|
@ -735,12 +802,10 @@ swiper.menu-swiper{ |
|
|
|
margin-bottom: 10px; |
|
|
|
padding-left: 5px; |
|
|
|
} |
|
|
|
|
|
|
|
.card-list { |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.card-swiper { |
|
|
|
height: 106px; |
|
|
|
.card-item{ |
|
|
|
@ -782,6 +847,8 @@ swiper.menu-swiper{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.default-tag { |
|
|
|
position: absolute; |
|
|
|
right: 12px; |
|
|
|
@ -795,6 +862,8 @@ swiper.menu-swiper{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.erweima-style{ |
|
|
|
position: absolute; |
|
|
|
right: 12px; |
|
|
|
@ -805,17 +874,6 @@ swiper.menu-swiper{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// .qrcode-popup { |
|
|
|
// padding: 20px; |
|
|
|
// border-radius: 12px; |
|
|
|
// background: #fff; |
|
|
|
|
|
|
|
// .qrcode-tip { |
|
|
|
// text-align: center; |
|
|
|
// font-size: 12px; |
|
|
|
// color: #999; |
|
|
|
// margin-top: 10px; |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
</style> |