Commit 615a98ed by Jaxon

fix(workspace): 修复服务中心通知弹窗路由跳转后this指向问题

修复checkServiceNotice方法中异步回调内this指向错误,导致路由跳转后无法正确更新页面状态的问题。通过引入that变量保存当前this引用,确保在wx.showModal回调中能正确访问页面实例。
1 parent 89a4f8eb
......@@ -132,6 +132,7 @@ Page({
},
async checkServiceNotice() {
const that = this;
for (let serviceCenterEnum of noticeSort) {
const { data } = await getCompanyNoticeList({
pageNum: 1,
......@@ -144,7 +145,7 @@ Page({
});
let index = this.data.storeManagementMenus.findIndex((e) => e.name === "服务中心");
this.setData({
that.setData({
[`storeManagementMenus[${index}].tipsNum`]: data?.total || 0,
});
......@@ -155,7 +156,7 @@ Page({
// 根据类型取到对应的值
const { message, ...dialogParams } = dialogOptions[serviceCenterEnum][noticeItem.reminderType || 1];
this.setData({
that.setData({
isShowingModal: true,
});
wx.showModal({
......@@ -164,10 +165,10 @@ Page({
showCancel: false,
confirmText: dialogParams.confirmButtonText,
success: function (res) {
wx.$router.go("packageWorkspace.companyNoticeDetail", { id: noticeItem.id });
this.setData({
that.setData({
isShowingModal: false,
});
wx.$router.go("packageWorkspace.companyNoticeDetail", { id: noticeItem.id });
},
});
break;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!