avatar.wxs 904 B

1234567891011121314151617181920212223242526
  1. module.exports = {
  2. getClass: function (classPrefix, size, shape, bordered) {
  3. var hasPx = (size || '').indexOf('px') > -1;
  4. var borderSize = hasPx ? 'medium' : size;
  5. var classNames = [
  6. classPrefix,
  7. classPrefix + (shape === 'round' ? '--round' : '--circle'),
  8. bordered ? classPrefix + '--border' + ' ' + classPrefix + '--border-' + borderSize : '',
  9. hasPx ? '' : classPrefix + '--' + size,
  10. ];
  11. return classNames.join(' ');
  12. },
  13. getSize: function (size = 'medium') {
  14. var pxIndex = size.indexOf('px');
  15. if (pxIndex > -1) {
  16. return 'width:' + size + ';height:' + size + ';font-size:' + ((size.slice(0, pxIndex) / 8) * 3 + 2) + 'px;';
  17. }
  18. },
  19. getStyles: function (isShow, zIndex) {
  20. var displayStyle = isShow ? '' : 'display: none;';
  21. var zIndexStyle = zIndex ? 'z-index:' + zIndex + ';' : '';
  22. return displayStyle + zIndexStyle;
  23. },
  24. };