iconfont.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. Component({
  2. properties: {
  3. // mj-lanmao | mj-heimao | mj--astonished | mj--angel | mj--devil | mj--in-love | mj--mute | mj--sad | mj--sad- | mj--scared | mj--secret | mj--scared- | mj--shocked | mj--sick | mj--smile | mj--smile- | mj--sleeping | mj--smiling- | mj--smiling | mj--sweat | mj--surprised | mj--smirking | mj--thinking | mj--tired | mj--tongue | mj--tongue- | mj--tongue-1 | mj--unamused | mj--wink | mj--vomiting | mj--zombie | mj--vomiting- | mj--newastonished- | mj--cool | mj--confused | mj--angry | mj--cool- | mj--dizzy | mj--cry | mj--cry- | mj--expressionless | mj--flushed | mj--happy- | mj--happy-1 | mj--happy | mj--injury | mj--joy | mj--kiss | mj--kiss- | mj--kiss-1 | mj--mask | mj--neutral
  4. name: {
  5. type: String,
  6. },
  7. // string | string[]
  8. color: {
  9. type: null,
  10. observer: function(color) {
  11. this.setData({
  12. colors: this.fixColor(),
  13. isStr: typeof color === 'string',
  14. });
  15. }
  16. },
  17. size: {
  18. type: Number,
  19. value: 18,
  20. observer: function(size) {
  21. this.setData({
  22. svgSize: size,
  23. });
  24. },
  25. },
  26. },
  27. data: {
  28. colors: '',
  29. svgSize: 18,
  30. quot: '"',
  31. isStr: true,
  32. },
  33. methods: {
  34. fixColor: function() {
  35. var color = this.data.color;
  36. var hex2rgb = this.hex2rgb;
  37. if (typeof color === 'string') {
  38. return color.indexOf('#') === 0 ? hex2rgb(color) : color;
  39. }
  40. return color.map(function (item) {
  41. return item.indexOf('#') === 0 ? hex2rgb(item) : item;
  42. });
  43. },
  44. hex2rgb: function(hex) {
  45. var rgb = [];
  46. hex = hex.substr(1);
  47. if (hex.length === 3) {
  48. hex = hex.replace(/(.)/g, '$1$1');
  49. }
  50. hex.replace(/../g, function(color) {
  51. rgb.push(parseInt(color, 0x10));
  52. return color;
  53. });
  54. return 'rgb(' + rgb.join(',') + ')';
  55. }
  56. }
  57. });