style.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template id="button-group-style">
  2. <div>
  3. <diy-style-contain title="按钮样式" class="fill-border-top">
  4. <el-radio-group v-model="buttonData.style" @change="radioChange($event, 'style')">
  5. <el-radio :label="1">{{ buttonData.type == 1 ? '图片' : '图标' }}+文字</el-radio>
  6. <el-radio :label="2">{{ buttonData.type == 1 ? '图片' : '图标' }}</el-radio>
  7. <el-radio :label="3">文字</el-radio>
  8. </el-radio-group>
  9. </diy-style-contain>
  10. <diy-style-contain title="按钮形状" class="fill-border-top" v-if="buttonData.style != 3">
  11. <div class="button-shape-box" flex="cross:center">
  12. <div class="button-shape-cycle" v-for="(it, i) in shapeList" @click="toggleShape(it, i)">
  13. <div class="button-shape-item"
  14. :class="buttonData.shape == it ? 'active' : ''"
  15. :style="{borderRadius: it == 'square' ? '0px' : it == 'round' ? '3px' : '50%'}"
  16. ></div>
  17. </div>
  18. </div>
  19. </diy-style-contain>
  20. <diy-style-contain title="按钮类型" class="fill-border-top" v-if="buttonData.style != 3">
  21. <el-radio-group v-model="buttonData.type" @change="radioChange($event, 'type')">
  22. <el-radio :label="1">图片</el-radio>
  23. <el-radio :label="2">图标</el-radio>
  24. </el-radio-group>
  25. </diy-style-contain>
  26. <diy-tabs title="组件样式" class="fill-border-top" radio_text='text' :default_item="defaultForm.tabItem" @change="colorSelect"></diy-tabs>
  27. <diy-tabs title="组件风格" class="fill-border-top" :list="buttonPattern" :default_item="buttonData.patternItem" radio_text='text' @change="patternChange"></diy-tabs>
  28. <diy-style-contain title="单行数量" class="fill-border-top">
  29. <el-radio-group v-model="buttonData.single_line" @change="radioChange($event, 'single_line')">
  30. <el-radio :label="3">3个</el-radio>
  31. <el-radio :label="4">4个</el-radio>
  32. <el-radio :label="5">5个</el-radio>
  33. </el-radio-group>
  34. </diy-style-contain>
  35. <diy-style-contain title="每页行数" class="fill-border-top" v-if="buttonData.pattern == 'swiper'">
  36. <el-radio-group v-model="buttonData.line_num" @change="radioChange($event, 'line_num')">
  37. <el-radio :label="1">1行</el-radio>
  38. <el-radio :label="2">2行</el-radio>
  39. </el-radio-group>
  40. </diy-style-contain>
  41. <diy-icon-set
  42. class="fill-border-top"
  43. title="图标设置"
  44. :list="iconList"
  45. :type="buttonData.type"
  46. suggest-text="建议尺寸:88*88"
  47. :tag-switch="true"
  48. :btn-style="buttonData.style"
  49. :max-icon-length="30"
  50. :show-link="true"
  51. :show-add-btn="true"
  52. :img-url="defaultImg"
  53. :default-tabs="[{name: 'marketing',children:['bargain_cate'] }]"
  54. :show-id="false"
  55. @change="setChange"
  56. ></diy-icon-set>
  57. <diy-color class="fill-border-top" :color-infos="colorInfos" :str-color="defColor" @chang="updateColor"></diy-color>
  58. <diy-size-setting top-name="边距" class="fill-border-top" :size-infos="sizeInfos" :size-infos-value="sizeInfosValue" :max-value="50" @chang="sliderChange"></diy-size-setting>
  59. <diy-size-setting top-name="圆角设置" class="fill-border-top" :size-infos="defaultForm.radiusInfos" :max-value="20" @chang="RadiusChange"></diy-size-setting>
  60. </div>
  61. </template>
  62. <script>
  63. Vue.component('button-group-style', {
  64. name: "button-group-style",
  65. mixins: [basicMixins],
  66. template: '#button-group-style',
  67. props: {
  68. activeItem: {
  69. type: Object,
  70. default () {
  71. return {}
  72. }
  73. }
  74. },
  75. data() {
  76. return {
  77. shapeList: ['square', 'round', 'cricle'], // 按钮形状
  78. buttonType: 1, // 按钮类型
  79. buttonPattern: [
  80. { label: '固定显示', value: 'fixed' },
  81. { label: '单行滑动', value: 'scroll' },
  82. { label: '分页滑动', value: 'swiper' },
  83. ],
  84. patternCurrent: 'fixed',
  85. btnType: 1,
  86. colorInfos: ['底部背景' ,'组件背景', '文字颜色'],
  87. defColor: ['', '', '#333333'],
  88. sizeInfos: ['上边距', '下边距', '左右边距'],
  89. sizeInfosValue: [8,8,0],
  90. buttonData: {
  91. style: 1, // 按钮样式
  92. type: 1, // 按钮类型
  93. single_line: 3, // 单行数量
  94. line_num: 1, // 每页行数
  95. shape: 'square', // 当前相中的按钮形状
  96. pattern: 'fixed', // 组件风格
  97. patternItem: null, // 组件风格对象
  98. },
  99. defaultImg: 'resources/img/decorate/default_picture.png',
  100. iconList: [
  101. {
  102. img: 'resources/img/decorate/group-goods/icon1.png',
  103. icon: 'el-icon-setting',
  104. is_show_tag: false,
  105. tags: '热门',
  106. tagsBgColor: '#f83287',
  107. tagsTextColor: '#ffffff',
  108. btnText: '三人团',
  109. link_params: null,
  110. },
  111. {
  112. img: 'resources/img/decorate/group-goods/icon2.png',
  113. icon: 'el-icon-setting',
  114. is_show_tag: false,
  115. tags: '热门',
  116. tagsBgColor: '#f83287',
  117. tagsTextColor: '#ffffff',
  118. btnText: '五人团',
  119. link_params: null,
  120. },
  121. {
  122. img: 'resources/img/decorate/group-goods/icon3.png',
  123. icon: 'el-icon-setting',
  124. is_show_tag: false,
  125. tags: '热门',
  126. tagsBgColor: '#f83287',
  127. tagsTextColor: '#ffffff',
  128. btnText: '十人团',
  129. link_params: null,
  130. }
  131. ],
  132. }
  133. },
  134. methods: {
  135. init() {
  136. basicMixins.methods.init.call(this); // 以前的数据调用一下
  137. if (this.result.data.buttonData) {
  138. this.buttonData = this.result.data.buttonData
  139. } else {
  140. this.result.data.buttonData = this.buttonData
  141. }
  142. this.updataInfos()
  143. },
  144. updateColor(e) { // 选择颜色
  145. this.colorInfos = e;
  146. if(this.result.data.colorInfos){
  147. this.colorInfos = this.result.data.colorInfos;
  148. } else {
  149. this.result.data.colorInfos = this.colorInfos;
  150. }
  151. this.result.computedStyle.searchBox = this.colorInfos[0].color
  152. this.result.computedStyle.iptBg = this.colorInfos[1].color
  153. this.result.computedStyle.textStyle = this.colorInfos[2].color
  154. this.updataInfos()
  155. },
  156. sliderChange(arr) {
  157. this.sizeInfos = arr
  158. if (this.result.data.sizeInfos && this.result.data.sizeInfos.length) {
  159. this.sizeInfos = this.result.data.sizeInfos
  160. } else {
  161. this.result.data.sizeInfos = this.sizeInfos
  162. }
  163. let top = this.sizeInfos[0] && (this.sizeInfos[0].value + this.sizeInfos[0].unit)
  164. let bottom = this.sizeInfos[1] && (this.sizeInfos[1].value + this.sizeInfos[1].unit)
  165. let lr = this.sizeInfos[2] && (this.sizeInfos[2].value + this.sizeInfos[2].unit)
  166. const style = {
  167. marginTop: top,
  168. marginBottom: bottom,
  169. marginLeft: lr,
  170. marginRight: lr
  171. }
  172. this.searchIpts = Object.assign(this.searchIpts, style)
  173. this.updataResult(this.searchIpts, 'searchIpts')
  174. },
  175. toggleShape(it, i) { // 按钮形状
  176. this.buttonData.shape = it
  177. this.updataInfos()
  178. },
  179. setChange(arr) { // 图标设置
  180. this.iconList = arr
  181. if (this.result.data.iconList && this.result.data.iconList.length) {
  182. this.iconList = this.result.data.iconList
  183. } else {
  184. this.result.data.iconList = this.iconList
  185. }
  186. this.updataInfos()
  187. },
  188. patternChange(e) { // 组件风格
  189. this.buttonData.pattern = e.item.value
  190. this.buttonData.patternItem = e.item
  191. this.updataInfos()
  192. },
  193. radioChange(e, name) {
  194. this.buttonData[name] = e
  195. this.updataInfos()
  196. },
  197. updataInfos() {
  198. this.$emit("update", this.result)
  199. }
  200. }
  201. });
  202. </script>
  203. <style>
  204. .button-shape-cycle {
  205. margin-right: 25px;
  206. }
  207. .button-shape-item {
  208. width: 36px;
  209. height: 36px;
  210. background-color: #DFDFDF;
  211. }
  212. .button-shape-cycle .active {
  213. border: 1px solid var(--primary, #2D8CF0);
  214. }
  215. </style>