update:优化未登录进入砍价弹窗,以及点击头像登录弹窗
This commit is contained in:
parent
d069df8461
commit
851b48f822
@ -3,7 +3,7 @@
|
||||
<view style="background: rgb(41, 36, 56)">
|
||||
<view class="bargin" v-if="show == false">
|
||||
<view class="top-sty">
|
||||
<view class="user-info">
|
||||
<view class="user-info" @tap="handleAvatarClick">
|
||||
<image class="user-img" lazy-load :src="imgPath"></image>
|
||||
<view class="username">{{ user_nickname }}</view>
|
||||
</view>
|
||||
@ -338,7 +338,7 @@
|
||||
:shareDataDefault="shareData"
|
||||
ref="shareBoxApp"
|
||||
></share-box-app>
|
||||
<loginPopup :show="showLoginPopup" @close="closeLoginPopup"></loginPopup>
|
||||
<loginPopup :show="showLoginPopup" @close="closeLoginPopup" @loginSuccess="handleLoginSuccess"></loginPopup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -259,9 +259,16 @@ export default {
|
||||
UserInfo: user_info,
|
||||
});
|
||||
});
|
||||
|
||||
// 核心:登录成功后,向父组件发送回调通知
|
||||
that.$emit("loginSuccess"); // 新增这行,通知父组件
|
||||
that.close();
|
||||
},
|
||||
fail: function () {
|
||||
// 即使获取用户详情失败,也触发回调(避免登录后无响应)
|
||||
that.$emit("loginSuccess");
|
||||
that.close();
|
||||
that.$.confirm("登录成功,但获取用户信息失败,请重试");
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user