index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. Component({
  2. externalClasses: [
  3. 'l-class',
  4. 'l-class-text',
  5. 'l-text-class'
  6. ],
  7. properties: {
  8. icon: String,
  9. iconColor: {
  10. type: String,
  11. value: '#3963BC'
  12. },
  13. iconSize: {
  14. type: String,
  15. value: '28'
  16. },
  17. text: String,
  18. src: String,
  19. openData: {
  20. type: Array,
  21. observer: '_initOpenData'
  22. },
  23. shape: {
  24. type: String,
  25. value: 'circle'
  26. },
  27. mode: {
  28. type: String,
  29. value: 'scaleToFill'
  30. },
  31. size: {
  32. type: Number,
  33. value: 120,
  34. },
  35. placement: {
  36. type: String,
  37. value: 'right'
  38. },
  39. },
  40. data: {
  41. _isHaveUserNickName: false,
  42. _isHaveUserAvatarUrl: false,
  43. _iconSize: '',
  44. _iconColor: '#ffffff'
  45. },
  46. methods: {
  47. _initOpenData: function (openData) {
  48. this._isHaveUserAvatarUrl(openData);
  49. this._isHaveUserNickName(openData);
  50. },
  51. _isHaveUserAvatarUrl: function (openData) {
  52. this.setData({
  53. _isHaveUserAvatarUrl: openData.indexOf('userAvatarUrl') !== -1
  54. });
  55. },
  56. _isHaveUserNickName: function (openData) {
  57. this.setData({
  58. _isHaveUserNickName: openData.indexOf('userNickName') !== -1
  59. });
  60. },
  61. tapAvatar: function (e) {
  62. this.triggerEvent('lintap', e, {
  63. bubbles: true,
  64. composed: true
  65. });
  66. },
  67. }
  68. });