import {isNumber} from "../utils/utils"; const app = getApp(); export default class LastMayday { palette(data) { const config = JSON.parse(data.configs); let ratio = 0; if (app.globalData.isPC) { ratio = 2; } else { ratio = 2; } let viewsConfigs = config.map(configItem => { let viewText = ''; let textIndent = configItem.textIndent; let padEmptyStr = ''; if (textIndent > 0) { padEmptyStr = new Array(textIndent).fill('').join(' '); } viewText = padEmptyStr + configItem.content; Object.keys(configItem).forEach(key => { if (isNumber(configItem[key])) { configItem[key] = configItem[key] * ratio + "rpx" } }); return { type: 'text', text: viewText, css: configItem }; }); return ( { width: data.drawWidth * ratio + 'rpx', height: data.drawHeight * ratio + 'rpx', views: [ { type: 'image', url: data.templatePicUrl, css: { width: data.drawWidth * ratio + 'rpx', height: data.drawHeight * ratio + 'rpx', }, }, ...viewsConfigs ], } ); } }