地址路径修改
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { UserInfo, Marker } from '../../../types';
|
||||
import { avatarCache } from '../../../utils/avatarCache';
|
||||
|
||||
/**
|
||||
* 页面数据管理模块
|
||||
@@ -80,16 +81,48 @@ export class DataModule {
|
||||
/**
|
||||
* 更新用户信息
|
||||
*/
|
||||
public updateUserInfo(userInfo: UserInfo | null): void {
|
||||
public async updateUserInfo(userInfo: UserInfo | null): Promise<void> {
|
||||
if (!userInfo) {
|
||||
this.pageContext.setData({
|
||||
userInfo: null,
|
||||
isLoggedIn: false
|
||||
});
|
||||
|
||||
// 更新按钮显示状态
|
||||
if (this.pageContext.updateButtonDisplayStatus) {
|
||||
this.pageContext.updateButtonDisplayStatus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理头像缓存
|
||||
const processedUserInfo = { ...userInfo };
|
||||
if (userInfo.avatarPath) {
|
||||
try {
|
||||
// 只有在用户已签到的情况下才使用头像缓存
|
||||
const app = getApp<any>();
|
||||
const isSignedIn = app.globalData.userInfo && app.globalData.userInfo.status === 'signed_in';
|
||||
|
||||
if (isSignedIn) {
|
||||
processedUserInfo.avatarPath = await avatarCache.getAvatarPath(userInfo.avatarPath);
|
||||
} else {
|
||||
// 未签到状态,直接使用原始路径
|
||||
processedUserInfo.avatarPath = userInfo.avatarPath;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理用户头像缓存失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
this.pageContext.setData({
|
||||
userInfo,
|
||||
isLoggedIn: !!userInfo
|
||||
userInfo: processedUserInfo,
|
||||
isLoggedIn: true
|
||||
});
|
||||
|
||||
// 更新按钮显示状态
|
||||
if (this.pageContext.updateButtonDisplayStatus) {
|
||||
this.pageContext.updateButtonDisplayStatus();
|
||||
}
|
||||
if (this.pageContext.updateButtonDisplayStatus) {
|
||||
this.pageContext.updateButtonDisplayStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,8 +193,32 @@ export class DataModule {
|
||||
/**
|
||||
* 设置当前选中货运人员
|
||||
*/
|
||||
public setCurrentDeliveryPerson(person: any): void {
|
||||
this.pageContext.setData({ currentDeliveryPerson: person });
|
||||
public async setCurrentDeliveryPerson(person: any): Promise<void> {
|
||||
if (!person) {
|
||||
this.pageContext.setData({ currentDeliveryPerson: null });
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理头像缓存
|
||||
const processedPerson = { ...person };
|
||||
if (person.avatarPath) {
|
||||
try {
|
||||
// 只有在用户已签到的情况下才使用头像缓存
|
||||
const app = getApp<any>();
|
||||
const isSignedIn = app.globalData.userInfo && app.globalData.userInfo.status === 'signed_in';
|
||||
|
||||
if (isSignedIn) {
|
||||
processedPerson.avatarPath = await avatarCache.getAvatarPath(person.avatarPath);
|
||||
} else {
|
||||
// 未签到状态,直接使用原始路径
|
||||
processedPerson.avatarPath = person.avatarPath;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理货运人员头像缓存失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
this.pageContext.setData({ currentDeliveryPerson: processedPerson });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user