style.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template id="store-cate-recommend-style">
  2. <div>
  3. <diy-style-contain title="搜索" class="clear-diy-style fill-border-top">
  4. <el-radio-group v-model="searchStyle.show" @change="btnChange($event, 'show')">
  5. <el-radio :label="0">隐藏</el-radio>
  6. <el-radio :label="1">显示</el-radio>
  7. </el-radio-group>
  8. <!-- <div style="padding-top: 10px" v-if="searchStyle.show == 1">
  9. <store-search-style :active-item="searchStyle" @update="update" ></store-search-style>
  10. </div>-->
  11. </diy-style-contain>
  12. <div class="tabs">
  13. <diy-style-contain title="按钮样式" class="fill-border-top">
  14. <el-radio-group v-model="buttonData.style" @change="radioChange($event, 'style')">
  15. <el-radio :label="1">{{ buttonData.type == 1 ? '图片' : '图标' }}+文字</el-radio>
  16. <el-radio :label="2">{{ buttonData.type == 1 ? '图片' : '图标' }}</el-radio>
  17. <el-radio :label="3">文字</el-radio>
  18. </el-radio-group>
  19. </diy-style-contain>
  20. <diy-style-contain title="按钮形状" class="fill-border-top" v-if="buttonData.style != 3">
  21. <div class="button-shape-box" flex="cross:center">
  22. <div class="button-shape-cycle" v-for="(it, i) in shapeList" @click="toggleShape(it, i)">
  23. <div class="button-shape-item"
  24. :class="buttonData.shape == it ? 'active' : ''"
  25. :style="{borderRadius: it == 'square' ? '0px' : it == 'round' ? '3px' : '50%'}"
  26. ></div>
  27. </div>
  28. </div>
  29. </diy-style-contain>
  30. <diy-style-contain title="按钮类型" class="fill-border-top" v-if="buttonData.style != 3">
  31. <el-radio-group v-model="buttonData.type" @change="radioChange($event, 'type')">
  32. <el-radio :label="1">图片</el-radio>
  33. <!-- <el-radio :label="2">图标</el-radio> -->
  34. </el-radio-group>
  35. </diy-style-contain>
  36. <diy-tabs title="组件样式" class="fill-border-top" radio_text='text' :default_item="defaultForm.tabItem" @change="colorSelect"></diy-tabs>
  37. <diy-tabs title="组件风格" class="fill-border-top" :list="buttonPattern" :default_item="buttonData.patternItem" radio_text='text' @change="patternChange"></diy-tabs>
  38. <diy-style-contain title="单行数量" class="fill-border-top">
  39. <el-radio-group v-model="buttonData.single_line" @change="radioChange($event, 'single_line')">
  40. <el-radio :label="3">3个</el-radio>
  41. <el-radio :label="4">4个</el-radio>
  42. <el-radio :label="5">5个</el-radio>
  43. </el-radio-group>
  44. </diy-style-contain>
  45. <diy-style-contain title="每页行数" class="fill-border-top" v-if="buttonData.pattern == 'swiper'">
  46. <el-radio-group v-model="buttonData.line_num" @change="radioChange($event, 'line_num')">
  47. <el-radio :label="1">1行</el-radio>
  48. <el-radio :label="2">2行</el-radio>
  49. </el-radio-group>
  50. </diy-style-contain>
  51. <diy-icon-set
  52. class="fill-border-top"
  53. title="图标设置"
  54. :list="iconList"
  55. :type="buttonData.type"
  56. suggest-text="建议尺寸:88*88"
  57. :tag-switch="tagswitch"
  58. :btn-style="buttonData.style"
  59. :max-icon-length="30"
  60. :show-link="false"
  61. :show-store-link = "true"
  62. :show-add-btn="true"
  63. :img-url="defaultImg"
  64. :default-tabs="defaultTabs"
  65. @change="setChange"
  66. >
  67. </diy-icon-set>
  68. <diy-color class="fill-border-top" :color-infos="colorInfos" :str-color="defColor" @chang="updateColor"></diy-color>
  69. <diy-size-setting top-name="边距" class="fill-border-top" :size-infos="sizeInfos" :size-infos-value="sizeInfosValue" :max-value="50" @chang="sliderChange"></diy-size-setting>
  70. <diy-size-setting top-name="圆角设置" class="fill-border-top" :size-infos="defaultForm.radiusInfos" :max-value="20" @chang="RadiusChange"></diy-size-setting>
  71. </div>
  72. <transition name="el-fade-in-linear">
  73. <store-recommend-list-style :active-item="childItem" @update="update" v-if="show"></store-recommend-list-style>
  74. </transition>
  75. </div>
  76. </template>
  77. <script>
  78. Vue.component('store-cate-recommend-style', {
  79. name: "store-cate-recommend-style",
  80. mixins: [basicMixins],
  81. template: '#store-cate-recommend-style',
  82. props: {
  83. activeItem: {
  84. type: Object,
  85. default () {
  86. return { }
  87. }
  88. }
  89. },
  90. data() {
  91. return {
  92. searchStyle:{
  93. show:0,
  94. },
  95. tagswitch:false,
  96. childItem: null, // 当前item
  97. activeIndex: 0, // 当前索引
  98. show: true,
  99. shapeList: ['square', 'round', 'cricle'], // 按钮形状
  100. buttonType: 1, // 按钮类型
  101. buttonPattern: [
  102. { label: '固定显示', value: 'fixed' },
  103. { label: '单行滑动', value: 'scroll' },
  104. { label: '分页滑动', value: 'swiper' },
  105. ],
  106. patternCurrent: 'scroll',
  107. btnType: 1,
  108. colorInfos: ['底部背景' ,'组件背景', '文字颜色','选中颜色','间隔颜色'],
  109. defColor: ['', '', '#333333','#F1DF1F','#f2f2f2'],
  110. sizeInfos: ['上边距', '下边距', '左右边距'],
  111. sizeInfosValue: [8,8,0],
  112. buttonData: {
  113. style: 1, // 按钮样式
  114. type: 1, // 按钮类型
  115. single_line: 3, // 单行数量
  116. line_num: 1, // 每页行数
  117. shape: 'cricle', // 当前相中的按钮形状
  118. pattern: 'scroll', // 组件风格
  119. patternItem: null, // 组件风格对象
  120. },
  121. defaultImg: 'resources/img/decorate/default_btn1.png',
  122. iconList: [
  123. {
  124. img: 'resources/img/decorate/default_btn1.png',
  125. icon: 'el-icon-setting',
  126. is_show_tag: true,
  127. tags: '热门',
  128. tagsBgColor: '#f83287',
  129. tagsTextColor: '#ffffff',
  130. btnText: '按钮文字',
  131. link_params: null,
  132. },
  133. {
  134. img: 'resources/img/decorate/default_btn2.png',
  135. icon: 'el-icon-setting',
  136. is_show_tag: false,
  137. tags: '热门',
  138. tagsBgColor: '#f83287',
  139. tagsTextColor: '#ffffff',
  140. btnText: '按钮文字',
  141. link_params: null,
  142. },
  143. {
  144. img: 'resources/img/decorate/default_btn3.png',
  145. icon: 'el-icon-setting',
  146. is_show_tag: false,
  147. tags: '热门',
  148. tagsBgColor: '#f83287',
  149. tagsTextColor: '#ffffff',
  150. btnText: '按钮文字',
  151. link_params: null,
  152. },
  153. {
  154. img: 'resources/img/decorate/default_btn4.png',
  155. icon: 'el-icon-setting',
  156. is_show_tag: false,
  157. tags: '热门',
  158. tagsBgColor: '#f83287',
  159. tagsTextColor: '#ffffff',
  160. btnText: '按钮文字',
  161. link_params: null,
  162. }
  163. ],
  164. defaultTabs: ["mall", "goods", "addons", "other"],
  165. }
  166. },
  167. watch: {
  168. activeIndex(newVal, OldVal) {
  169. this.show = false
  170. if (newVal !== OldVal) {
  171. this.updateData("activeIndex", newVal)
  172. }
  173. setTimeout(() => {
  174. this.show = true
  175. }, 200)
  176. },
  177. goodList: {
  178. handler(newValue) {
  179. // 监测数据变化去统一update,会更新多次
  180. if (newValue && newValue.length) {
  181. this.result.data.goodList = newValue
  182. this.$emit("update", this.result)
  183. }
  184. },
  185. immediate: true
  186. }
  187. },
  188. created() {
  189. // 设置默认值
  190. this.result = deepClone(this.activeItem)
  191. if (this.result.data.goodList) {
  192. console.log(1111111111)
  193. this.goodList = this.result.data.goodList
  194. this.activeIndex = this.result.data.activeIndex || 0 // 当前索引
  195. this.childItem = this.result.data.goodList[this.activeIndex]
  196. console.log('this.childItem',this.childItem)
  197. } else {
  198. console.log(222222222)
  199. var childItem = this.getChildItem()
  200. this.goodList = [childItem]
  201. this.childItem = childItem
  202. this.activeIndex = 0 // 当前索引
  203. }
  204. this.init()
  205. // 初始列表耦合setKey设置对应属性 -- 以及更新对应updataList
  206. this.initList("list")
  207. this.initList("tabList")
  208. this.initList("selectImgList")
  209. this.initList("selectBackList")
  210. this.initList("subtitleList")
  211. this.initList("bgColorSet")
  212. },
  213. methods: {
  214. updateData(key, value) {
  215. var obj = this.result.data
  216. this.result.data = Object.assign(obj, {
  217. [key]: value
  218. })
  219. this.$emit("update", this.result)
  220. },
  221. deepMerge(obj1, obj2) {
  222. let key;
  223. for (key in obj2) {
  224. // 如果target(也就是obj1[key])存在,且是对象的话再去调用deepMerge,否则就是obj1[key]里面没这个对象,需要与obj2[key]合并
  225. obj1[key] = obj1[key] && obj1[key].toString() === "[object Object]" ?
  226. this.deepMerge(obj1[key], obj2[key]) :
  227. (obj1[key] = obj2[key]);
  228. }
  229. return obj1;
  230. },
  231. update(item, index) {
  232. var list = deepClone(this.goodList) // 克隆一下
  233. var oldItem = list[this.activeIndex]
  234. var newItem = this.deepMerge(oldItem, item) // 合并数据
  235. // 直接全部覆盖
  236. list[this.activeIndex] = newItem
  237. this.childItem = newItem
  238. this.goodList = list
  239. this.updateData("goodList", list)
  240. },
  241. getChildItem() {
  242. var item = Object.create(null)
  243. item.data = {}
  244. item.computedStyle = {
  245. aroundMargin:'12px',
  246. marginBottom:'0',
  247. marginTop:'12px',
  248. spacing:'20px'
  249. }
  250. return item
  251. },
  252. initList(target) {
  253. var data = this.result.computedStyle
  254. if (this[target] && !this[target].length) {
  255. return false
  256. }
  257. var arr = this[target].map(item => {
  258. var obj = Object.assign(item, {
  259. value: item.value
  260. })
  261. if ((item.setKey in data) && data[item.setKey] !== "") {
  262. obj.value = data[item.setKey]
  263. }
  264. return obj
  265. });
  266. this[target] = arr
  267. },
  268. init() {
  269. basicMixins.methods.init.call(this); // 以前的数据调用一下
  270. if (this.result.data.buttonData) {
  271. this.buttonData = this.result.data.buttonData
  272. } else {
  273. this.result.data.buttonData = this.buttonData
  274. }
  275. if (this.result.data.searchStyle) {
  276. this.searchStyle = this.result.data.searchStyle
  277. } else {
  278. this.result.data.searchStyle = this.searchStyle
  279. }
  280. if(this.result.data.pickType){
  281. this.pickType = this.result.data.pickType
  282. } else {
  283. this.result.data.pickType = this.pickType
  284. }
  285. if(this.result.data.defaultTabs){
  286. this.defaultTabs = this.result.data.defaultTabs
  287. } else {
  288. this.result.data.defaultTabs = this.defaultTabs
  289. }
  290. //设置默认单行滑动的样式
  291. this.patternChange({
  292. index:1,
  293. item:{
  294. label:'单行滑动',
  295. value:'scroll'
  296. }
  297. })
  298. this.updataInfos()
  299. },
  300. updateColor(e) { // 选择颜色
  301. this.colorInfos = e;
  302. if(this.result.data.colorInfos){
  303. this.colorInfos = this.result.data.colorInfos;
  304. } else {
  305. this.result.data.colorInfos = this.colorInfos;
  306. }
  307. this.result.computedStyle.searchBox = this.colorInfos[0].color
  308. this.result.computedStyle.iptBg = this.colorInfos[1].color
  309. this.result.computedStyle.textStyle = this.colorInfos[2].color
  310. this.result.computedStyle.selecttextStyle = this.colorInfos[3].color
  311. this.result.computedStyle.gapStyle = this.colorInfos[4].color
  312. this.updataInfos()
  313. },
  314. sliderChange(arr) {
  315. this.sizeInfos = arr
  316. if (this.result.data.sizeInfos && this.result.data.sizeInfos.length) {
  317. this.sizeInfos = this.result.data.sizeInfos
  318. } else {
  319. this.result.data.sizeInfos = this.sizeInfos
  320. }
  321. let top = this.sizeInfos[0] && (this.sizeInfos[0].value + this.sizeInfos[0].unit)
  322. let bottom = this.sizeInfos[1] && (this.sizeInfos[1].value + this.sizeInfos[1].unit)
  323. let lr = this.sizeInfos[2] && (this.sizeInfos[2].value + this.sizeInfos[2].unit)
  324. const style = {
  325. marginTop: top,
  326. marginBottom: bottom,
  327. marginLeft: lr,
  328. marginRight: lr
  329. }
  330. this.searchIpts = Object.assign(this.searchIpts, style)
  331. this.updataResult(this.searchIpts, 'searchIpts')
  332. },
  333. toggleShape(it, i) { // 按钮形状
  334. this.buttonData.shape = it
  335. this.updataInfos()
  336. },
  337. setChange(arr) { // 图标设置
  338. this.iconList = arr
  339. if (this.result.data.iconList && this.result.data.iconList.length) {
  340. this.iconList = this.result.data.iconList
  341. } else {
  342. this.result.data.iconList = this.iconList
  343. }
  344. this.updataInfos()
  345. },
  346. patternChange(e) { // 组件风格
  347. this.buttonData.pattern = e.item.value
  348. this.buttonData.patternItem = e.item
  349. this.updataInfos()
  350. },
  351. radioChange(e, name) {
  352. this.buttonData[name] = e
  353. this.updataInfos()
  354. },
  355. btnChange(e,name){
  356. this.searchStyle[name] = e
  357. this.result.data.searchStyle = this.searchStyle
  358. this.updataInfos()
  359. },
  360. updataInfos() {
  361. this.$emit("update", this.result)
  362. }
  363. }
  364. });
  365. </script>
  366. <?php
  367. use common\helpers\ComponentHelper;
  368. use common\helpers\AddonHelper;
  369. ComponentHelper::loadComponentView('style', AddonHelper::getAddonRootPath('Store') . 'backend/views/components/diy/store-recommend-list');
  370. ComponentHelper::loadComponentView('style', AddonHelper::getAddonRootPath('Store') . 'backend/views/components/diy/store-search');
  371. ?>
  372. <style>
  373. .button-shape-cycle {
  374. margin-right: 25px;
  375. }
  376. .button-shape-item {
  377. width: 36px;
  378. height: 36px;
  379. background-color: #DFDFDF;
  380. }
  381. .button-shape-cycle .active {
  382. border: 1px solid var(--primary, #2D8CF0);
  383. }
  384. </style>