统一排行榜页:四角色七时段,对接 phbhqsj 新接口
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
19
miniprogram/utils/avatar.js
Normal file
19
miniprogram/utils/avatar.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/** 头像 URL 解析(排行榜等页面共用) */
|
||||
export function getDefaultAvatarUrl(app) {
|
||||
const g = app || getApp();
|
||||
const oss = g.globalData.ossImageUrl || '';
|
||||
const def = g.globalData.morentouxiang || '';
|
||||
if (!def) return '';
|
||||
if (def.startsWith('http')) return def;
|
||||
return oss + def.replace(/^\//, '');
|
||||
}
|
||||
|
||||
export function resolveAvatarUrl(path, app) {
|
||||
if (!path || path === 'null' || path === 'undefined') return '';
|
||||
const s = String(path).trim();
|
||||
if (!s) return '';
|
||||
if (s.startsWith('http')) return s;
|
||||
const g = app || getApp();
|
||||
const oss = g.globalData.ossImageUrl || '';
|
||||
return oss + s.replace(/^\//, '');
|
||||
}
|
||||
Reference in New Issue
Block a user