avatar.wxs 932 B

123456789101112131415161718192021222324252627282930
  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', systemInfo) {
  14. var res = getRegExp('^([0-9]+)(px|rpx)$').exec(size);
  15. if (res && res.length >= 3) {
  16. var px = res[1];
  17. if (res[2] === 'rpx') {
  18. px = Math.floor((systemInfo.windowWidth * res[1]) / 750);
  19. }
  20. return 'width:' + size + ';height:' + size + ';font-size:' + ((px / 8) * 3 + 2) + 'px';
  21. }
  22. },
  23. getStyles: function (isShow) {
  24. return isShow ? '' : 'display: none;';
  25. },
  26. };