import dataDemo from './dataDemo'; /** * xml经过doT.js编译出的模板函数 * 因为小游戏不支持new Function,模板函数只能外部编译 * 可直接拷贝本函数到小游戏中使用 */ function tplFunc(it) { const parts = []; const data = it.data || []; const dataLength = data.length; // 预定义基础结构 parts.push(''); // 预定义模板路径 const bgTemplates = [ 'openDataContext/image/bg_horizontal_0.png', ]; const medalTemplates = [ 'openDataContext/image/rank_Num_1.png', 'openDataContext/image/rank_Num_2.png', 'openDataContext/image/rank_Num_3.png', 'openDataContext/image/rank_Num_4.png' ]; const lineImgSrc = "openDataContext/image/line.png"; const selfmedal = "openDataContext/image/rank_Num_self.png"; // 处理排行榜数据 for (let i = 0; i < dataLength; i++) { const item = data[i]; const rank = i + 1; const bgIndex = i <= 2 ? i : 3; const medalClass = rank < 4 ? rank : 4; parts.push( ``, '', ``, ``, '', '', // '', // ``, //'', '', ``, '', ``, '' ); } parts.push(''); // 处理自己的排名信息 if (it.selfItem) { let imgIdx = Math.min(it.selfRankIdx >= 0 ? it.selfRankIdx + 1 : 4, 4); const rankDisplay = it.selfRankIdx < 0 ? "未上榜" : (it.selfRankIdx + 1); parts.push( ` `, '', ``, '', ``, ``, '', '', //``, ``, '', ); } parts.push(''); return parts.join(''); } var template = { tplFunc:tplFunc, } export default template;