import {isNumber} from "../utils/utils"; import {cardTypes} from "./enum"; const app = getApp(); const miniRatio = 2; const pcRatio = 2; export default class LastMayday { palette(data, number = 'xx', startTime = "xxxx年x月x日", endTime = 'xxxx年x月x日', userName = 'xx', projectName = 'xx培训', isOnline = false) { projectName = projectName.trim(); const config = JSON.parse(data.configs); const numberStyle = config.find(item => item.type == cardTypes.NUMBER_STYLE); // app.globalData.isPC = false; Object.keys(numberStyle).forEach(key => { if (isNumber(numberStyle[key])) { if (app.globalData.isPC) { numberStyle[key] = numberStyle[key] * pcRatio + "rpx" } else { numberStyle[key] = numberStyle[key] * miniRatio + "rpx" } } }) const textStyle = config.find(item => item.type == cardTypes.TEXT_STYLE); Object.keys(textStyle).forEach(key => { if (isNumber(textStyle[key])) { if (app.globalData.isPC) { textStyle[key] = textStyle[key] * pcRatio + "rpx" } else { textStyle[key] = textStyle[key] * miniRatio + "rpx" } } }) if (app.globalData.isPC) { return ( { width: data.drawWidth * pcRatio + 'rpx', height: data.drawHeight * pcRatio + 'rpx', views: [ { type: 'image', url: data.templatePicUrl, css: { width: data.drawWidth * pcRatio + 'rpx', height: data.drawHeight * pcRatio + 'rpx', }, }, { type: 'text', text: `编号:${number}`, css: numberStyle, }, { type: 'text', text: ` ${userName}同志于${startTime}-${endTime}参加”${projectName}”${isOnline ? "线上培训" : "线下培训"},完成规定培训内容。准予结业,特发此证。`, css: textStyle, }, ], } ); } else { return ( { width: data.drawWidth * miniRatio + 'rpx', height: data.drawHeight * miniRatio + 'rpx', views: [ { type: 'image', url: data.templatePicUrl, css: { width: data.drawWidth * miniRatio + 'rpx', height: data.drawHeight * miniRatio + 'rpx', }, }, { type: 'text', text: `编号:${number}`, css: numberStyle, }, { type: 'text', text: ` ${userName}同志于${startTime}-${endTime}参加”${projectName}”${isOnline ? "线上培训" : "线下培训"},完成规定培训内容。准予结业,特发此证。`, css: textStyle, }, ], } ); } } }