From 5606f63d8f5ad78057ca15403689dff134a74fd7 Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Thu, 14 May 2026 15:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=89=8B=E6=9C=BA=E5=8F=B7/?= =?UTF-8?q?=E5=B0=81=E9=9D=A2=E5=9B=BEbase64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/user.js | 15 ++++ components/book-list-item/book-list-item.vue | 22 +++--- pages/lendCar/lendCar.vue | 20 ++++- pages/register/register.vue | 82 +++++++++++--------- pages/search/search.vue | 14 +++- subpkg/pages/book-detail/book-detail.vue | 21 +++++ subpkg/pages/collect-list/collect-list.vue | 27 +------ subpkg/pages/myLending/myLending.vue | 41 ++++------ subpkg/pages/ranking/ranking.vue | 12 +++ utils/bookCover.js | 61 +++++++++++++++ 10 files changed, 216 insertions(+), 99 deletions(-) diff --git a/api/user.js b/api/user.js index 1509892..f4ae969 100644 --- a/api/user.js +++ b/api/user.js @@ -139,3 +139,18 @@ export function FetchReaderMessage(data) { data }); } + +export function FetchSessionKey(data) { + return request({ + url: '/api/weixin/getSessionKey', + data + }); +} + +export function FetchDecryptPhone(data) { + return request({ + url: '/api/weixin/decryptPhone', + method: 'POST', + data + }); +} \ No newline at end of file diff --git a/components/book-list-item/book-list-item.vue b/components/book-list-item/book-list-item.vue index 5431d41..c62cbc8 100644 --- a/components/book-list-item/book-list-item.vue +++ b/components/book-list-item/book-list-item.vue @@ -29,22 +29,17 @@ export default { }, computed: { actualCover() { - // 优先级:base64Cover > cover > imgCover + // 优先使用 cover + if (this.data.cover) { + return this.data.cover; + } - // base64Cover 是本地 base64 图片,直接使用,不需要检查 + // 其次使用 base64Cover(兼容推荐页面) if (this.data.base64Cover) { return this.data.base64Cover; } - // cover 和 imgCover 需要检查有效性 - const cover = this.data.cover || this.data.imgCover; - - // 如果有封面链接,检查是否是无效域名 - if (cover && this.isValidCoverLink(cover)) { - return cover; - } - - // 返回默认图片 + // 最后使用默认图片 return '/static/images/default-book.png'; } }, @@ -59,6 +54,11 @@ export default { return false; } + // 支持 base64 图片格式 + if (coverlink.indexOf('data:image/') === 0) { + return true; + } + // 检查是否包含 http if (coverlink.indexOf('http') === -1) { return false; diff --git a/pages/lendCar/lendCar.vue b/pages/lendCar/lendCar.vue index cad1d93..21e9b0e 100644 --- a/pages/lendCar/lendCar.vue +++ b/pages/lendCar/lendCar.vue @@ -65,6 +65,7 @@ import { FetchInitScreenSetting } from '@/api/user'; import { FetchRdloanlist, FetchRenewbook } from '@/api/book'; import { getCurrentReaderCard } from '@/utils/storage'; import config from '@/utils/config'; +import { loadBookCoversBase64 } from '@/utils/bookCover'; export default { data() { @@ -190,13 +191,15 @@ export default { const res = await FetchRdloanlist(params); const result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data; - // 添加选中状态和封面处理 + // 添加选中状态 this.bookList = (result.loanlist || []).map(item => ({ ...item, - checked: false, - cover: this.getBookCover(item) + checked: false })); + // 加载封面 + await this.loadCoversForList(); + } catch (err) { console.error('获取借阅列表失败:', err); uni.showToast({ title: '加载失败', icon: 'none' }); @@ -220,6 +223,17 @@ export default { } return null; }, + + /** + * 加载封面 + */ + async loadCoversForList() { + await loadBookCoversBase64(this.bookList, (index, coverUrl) => { + if (this.bookList[index]) { + this.$set(this.bookList[index], 'cover', coverUrl); + } + }); + }, /** * 判断是否逾期 diff --git a/pages/register/register.vue b/pages/register/register.vue index 1286f07..db07c34 100644 --- a/pages/register/register.vue +++ b/pages/register/register.vue @@ -106,10 +106,13 @@