diff --git a/components/DynamicIsland.vue b/components/DynamicIsland.vue
index 9190b25..e10534c 100644
--- a/components/DynamicIsland.vue
+++ b/components/DynamicIsland.vue
@@ -104,6 +104,7 @@
积分:{{totalPoints||0}}积分获取规则
@@ -387,6 +388,11 @@
url: '/subPackages/other/introduction'
})
},
+ pointDetail(){
+ uni.navigateTo({
+ url:'/subPackages/user/privacyInfo?id=10222'
+ })
+ }
},
};
diff --git a/components/WaterfallLayout.vue b/components/WaterfallLayout.vue
index b5cee8b..3ddb72f 100644
--- a/components/WaterfallLayout.vue
+++ b/components/WaterfallLayout.vue
@@ -12,7 +12,6 @@
@@ -33,16 +32,16 @@
/>
{{ item.nickname }}
-
+
{{ item.likeCount || 0 }}
@@ -55,7 +54,6 @@
@@ -79,16 +77,16 @@
}}{{ item.nickname }}
-
+
{{ item.likeCount || 0 }}
@@ -144,6 +142,70 @@ export default {
this.calculateLayout(this.items);
},
methods: {
+ // 处理点赞/取消点赞
+ handleLikeClick(item) {
+ if (!item || !item.id) {
+ uni.showToast({
+ title: "操作失败,笔记ID不存在",
+ icon: "none",
+ });
+ return;
+ }
+
+ // 乐观更新UI
+ const isLiked = !item.userLiked;
+ item.userLiked = isLiked;
+ item.likeCount = isLiked
+ ? (item.likeCount || 0) + 1
+ : Math.max((item.likeCount || 0) - 1, 0);
+
+ // 调用API
+ const url = isLiked
+ ? `/framework/noteLike/add/${item.id}`
+ : `/framework/noteLike/cancel/${item.id}`;
+
+ this.Post({}, url, "DES")
+ .then((res) => {
+ if (res.code !== 200) {
+ // 如果请求失败,回滚UI更新
+ item.userLiked = !isLiked;
+ item.likeCount = !isLiked
+ ? (item.likeCount || 0) + 1
+ : Math.max((item.likeCount || 0) - 1, 0);
+
+ uni.showToast({
+ title: res.msg || "操作失败,请稍后重试",
+ icon: "none",
+ });
+ } else {
+ // 请求成功,发出事件通知父组件
+ this.$emit("like-change", {
+ noteId: item.id,
+ isLiked: isLiked,
+ likeCount: item.likeCount,
+ });
+
+ // 同时发送全局事件,通知其他页面更新
+ uni.$emit('note-like-change', {
+ noteId: item.id,
+ isLiked: isLiked,
+ likeCount: item.likeCount
+ });
+ }
+ })
+ .catch((err) => {
+ // 请求失败,回滚UI更新
+ item.userLiked = !isLiked;
+ item.likeCount = !isLiked
+ ? (item.likeCount || 0) + 1
+ : Math.max((item.likeCount || 0) - 1, 0);
+
+ uni.showToast({
+ title: err.msg || "网络异常,请稍后重试",
+ icon: "none",
+ });
+ });
+ },
// 获取列的实际高度(通过DOM查询)
getColumnHeight(columnRef) {
if (!columnRef) return 0;
@@ -370,6 +432,7 @@ export default {
display: flex;
align-items: center;
gap: 6rpx;
+ padding: 4rpx 8rpx;
}
.like-icon {
diff --git a/pages/index/timeShopBank.vue b/pages/index/timeShopBank.vue
index ca8346c..5d1617e 100644
--- a/pages/index/timeShopBank.vue
+++ b/pages/index/timeShopBank.vue
@@ -44,20 +44,13 @@
-
-
-
@@ -66,32 +59,32 @@
-->
-
-
+
+ 关注功能开发中...
-
-
-
-
+
+
@@ -91,7 +96,7 @@
@@ -241,52 +242,6 @@ export default {
uni.hideLoading();
}
},
-
- // 加载模拟数据
- loadMockData() {
- this.noteDetail = {
- id: "mock001",
- title: "首期「桃园山河令」",
- content:
- "一周前,我们种下了一片想象中的桃园,并向江湖发出了一封「桃园山河令」,邀请你来分享属于自己的“桃园时刻”。未曾想到,这片初生的桃园,会迎来五湖四海如此多的“桃园客”——这是我们想送给每一位「EpicSoul交响」星球上「三个桃子」粉丝的名字。这些回响,来自每一位被「三个桃子」IP故事所触动的你。因为是你们,用一个个真实、温暖的故事,让我们想象中的那片桃园,迅速地枝繁叶茂,长满了沉甸甸的果实。",
- image: "https://des.dayunyuanjian.cn/epicSoul/canal-town.jpg",
- tags: ["时间里的约定", "审美", "治愈系调色"],
- likes: 30,
- isLiked: false,
- createTime: "2025-08-20 14:30:00",
- user: {
- id: "user001",
- name: "发布者",
- avatar: "/uploads/20250826/b4b7c64ce37481e75742454c037e6407.png",
- isFollowed: false,
- },
- comments: [
- {
- id: "comment001",
- content:
- "我的「桃园时刻」是和发小一起玩耍,阳光透过桃叶洒下斑驳光影,空气中弥漫着桃子的香甜。我们一起摘桃子,分享秘密,笑声在桃园里回荡。",
- createTime: "2025-08-20 15:00:00",
- user: {
- id: "user002",
- name: "@小新",
- avatar: "/uploads/20250826/d68433653e8b8cceba9bc4a6ab2a394d.png",
- },
- },
- {
- id: "comment002",
- content:
- "我的「桃园时刻」是和家人一起野餐,在桃树下享受美食,孩子们在周围嬉戏,欢声笑语让时光变得缓慢而美好。",
- createTime: "2025-08-20 16:20:00",
- user: {
- id: "user003",
- name: "Mr.曾",
- avatar: "/uploads/20250826/d68433653e8b8cceba9bc4a6ab2a394d.png",
- },
- },
- ],
- };
- },
-
// 预览图片
previewImage(imageUrl) {
uni.previewImage({
@@ -333,36 +288,69 @@ export default {
// 切换点赞状态
async toggleLike() {
+ if (!this.noteId) {
+ uni.showToast({
+ title: "笔记ID不存在",
+ icon: "none",
+ });
+ return;
+ }
+
try {
- const action = this.noteDetail.isLiked ? "cancel" : "like";
- const res = await this.Post(
- {
- method: "POST",
- noteId: this.noteId,
- action: action,
- },
- "/framework/note/like",
- "DES"
- );
+ // 保存原始状态,用于出错时回滚
+ const originalLiked = this.noteDetail.userLiked;
+ const originalLikeCount = this.noteDetail.likeCount || 0;
- if (res.code === 200) {
- this.noteDetail.isLiked = !this.noteDetail.isLiked;
- this.noteDetail.likes += this.noteDetail.isLiked ? 1 : -1;
+ // 乐观更新UI
+ this.noteDetail.userLiked = !this.noteDetail.userLiked;
+ this.noteDetail.likeCount =
+ (this.noteDetail.likeCount || 0) +
+ (this.noteDetail.userLiked ? 1 : -1);
+
+ // 根据当前状态决定调用哪个API
+ const apiUrl = this.noteDetail.userLiked
+ ? "/framework/noteLike/add/" + this.noteId
+ : "/framework/noteLike/cancel/" + this.noteId;
+
+ const res = await this.Post({}, apiUrl, "DES");
- // 可选:更新点赞数为接口返回的准确数值
+ if (res.code === 200) {
+ // 成功时,如果API返回了准确的点赞数,则使用API返回的数据
if (res.data && res.data.likeCount !== undefined) {
- this.noteDetail.likes = res.data.likeCount;
+ this.noteDetail.likeCount = res.data.likeCount;
}
+
+ // 发送事件通知 timeShopBank 页面更新数据
+ uni.$emit('note-like-change', {
+ noteId: this.noteId,
+ isLiked: this.noteDetail.userLiked,
+ likeCount: this.noteDetail.likeCount
+ });
+
+ // 可以在这里添加成功的提示或动画效果
} else {
+ // 失败时回滚UI状态
+ this.noteDetail.userLiked = originalLiked;
+ this.noteDetail.likeCount = originalLikeCount;
+
uni.showToast({
- title: res.msg || (action === "like" ? "点赞失败" : "取消点赞失败"),
+ title:
+ res.msg ||
+ (this.noteDetail.userLiked ? "点赞失败" : "取消点赞失败"),
icon: "none",
});
}
} catch (error) {
console.error("点赞操作失败:", error);
+
+ // 发生异常时也需要回滚UI状态
+ this.noteDetail.userLiked = !this.noteDetail.userLiked;
+ this.noteDetail.likeCount =
+ (this.noteDetail.likeCount || 0) +
+ (this.noteDetail.userLiked ? 1 : -1);
+
uni.showToast({
- title: "操作失败",
+ title: "网络异常,请稍后重试",
icon: "none",
});
}
@@ -629,7 +617,7 @@ export default {
}
.comment-input-section-box {
position: fixed;
- bottom: 0;
+ bottom: -1px;
left: 0;
right: 0;
z-index: 999;
diff --git a/static/js/request.js b/static/js/request.js
index 9ce85f7..6985869 100644
--- a/static/js/request.js
+++ b/static/js/request.js
@@ -9,8 +9,8 @@ const DEV_API_URL = 'https://epic.dayunyuanjian.cn';
const PROD_API_URL = 'https://epic.dayunyuanjian.cn';
const NEWAPIURL = process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL;
// const DEV_API_URL_DES = 'https://des.dayunyuanjian.cn/xcx';
-const DEV_API_URL_DES = 'https://des.dayunyuanjian.cn/xcx';
-// const DEV_API_URL_DES = 'http://192.168.124.8:8083/xcx';
+// const DEV_API_URL_DES = 'https://des.dayunyuanjian.cn/xcx';
+const DEV_API_URL_DES = 'http://192.168.124.8:8083/xcx';
// const PROD_API_URL_DES = 'https://des.dayunyuanjian.cn/xcx';
const PROD_API_URL_DES = 'https://des.dayunyuanjian.cn/xcx';
const NEWAPIURL_DES = process.env.NODE_ENV === 'development' ? DEV_API_URL_DES : PROD_API_URL_DES;