|
|
@ -221,6 +221,8 @@ |
|
|
|
<text>编辑</text> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 分享按钮已移至底部 --> |
|
|
|
|
|
|
|
<!-- 底部评论输入框 --> |
|
|
|
<view class="comment-input-section-box"> |
|
|
|
<view class="comment-input-section"> |
|
|
@ -254,6 +256,7 @@ |
|
|
|
> |
|
|
|
发送 |
|
|
|
</button> |
|
|
|
|
|
|
|
<view class="like-section" @click="toggleLike"> |
|
|
|
<image |
|
|
|
class="like-icon" |
|
|
@ -270,6 +273,16 @@ |
|
|
|
>{{ noteDetail.likeCount || 0 }}</text |
|
|
|
> |
|
|
|
</view> |
|
|
|
<!-- #ifdef MP-WEIXIN --> |
|
|
|
<button class="share-section" open-type="share"> |
|
|
|
<uni-icons type="redo" size="24" color="#666"></uni-icons> |
|
|
|
</button> |
|
|
|
<!-- #endif --> |
|
|
|
<!-- #ifndef MP-WEIXIN --> |
|
|
|
<view class="share-section"> |
|
|
|
<uni-icons type="redo" size="24" color="#666"></uni-icons> |
|
|
|
</view> |
|
|
|
<!-- #endif --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -289,6 +302,32 @@ export default { |
|
|
|
this.loadCommentList(true); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 微信分享配置 |
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
onShareAppMessage() { |
|
|
|
// 设置分享标识符,在onShow中会检查并调用分享接口 |
|
|
|
this.isShared = true; |
|
|
|
|
|
|
|
return { |
|
|
|
title: this.noteDetail.title || "Epic Soul交响", |
|
|
|
path: `/pages/notes/detail?id=${this.noteId}`, |
|
|
|
imageUrl: |
|
|
|
this.topBanner && this.topBanner.length > 0 ? this.topBanner[0] : "", |
|
|
|
mpId: "wx9660f8c5776663e0", |
|
|
|
}; |
|
|
|
}, |
|
|
|
onShareTimeline() { |
|
|
|
// 设置分享标识符,在onShow中会检查并调用分享接口 |
|
|
|
this.isShared = true; |
|
|
|
|
|
|
|
return { |
|
|
|
title: this.noteDetail.title || "Epic Soul交响", |
|
|
|
query: `id=2`, |
|
|
|
imageUrl: |
|
|
|
this.topBanner && this.topBanner.length > 0 ? this.topBanner[0] : "", |
|
|
|
}; |
|
|
|
}, |
|
|
|
// #endif |
|
|
|
data() { |
|
|
|
return { |
|
|
|
noteId: "", |
|
|
@ -305,6 +344,8 @@ export default { |
|
|
|
toNickname: "", // 被回复的用户昵称 |
|
|
|
inputFocusState: false, // 输入框焦点状态 |
|
|
|
showRepliesMap: {}, // 存储每个评论的二级评论展开状态 |
|
|
|
isShared: false, // 分享标识符 |
|
|
|
shareTimer: null, // 分享定时器 |
|
|
|
noteDetail: { |
|
|
|
id: "", |
|
|
|
title: "", |
|
|
@ -330,7 +371,10 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
onLoad(options) { |
|
|
|
console.log(options, "页面的"); |
|
|
|
if (uni.getStorageSync("userInfo")) { |
|
|
|
this.userInfo = JSON.parse(uni.getStorageSync("userInfo")); |
|
|
|
} |
|
|
|
console.log(this.userInfo); |
|
|
|
if (options.id) { |
|
|
|
this.noteId = options.id; |
|
|
@ -345,10 +389,53 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
let id = uni.getStorageSync("wechat_qrcode"); |
|
|
|
this.noteId = this.noteId || id; |
|
|
|
this.loadNoteDetail(); |
|
|
|
this.userInfo = JSON.parse(uni.getStorageSync("userInfo")); |
|
|
|
|
|
|
|
// 检查分享标识符,如果为true则调用分享接口 |
|
|
|
if (this.isShared) { |
|
|
|
// 使用定时器延迟调用,确保页面已完全加载 |
|
|
|
this.shareTimer = setTimeout(() => { |
|
|
|
this.recordShare(); |
|
|
|
this.isShared = false; // 重置分享标识符 |
|
|
|
}, 1000); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
onHide() { |
|
|
|
// 页面隐藏时清除定时器 |
|
|
|
if (this.shareTimer) { |
|
|
|
clearTimeout(this.shareTimer); |
|
|
|
this.shareTimer = null; |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 记录分享并获得积分 |
|
|
|
async recordShare() { |
|
|
|
try { |
|
|
|
const res = await this.Post( |
|
|
|
{}, |
|
|
|
`/framework/noteShare/add/${this.noteId}`, |
|
|
|
"DES" |
|
|
|
); |
|
|
|
|
|
|
|
if (res.code === 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "分享成功", |
|
|
|
icon: "success", |
|
|
|
}); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
console.warn("分享记录失败:", res.msg); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error("分享记录失败:", error); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
swiperChange(e) { |
|
|
|
this.swiperIndex = e.detail.current; |
|
|
|
}, |
|
|
@ -1191,9 +1278,28 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.like-section { |
|
|
|
.share-section { |
|
|
|
margin-bottom: max(env(safe-area-inset-bottom), 24rpx); |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
padding: 0 16rpx; |
|
|
|
background: transparent; |
|
|
|
border: none; |
|
|
|
outline: none; |
|
|
|
box-shadow: none; |
|
|
|
line-height: normal; |
|
|
|
border-radius: 0; |
|
|
|
font-size: inherit; |
|
|
|
color: inherit; |
|
|
|
text-align: center; |
|
|
|
min-height: auto; |
|
|
|
&::after { |
|
|
|
border: none; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.like-section { |
|
|
|
margin-bottom: max(env(safe-area-inset-bottom), 24rpx); |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
gap: 8rpx; |
|
|
|