diy-center-menu.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template id="diy-center-menu">
  2. <div class="diy-center-box" :style="{background: bottomBg}">
  3. <div class="diy-center-list" :style="[computedStyle.searchIpts]">
  4. <div class="diy-center-cell" flex="cross:center" :style="{background: titleBg}" v-if="title">
  5. <div class="cell-title" :style="{color: titleColor}">{{ title }}</div>
  6. <div class="cell-subtitle" :style="{color: subtitleColor}" v-if="subTitle">{{ subTitle }}</div>
  7. <i v-if="icon" :class="icon" :style="{color: subtitleColor, fontSize: iconSize + 'px'}" style="margin-top: 2px;"></i>
  8. </div>
  9. <div class="diy-center-menu-box" flex="cross:center wrap:wrap" :style="[menuBoxStyle]">
  10. <div class="order-menu-items" :style="{width: itemWidth}" v-for="(item, index) in list" :key="index">
  11. <el-image class="order-menu-img" :style="{maxWidth: widthImg + 'px', height: heightImg + 'px'}" :src="imgToUrl(item.img)"></el-image>
  12. <div class="order-menu-text" :style="{color: btnColor}">{{ item.btnText }}</div>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. Vue.component('diy-center-menu', {
  20. name: "diy-center-menu",
  21. template: "#diy-center-menu",
  22. props: {
  23. activeItem: {
  24. type: Object,
  25. default () {
  26. return {}
  27. }
  28. },
  29. list: { // 列表
  30. type: Array,
  31. default: () => []
  32. },
  33. title: { // 标题
  34. type: String,
  35. default: ''
  36. },
  37. subTitle: { // 副标题
  38. type: String,
  39. default: ''
  40. },
  41. icon: { // 图标
  42. type: String,
  43. default: ''
  44. },
  45. iconSize: { // 图标的大小
  46. type: Number,
  47. default: 12
  48. },
  49. bottomBg: { // 底部背景
  50. type: String,
  51. default: ''
  52. },
  53. titleBg: { // 标题背景
  54. type: String,
  55. default: ''
  56. },
  57. contentBg: { // 内容背景
  58. type: String,
  59. default: ''
  60. },
  61. titleColor: { // 标题颜色
  62. type: String,
  63. default: ''
  64. },
  65. subtitleColor: { // 副标题颜色
  66. type: String,
  67. default: ''
  68. },
  69. btnColor: { // 按钮
  70. type: String,
  71. default: ''
  72. },
  73. widthImg: { // 图片的宽度
  74. type: Number,
  75. default: 24
  76. },
  77. heightImg: { // 图片的高度
  78. type: Number,
  79. default: 24
  80. },
  81. itemWidth: { // 按钮的宽度
  82. type: String,
  83. default: '20%'
  84. },
  85. },
  86. computed: {
  87. computedStyle() {
  88. return this.activeItem.computedStyle
  89. },
  90. menuBoxStyle(){
  91. let { conRadiusSets } = this.activeItem.computedStyle
  92. let result = {
  93. background:this.contentBg,
  94. ...conRadiusSets
  95. }
  96. return result
  97. }
  98. },
  99. data() {
  100. return {
  101. static_img_prefix: '<?= Yii::getAlias('@attachurl') ?>'+'/static',
  102. }
  103. },
  104. methods: {
  105. imgToUrl(url){
  106. if(url && url.indexOf('http') ==-1 && url.indexOf('resources/img') == -1){
  107. return this.static_img_prefix + url
  108. }
  109. return url
  110. },
  111. }
  112. });
  113. </script>
  114. <style>
  115. .diy-center-box,
  116. .diy-center-list {
  117. position: relative;
  118. overflow: hidden;
  119. }
  120. .diy-center-cell {
  121. padding: 20px 10px 12px;
  122. align-items: center;
  123. font-size: 14px;
  124. }
  125. .cell-title {
  126. font-size: 15px;
  127. font-weight: 700;
  128. }
  129. .cell-subtitle {
  130. flex: 1;
  131. text-align: right;
  132. font-size: 13px;
  133. color: #666;
  134. }
  135. .diy-center-menu-box {
  136. padding: 0 0 20px;
  137. text-align: center;
  138. background: #fff;
  139. }
  140. .order-menu-items {
  141. padding: 20px 0 0;
  142. }
  143. .order-menu-img {
  144. max-width: 30px;
  145. height: 25px;
  146. }
  147. .order-menu-text {
  148. font-size: 12px;
  149. padding-top: 10px;
  150. color: #333;
  151. }
  152. </style>