From bc8a13ff3d47ad85a33812321fc6a9174e693490 Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Mon, 24 Aug 2026 15:04:02 +0800 Subject: [PATCH] =?UTF-8?q?banner+logo=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 8 +- pages/home/home.vue | 150 ++++++++++++------ .../pages/activity-record/activity-record.vue | 48 ++++-- subpkg/pages/book-detail/book-detail.vue | 127 ++++++++++++--- subpkg/pages/seat-record/seat-record.vue | 25 ++- subpkg/pages/user-info/user-info.vue | 72 +++++---- 6 files changed, 319 insertions(+), 111 deletions(-) diff --git a/manifest.json b/manifest.json index edcc845..fab7b1c 100644 --- a/manifest.json +++ b/manifest.json @@ -51,13 +51,19 @@ "mp-weixin" : { /* 小程序特有相关 */ "appid" : "wxa98bf58c54e9102e", + "libVersion": "2.24.4", + "__usePrivacyCheck__": true, "setting" : { "urlCheck" : false, "checkSitMap" : false, "minified" : true, "postcss" : true }, - "usingComponents" : true + "usingComponents" : true, + "permission" : {}, + "unipush" : { + "enable" : false + } }, "vueVersion" : "2" } diff --git a/pages/home/home.vue b/pages/home/home.vue index c5d8e83..7d10a77 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -1,14 +1,17 @@ + + - \ No newline at end of file + + + diff --git a/subpkg/pages/activity-record/activity-record.vue b/subpkg/pages/activity-record/activity-record.vue index f8a8d74..4c15dff 100644 --- a/subpkg/pages/activity-record/activity-record.vue +++ b/subpkg/pages/activity-record/activity-record.vue @@ -40,13 +40,13 @@ - 开始时间 - {{ formatTime(item.start_time) }} - - - 结束时间 - {{ formatTime(item.end_time) }} - + 开始时间 + {{ formatShowDateTime(item.start_time) }} + + + 结束时间 + {{ formatShowDateTime(item.end_time) }} + 预约人 {{ item.signName }} @@ -75,14 +75,13 @@ - 没有更多数据了 - 暂无预约活动~ + 暂无相关活动~ @@ -140,6 +139,37 @@ export default { this.activityList = [] this.getActivityList(true) }, + // 新增:时间戳 → 今天/昨天/明天 HH:mm + formatShowDateTime(timestamp) { + if (!timestamp) return ''; + const d = new Date(timestamp); + const targetY = d.getFullYear(); + const targetM = d.getMonth(); + const targetD = d.getDate(); + const hh = String(d.getHours()).padStart(2, '0'); + const mm = String(d.getMinutes()).padStart(2, '0'); + const timeStr = `${hh}:${mm}`; + + const now = new Date(); + const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); + const targetDayTs = new Date(targetY, targetM, targetD).getTime(); + const oneDay = 24 * 60 * 60 * 1000; + const diff = Math.round((targetDayTs - today.getTime()) / oneDay); + + let dateText = ''; + if (diff === 0) { + dateText = '今天'; + } else if (diff === -1) { + dateText = '昨天'; + } else if (diff === 1) { + dateText = '明天'; + } else { + const m = String(targetM + 1).padStart(2, '0'); + const day = String(targetD).padStart(2, '0'); + dateText = `${targetY}-${m}-${day}`; + } + return `${dateText} ${timeStr}`; + }, formatTime(timestamp) { if (!timestamp) return ''; diff --git a/subpkg/pages/book-detail/book-detail.vue b/subpkg/pages/book-detail/book-detail.vue index f01e7e0..52ca624 100644 --- a/subpkg/pages/book-detail/book-detail.vue +++ b/subpkg/pages/book-detail/book-detail.vue @@ -68,9 +68,9 @@ 内容简介 - + @@ -119,7 +119,10 @@ export default { }; }, onLoad(options) { - // 1. 首页/列表页 直接带完整 bookData 过来,优先走这个 + console.log('options',options) + const fromShare = options.fromShare === 'true' + + // 1. 首页/推荐页 bookData if (options.bookData) { const bookData = JSON.parse(decodeURIComponent(options.bookData)); this.bookInfo = bookData; @@ -127,30 +130,44 @@ export default { this.fromRecommend = options.fromRecommend === 'true'; this.holdingsData = []; this.checkCollectStatus(); + // 分享过来,有bookrecno强制拉完整馆藏 + if(fromShare && this.bookrecno){ + this.getOpacUrl(); + } return; } - console.log('options',options) - // 2. 检索页只传 bookrecno,请求接口拿详情 + + // 2. 分享传入 bookrecno 优先走这里 + if(options.bookrecno){ + this.bookrecno = options.bookrecno + this.fromRecommend = false + this.bookInfo = {} + this.getOpacUrl(); + return; + } + + // 3. 搜索列表 searchData if(options.searchData){ const bookData = JSON.parse(decodeURIComponent(options.searchData)); this.searchListInfo = bookData; this.bookrecno = bookData.bookrecno || ""; this.bookInfo = bookData; - } - - // 3. 如果从收藏列表进入,直接设置为已收藏状态 + + // 4. 收藏列表标记 if (options.isCollected === 'true') { this.isCollected = true; } - + this.fromRecommend = false; - this.getOpacUrl(); - this.getDictionaryTree(); + // 有bookrecno就请求详情,修复原逻辑漏调用getOpacUrl + if(this.bookrecno){ + this.getOpacUrl(); + } }, computed: { - // 在馆数量 - // 馆藏状态,编目=1,在馆=2,借出=3,丢失=4,剔除=5,交换=6,赠送=7,装订=8,锁定=9,预借=10, 清点=12 + // 在馆数量 + // 馆藏状态,编目=1,在馆=2,借出=3,丢失=4,剔除=5,交换=6,赠送=7,装订=8,锁定=9,预借=10, 清点=12 inLibraryCount() { return this.holdingsData.filter(item => item.state === 2).length; }, @@ -172,7 +189,7 @@ export default { async loadBookCover() { console.log('this.bookInfo',this.bookInfo) if (!this.bookInfo.isbn) return; - + try { const coverUrl = await fetchBookCoverBase64(this.bookInfo.isbn); if (coverUrl) { @@ -219,6 +236,7 @@ export default { try { const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE }); this.opacUrl = res.data.opac_url?.context || ''; + this.getDictionaryTree(); this.getBookDetail(); } catch (err) {} }, @@ -234,14 +252,21 @@ export default { bookrecno: this.bookrecno }; const res = await FetchFindbookByQuery(params); - // console.log('bookrecno详情',res); const apiData = res.data || {}; this.bookInfo = apiData.biblios || {}; - // console.log('bookrecno-bookInfo详情',this.bookInfo); this.holdingsData = apiData.holdings || []; - // console.log('bookrecno-holdingsData详情',this.holdingsData); - + + // ✅重点:分享进入场景补齐searchListInfo,防止收藏点击报错 + if(!this.searchListInfo || !this.searchListInfo.bookrecno){ + this.searchListInfo = { + bookrecno: this.bookInfo.bookrecno, + title: this.bookInfo.title, + author: this.bookInfo.author, + isbn: this.bookInfo.isbn + } + } + // 加载封面 await this.loadBookCover(); @@ -297,10 +322,14 @@ export default { uni.showToast({ title: '获取用户信息失败', icon: 'none' }); return; } + // 防御,分享进来searchListInfo为空保护 + if(!this.searchListInfo || !this.searchListInfo.bookrecno){ + uni.showToast({title:'数据未加载完成,请稍候',icon:'none'}) + return + } if (this.isCollected) { try { - console.log(' this.searchListInfo.id',this.searchListInfo.id); const res = await FetchCancelCollectionBook({id: this.searchListInfo.id}); if (res.code === 200) { this.isCollected = false; @@ -345,11 +374,46 @@ export default { } }, onShareAppMessage() { + const title = this.bookInfo.title || this.bookInfo.name || '图书详情'; + let path = ''; + let imageUrl = ''; + const cover = this.bookInfo.cover || this.bookInfo.base64Cover; + // 微信分享不支持base64图片,过滤 + if(cover && !cover.startsWith('data:image')){ + imageUrl = cover; + } + + if(this.bookrecno){ + //优先bookrecno,参数短,不会url超长 + path = `/subpkg/pages/book-detail/book-detail?bookrecno=${encodeURIComponent(this.bookrecno)}&fromShare=true` + }else{ + path = "/subpkg/pages/book-detail/book-detail?bookData=" + encodeURIComponent(JSON.stringify(this.bookInfo)) + "&fromShare=true" + } return { - title: this.bookInfo.title || '图书详情', - path: '/subpkg/pages/book-detail/book-detail?bookrecno=' + this.bookrecno, - imageUrl: this.bookInfo.cover + title, + path, + imageUrl }; + }, + //分享到朋友圈 + onShareTimeline(){ + const title = this.bookInfo.title || this.bookInfo.name || '图书详情'; + let query = '' + if(this.bookrecno){ + query = `bookrecno=${encodeURIComponent(this.bookrecno)}&fromShare=true` + }else{ + query = `bookData=${encodeURIComponent(JSON.stringify(this.bookInfo))}&fromShare=true` + } + let imageUrl = '' + const cover = this.bookInfo.cover + if(cover && !cover.startsWith('data:image')){ + imageUrl = cover + } + return { + title, + query, + imageUrl + } } }; @@ -490,8 +554,25 @@ export default { line-height: 1.6; } .detail-bottom{ + position: fixed; + bottom:0; + left:0; + right:0; + height:60px; + background:#fff; + display:flex; justify-content: space-around; - padding: 0 15px; + align-items:center; box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05); } +.handle-btn{ + display:flex; + align-items:center; + background:#fff; + border:none; +} +.share-text{ + margin-left:4px; + font-size:14px; +} diff --git a/subpkg/pages/seat-record/seat-record.vue b/subpkg/pages/seat-record/seat-record.vue index e7ea97c..9b7f1ce 100644 --- a/subpkg/pages/seat-record/seat-record.vue +++ b/subpkg/pages/seat-record/seat-record.vue @@ -45,7 +45,7 @@ 入馆日期 - {{ item.visitDate }} + {{ formatShowDate(item.visitDate) }} 入馆时间 @@ -107,6 +107,29 @@ export default { }) }, methods: { + formatShowDate(dateStr) { + if(!dateStr) return '' + // dateStr 格式 yyyy-MM-dd + const now = new Date() + // 本地今天0点 + const todayTs = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime() + const oneDay = 24 * 60 * 60 * 1000 + + const target = new Date(dateStr) + const targetTs = new Date(target.getFullYear(), target.getMonth(), target.getDate()).getTime() + + const diffDay = Math.round((targetTs - todayTs) / oneDay) + + if(diffDay === 0){ + return '今天' + }else if(diffDay === -1){ + return '昨天' + }else if(diffDay === 1){ + return '明天' + }else{ + return dateStr + } + }, formatTsToDate(ts) { const d = new Date(ts); const y = d.getFullYear(); diff --git a/subpkg/pages/user-info/user-info.vue b/subpkg/pages/user-info/user-info.vue index 1353cf2..f7836b1 100644 --- a/subpkg/pages/user-info/user-info.vue +++ b/subpkg/pages/user-info/user-info.vue @@ -1,30 +1,31 @@ @@ -38,13 +39,16 @@ const USER_KEY = 'user-info'; export default { data() { return { + pageReady: false, nickname: '', avatarUrl: '', // 仅存放 base64,用于显示 imgId: '', // 仅用于提交后端 saving: false // 防重复提交 }; }, - onLoad() { + onReady() { + //等页面完全渲染完成,再渲染chooseAvatar按钮 + this.pageReady = true; this.loadUserInfo(); }, methods:{ @@ -57,9 +61,7 @@ export default { if (avatarId) { try { uni.showLoading({ title: '加载头像中...' }); - // const url = `${config.baseUrl}/api/fileRelevant/getImg?imgType=5&imgId=${avatarId}`; - // this.avatarUrl = await this.urlToBase64(url); - console.log(avatarId) + this.imgId = avatarId; const url = `${config.baseUrl}/files/${avatarId}`; console.log(url) this.avatarUrl = url @@ -71,9 +73,11 @@ export default { } } else { this.avatarUrl = ''; + this.imgId = ''; } }, + // 选择头像 + 上传 + 转base64预览 async onChooseAvatar(e) { const tempFilePath = e.detail.avatarUrl; @@ -130,7 +134,6 @@ export default { }); }); }, - // 保存(防重复提交 + 同步缓存) async saveUserInfo() { if (this.saving) return; @@ -151,7 +154,12 @@ export default { openid: openId }; - await FetchBindRead(params); + const res = await FetchBindRead(params); + console.log('FetchBindRead',res) + if(res.code !== 200){ + uni.showToast({title: res.message || '保存失败',icon:'none'}) + return + } // 保存到缓存 uni.setStorageSync(USER_KEY, { @@ -172,6 +180,7 @@ export default { this.saving = false; } } + } }; @@ -196,15 +205,16 @@ export default { .avatar-btn { background: transparent; + pointer-events: auto !important; display: flex; flex-direction: column; align-items: center; - &::after { - border: none; + border: none !important; } } + .avatar-img { width: 120rpx; height: 120rpx;