Browse Source

分享

dev_des
1054425342@qq.com 4 weeks ago
parent
commit
45d50826b9
  1. 110
      pages/notes/detail.vue
  2. 2
      pages/notes/publish.vue

110
pages/notes/detail.vue

@ -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;

2
pages/notes/publish.vue

@ -193,7 +193,7 @@ export default {
//
insertQuickTag(tag) {
//
const existingTag = this.noteForm.tags.find((t) => t.id === tag.id);
const existingTag = this.noteForm.tags.find((t) => t.id == tag.id);
if (!existingTag) {
this.noteForm.tags.unshift(tag);
}

Loading…
Cancel
Save