From 851b48f8227bf54a2063d8414b551a1693dc3d00 Mon Sep 17 00:00:00 2001 From: lihaoyuan <18278596806@163.com> Date: Wed, 19 Nov 2025 18:12:59 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E6=9C=AA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=BF=9B=E5=85=A5=E7=A0=8D=E4=BB=B7=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=82=B9=E5=87=BB=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activity/cutprice/detail.vue | 92 ++++++++++++++++++++++++++---------- components/loginPopup.vue | 9 +++- 2 files changed, 76 insertions(+), 25 deletions(-) diff --git a/activity/cutprice/detail.vue b/activity/cutprice/detail.vue index a84edd5..3d41ee5 100644 --- a/activity/cutprice/detail.vue +++ b/activity/cutprice/detail.vue @@ -3,7 +3,7 @@ - @@ -441,30 +441,37 @@ export default { options.uid = paramsArray[3]; } - options.sid - ? t.setData({ - imgPath: this.userInfo.user_avatar, - user_nickname: this.userInfo.user_nickname, - mid: options.mid, - uid: options.sid, - participantId: this.userInfo.user_id, - pid: options.pid, - }) - : t.setData({ - imgPath: this.userInfo.user_avatar, - user_nickname: this.userInfo.user_nickname, - mid: options.mid, - uid: options.uid || this.userInfo.user_id, - participantId: this.userInfo.user_id, - pid: options.pid, - }); + options.sid + ? t.setData({ + imgPath: t.userInfo.user_avatar, + user_nickname: t.userInfo.user_nickname, + mid: options.mid, + uid: options.sid, + participantId: t.userInfo.user_id, + pid: options.pid, + }) + : t.setData({ + imgPath: t.userInfo.user_avatar, + user_nickname: t.userInfo.user_nickname, + mid: options.mid, + uid: options.uid || t.userInfo.user_id, + participantId: t.userInfo.user_id, + pid: options.pid, + }); - this.forceUserInfo(function (user) { - t.GetOtherCutPriceActivityList(); - }); - //t.getTime() - }, + // 已登录才执行后续逻辑 + if (t.hasLogin) { + t.forceUserInfo(function (user) { + t.GetOtherCutPriceActivityList(); + }); + } +}, onShow: function () { + //未登录时,直接显示登录弹窗 + if (!this.hasLogin) { + this.showLoginPopup = true; // 显示登录弹窗 + return; + } this.GetVendorCutPriceEventDetail(); }, onBackPress() { @@ -549,6 +556,43 @@ export default { } }, }); + }, + // 头像区域点击事件 + handleAvatarClick() { + const that = this; + if (!that.hasLogin) { + that.showLoginPopup = true; // 显示登录弹窗 + return; + } + }, + handleLoginSuccess() { + const that = this; + that.showLoginPopup = false; // 关闭弹窗 + + // 强制重新获取用户信息(触发 Vuex 更新 userInfo) + that.getUserInfo(); + + // 延迟 500ms,确保 userInfo 已完全更新 + setTimeout(() => { + const user_info = that.userInfo || {}; + + //直接更新页面数据(头像、昵称),确保实时渲染 + that.setData({ + imgPath: user_info.user_avatar || "https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/static/xcxfile/appicon/default-avatar.png", + user_nickname: user_info.user_nickname || "亲爱的用户", + participantId: user_info.user_id || "", + uid: user_info.user_id || that.uid, + }); + + // 重新请求砍价数据 + if (that.mid) { + that.GetVendorCutPriceEventDetail(); // 重新加载砍价详情 + that.GetOtherCutPriceActivityList(); // 重新加载砍价记录 + } + + // 5. 强制刷新 DOM(兜底,确保数据同步到页面) + that.$forceUpdate(); + }, 500); // 延长延迟到 500ms,确保异步请求完成 }, closeLoginPopup() { this.showLoginPopup = false; diff --git a/components/loginPopup.vue b/components/loginPopup.vue index af4a953..6063b06 100644 --- a/components/loginPopup.vue +++ b/components/loginPopup.vue @@ -259,9 +259,16 @@ export default { UserInfo: user_info, }); }); - + // 核心:登录成功后,向父组件发送回调通知 + that.$emit("loginSuccess"); // 新增这行,通知父组件 that.close(); }, + fail: function () { + // 即使获取用户详情失败,也触发回调(避免登录后无响应) + that.$emit("loginSuccess"); + that.close(); + that.$.confirm("登录成功,但获取用户信息失败,请重试"); + }, }); }, },