diff --git a/packages/chat/chatWindow.vue b/packages/chat/chatWindow.vue index b6b2c99..b6f0f45 100644 --- a/packages/chat/chatWindow.vue +++ b/packages/chat/chatWindow.vue @@ -58,7 +58,7 @@ const userId = options.userId; const userName = options.userName; const supplyDemandId = options.supplyDemandId; - const supplyDemandTitle = options.supplyDemandTitle ? decodeURIComponent(options.supplyDemandTitle) : ''; + const supplyDemandTitle = options.supplyDemandTitle; // 保存供应需求ID this.supplyDemandId = supplyDemandId; @@ -82,6 +82,7 @@ // 使用正确的API调用方式 this.$u.api.supplyDemandMessageList({ + to_user_id: this.theirUserId, supply_demand_id: supplyDemandId, page: page, per_page: this.pageSize diff --git a/packages/library/detail.vue b/packages/library/detail.vue index bef0551..7ccbeac 100644 --- a/packages/library/detail.vue +++ b/packages/library/detail.vue @@ -13,13 +13,13 @@ - {{ bookInfo.title }} - 作者:{{ bookInfo.author }} - 出版社:{{ bookInfo.publisher }} - 出版年份:{{ bookInfo.year }} - ISBN:{{ bookInfo.isbn }} + {{ bookInfo.title || '暂无标题' }} + 作者:{{ bookInfo.author || '暂无' }} + 出版社:{{ bookInfo.publisher || '暂无' }} + 出版年份:{{ bookInfo.year || '暂无' }} + ISBN:{{ bookInfo.isbn || '暂无' }} - + @@ -37,10 +37,6 @@ 状态: - - 创建时间: - {{ formatDate(bookInfo.created_at) }} - @@ -99,7 +95,6 @@ category: book.category, description: book.description, status: book.status, - created_at: book.created_at, image: book.cover ? book.cover.url : '' }; } else { @@ -139,13 +134,6 @@ 3: 'error' }; return typeMap[status] || 'info'; - }, - - // 格式化日期 - formatDate(dateStr) { - if (!dateStr) return '未知'; - const date = new Date(dateStr); - return date.toLocaleDateString('zh-CN'); } } } diff --git a/packages/library/index.vue b/packages/library/index.vue index 38fa2ff..2765374 100644 --- a/packages/library/index.vue +++ b/packages/library/index.vue @@ -28,9 +28,9 @@ - {{ book.title }} - {{ book.author }} - {{ book.publisher }} · {{ book.year }} + {{ book.title || '暂无标题' }} + {{ book.author || '暂无作者' }} + {{ (book.publisher || '暂无') }} · {{ book.year || '暂无' }} @@ -139,10 +139,10 @@ const newBooks = (bookData.data || []).map(book => { return { id: book.id, - title: book.title, - author: book.author, - publisher: book.publisher, - year: book.publish_year, + title: book.title || '暂无标题', + author: book.author || '暂无作者', + publisher: book.publisher || '暂无', + year: book.publish_year || '暂无', image: book.cover ? book.cover.url : '', tags: [ { @@ -150,7 +150,7 @@ type: 'primary' }, { - text: `ISBN: ${book.isbn || '未知'}`, + text: `ISBN: ${book.isbn || '暂无'}`, type: 'info' } ] diff --git a/packages/supply/detail.vue b/packages/supply/detail.vue index ba4481d..9306ca3 100644 --- a/packages/supply/detail.vue +++ b/packages/supply/detail.vue @@ -1,31 +1,104 @@ @@ -47,6 +120,50 @@ isCollected: false } }, + computed: { + hasContactInfo() { + if (!this.detail) return false; + + // 根据public_way字段控制联系方式的显示 + switch (this.detail.public_way) { + case 1: // 直接公开 + return this.detail.user || this.detail.wechat || this.detail.mobile || this.detail.email; + case 2: // 私信后自动公开 + return this.detail.user || this.detail.wechat || this.detail.mobile || this.detail.email; + case 3: // 不公开 + return false; + default: + return this.detail.user || this.detail.wechat || this.detail.mobile || this.detail.email; + } + }, + // 新增计算属性:是否需要私信后查看联系方式 + needMessageToShowContact() { + // 如果已经私信过(messages_count > 0),则显示联系方式 + if (this.detail && this.detail.messages_count > 0) { + return false; + } + // 否则根据public_way判断是否需要私信后查看 + return this.detail && this.detail.public_way === 2; + }, + // 新增计算属性:判断是否已过期 + isExpired() { + if (!this.detail || !this.detail.expire_time) { + return false; + } + // 使用moment比较当前时间和到期时间 + const currentTime = this.$moment(); + const expireTime = this.$moment(this.detail.expire_time); + return currentTime.isAfter(expireTime); + }, + // 新增计算属性:过滤出图片类型的文件 + imageFiles() { + if (!this.detail || !this.detail.files) return []; + return this.detail.files.filter(f => { + const ext = f.extension ? f.extension.toLowerCase() : ''; + return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'].includes(ext); + }); + } + }, onLoad(options) { console.log("页面ID:", options.id); this.fetchDetailData(options.id); @@ -75,9 +192,24 @@ uni.navigateTo({ url: `/packages/chat/chatWindow?userId=${this.detail.user.id}&userName=${userName}` }); + + // 如果是私信后自动公开的情况,且还没有私信过,显示联系方式 + if (this.detail.public_way === 2 && this.detail.messages_count === 0) { + this.$u.toast('私信后联系方式将自动公开'); + } } else { this.$u.toast('用户信息不完整'); } + }, + // 新增方法:预览图片 + previewImage(file, index) { + if (this.imageFiles.length === 0) return; + + uni.previewImage({ + urls: this.imageFiles.map(f => f.url), + current: file.url, + index: index + }); } } } @@ -86,7 +218,14 @@ \ No newline at end of file diff --git a/packages/supply/index.vue b/packages/supply/index.vue index 37109c2..12e540b 100644 --- a/packages/supply/index.vue +++ b/packages/supply/index.vue @@ -1,7 +1,15 @@