地图订单修改
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { UserInfo, Marker } from '../../../types';
|
||||
import { avatarCache } from '../../../utils/avatarCache';
|
||||
import { API_BASE_URL } from '../../../services/apiService';
|
||||
|
||||
/**
|
||||
* 页面数据管理模块
|
||||
@@ -203,19 +204,22 @@ export class DataModule {
|
||||
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;
|
||||
// 将相对路径转换为完整URL
|
||||
let avatarUrl = person.avatarPath;
|
||||
if (!avatarUrl.startsWith('http')) {
|
||||
avatarUrl = `${API_BASE_URL}${avatarUrl}`;
|
||||
}
|
||||
|
||||
// 使用头像缓存获取本地图片路径
|
||||
processedPerson.avatarPath = await avatarCache.getAvatarPath(avatarUrl);
|
||||
} catch (error) {
|
||||
console.error('处理货运人员头像缓存失败:', error);
|
||||
// 如果头像缓存失败,使用默认头像
|
||||
processedPerson.avatarPath = '/images/user-avatar.png';
|
||||
}
|
||||
} else {
|
||||
// 如果没有头像路径,使用默认头像
|
||||
processedPerson.avatarPath = '/images/user-avatar.png';
|
||||
}
|
||||
|
||||
this.pageContext.setData({ currentDeliveryPerson: processedPerson });
|
||||
|
||||
Reference in New Issue
Block a user