style.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template id="happiness-member-card-style">
  2. <div>
  3. <!-- 公共 -->
  4. <diy-color class="fill-border-top" :color-infos="colorInfos" :str-color="defColor" @chang="updateColor"></diy-color>
  5. <diy-size-setting class="fill-border-top" top-name="边距" :size-infos="sizeInfos" :min-value="0" :size-infos-max="sizeInfosMax" @chang="updateSize"></diy-size-setting>
  6. <diy-size-setting class="fill-border-top" top-name="圆角设置" :size-infos="radiusInfos" :size-infos-value="[4, 4]" :max-value="20" @chang="RadiusChange"></diy-size-setting>
  7. </div>
  8. </template>
  9. <script>
  10. Vue.component('happiness-member-card-style', {
  11. name: "happiness-member-card-style",
  12. mixins: [basicMixins],
  13. template: '#happiness-member-card-style',
  14. props: {
  15. activeItem: {
  16. type: Object,
  17. default () {
  18. return {}
  19. }
  20. }
  21. },
  22. data() {
  23. return {
  24. colorInfos: ['背景', '昵称', '资金颜色', '资金值颜色'],
  25. defColor: ['#FFFFFF', '#2F3033', '#AAAAAA', '#333333'],
  26. sizeInfos: ['上边距', '下边距', '左右边距','嵌入上面'],
  27. sizeInfosMax: [50, 50, 20],
  28. radiusInfos: ['上圆角', '下圆角'],
  29. }
  30. },
  31. methods: {
  32. init() {
  33. basicMixins.methods.init.call(this); // 以前的数据调用一下
  34. },
  35. updateColor(arr) { // 选择颜
  36. this.updateSome(arr, 'colorInfos')
  37. let style = this.result.computedStyle
  38. let colorArr = ['background', 'nicknameColor', 'descColor', 'btnColor']
  39. colorArr.forEach((it, i) => {
  40. style = Object.assign(style, { [it]: this.colorInfos[i].color })
  41. })
  42. this.$emit("update", this.result)
  43. },
  44. updateSize(arr) { // 选择尺寸
  45. this.updateSome(arr, 'sizeInfos')
  46. let style = this.result.computedStyle
  47. let sizeArr = ['marginTop', 'marginBottom', 'aroundMargin','posTop'] // 'spacing', 间距,不知道哪里用到,先去掉
  48. sizeArr.forEach((it, i) => {
  49. style.sizeObj = Object.assign(style.sizeObj || {}, { [it]: this.sizeInfos[i].value + this.sizeInfos[i].unit })
  50. })
  51. this.$emit("update", this.result)
  52. },
  53. updateSome(arr, name) {
  54. this[name] = arr
  55. if (this.result.data[name] && this.result.data[name].length) {
  56. this[name] = this.result.data[name]
  57. } else {
  58. this.result.data[name] = this[name]
  59. }
  60. },
  61. }
  62. });
  63. </script>
  64. <style>
  65. .avatar-uploader .el-upload {
  66. border: 1px dashed #d9d9d9;
  67. border-radius: 6px;
  68. cursor: pointer;
  69. position: relative;
  70. overflow: hidden;
  71. }
  72. .avatar-uploader .el-upload:hover {
  73. border-color: #409EFF;
  74. }
  75. .avatar-uploader-icon {
  76. font-size: 28px;
  77. color: #8c939d;
  78. width: 92px;
  79. height: 92px;
  80. line-height: 92px;
  81. text-align: center;
  82. }
  83. .avatar {
  84. width: 92px;
  85. height: 92px;
  86. display: block;
  87. }
  88. </style>