style.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. <template id="store-commodity-group-style">
  2. <div class="store-commodity-group-style">
  3. <diy-tabs class="fill-border-top" :default_item="defaultForm.tabItem" title="样式" radio_text='text' :default_color="defaultForm.default_color" @change="colorSelect"></diy-tabs>
  4. <!-- 公共 -->
  5. <diy-style-contain title="风格" class="clear-diy-style fill-border-top">
  6. <el-radio-group v-model="style" @change="onStyleList">
  7. <el-radio-button :label="item.label" v-for="(item,index) in styleList" :key="index">
  8. <div flex="cross:center" class="flex-x-center" style="width: 56px;height: 38px;">
  9. <img :src="item.src" style="width: 26px;">
  10. </div>
  11. </el-radio-button>
  12. </el-radio-group>
  13. </diy-style-contain>
  14. <diy-style-contain title="选择商品" class="clear-diy-style fill-border-top">
  15. <div style="margin-bottom: 10px;">
  16. <el-radio-group v-model="chooseGoods" @change="updateData($event,'chooseGoods')">
  17. <el-radio :label="1">选择门店商品</el-radio>
  18. <el-radio :label="2">选择门店商品分类</el-radio>
  19. <!-- <el-radio :label="3">选择分组</el-radio> -->
  20. </el-radio-group>
  21. </div>
  22. <div class="pick-goods" v-if="chooseGoods == 1">
  23. <com-pick-link @selected="selectNavUrl" :default-select-list="defaultSelectList" :pick-type="pickType" :default-tabs="[{name: 'marketing',children:['store_goods'] }]" :parameter="{parameter:{addonsFields: addonsKeyFields}}">
  24. <div class="add-goods-btn">+添加</div>
  25. </com-pick-link>
  26. <div flex="cross:center" style="margin-top: 20px" v-if="pickImgList.length">
  27. <draggable v-model="pickImgList" v-if="pickImgList.length" flex="dif:left" style="display:flex;flex-wrap:wrap" @end="changeGoodsList">
  28. <div class="pickImgItem" v-for="(item,index) in pickImgList" :key="index" @mouseenter="mouseenter(index)" @mouseleave="mouseleave(index)">
  29. <el-image style="width: 50px; height: 50px" :src="item.params.img" fit="contain"></el-image>
  30. <div v-show="index == pickIndex || item.visible">
  31. <el-popover placement="bottom" v-model="item.visible">
  32. <p class="diy-del-text">确定删除吗?</p>
  33. <div flex="cross:center">
  34. <el-button class="diy-del-btn" size="mini" plain @click="delModel(index)">删除</el-button>
  35. <el-button size="mini" plain @click="item.visible = false">取消</el-button>
  36. </div>
  37. <i class="el-icon-close" slot="reference" style="color:#999;"></i>
  38. </el-popover>
  39. </div>
  40. </div>
  41. </draggable>
  42. </div>
  43. </div>
  44. <div class="pick-goods" v-if="chooseGoods == 2" style="padding: 10px;">
  45. <div class="icon-set-items" flex="cross:center">
  46. <div class="icon-set-list-name diy-text-font">链接</div>
  47. <div class="icon-set-list-content" flex="cross:center">
  48. <com-pick-link @selected="selectedUrl($event)" :pick-type="pickType" :auto-width="true" :default-tabs="[{name: 'marketing',children:['store-commodity-cate'] }]">
  49. <diy-url text=""></diy-url>
  50. </com-pick-link>
  51. </div>
  52. </div>
  53. <div class="icon-set-items" :key="index" v-for="(item,index) in selectUrlList">
  54. <diy-url :text="item.title+''" ></diy-url>
  55. <div class="icon-set-items-close">
  56. <el-popover placement="bottom" v-model="item.visible">
  57. <p class="diy-del-text">确定删除吗?</p>
  58. <div flex="cross:center">
  59. <el-button class="diy-del-btn" size="mini" plain @click="delClassifyUrl(index)">删除</el-button>
  60. <el-button size="mini" plain @click="item.visible = false">取消</el-button>
  61. </div>
  62. <i class="el-icon-close" slot="reference" style="color:#999;"></i>
  63. </el-popover>
  64. </div>
  65. </div>
  66. <diy-operation-list v-if="selectUrlList.length" v-model="showLineList" @on-change="onChange5"> </diy-operation-list>
  67. </div>
  68. </diy-style-contain>
  69. <diy-style-contain title="显示内容 (划线价和会员价同时选择时,优先显示会员价) " class="show-content fill-border-top">
  70. <el-checkbox-group v-model="contentCheckList" @change="onContentChange">
  71. <div v-for="(item,index) in showContentList" :key="index">
  72. <div flex="cross:center" class="flex-y-center" style="margin-bottom: 12px;">
  73. <el-checkbox :label="item.label">
  74. <span>{{item.name}}</span>
  75. </el-checkbox>
  76. <el-color-picker v-if="!item.disableColor" class="show-content-pick" color-format="colorFormat" :show-alpha="item.showAlpha" v-model="item.color" @change="onPickColor"></el-color-picker>
  77. <el-input v-if="!item.disableColor" v-model="item.color" @input="updateInput($event,item)" class="diy-text-btn"></el-input>
  78. </div>
  79. </div>
  80. </el-checkbox-group>
  81. </diy-style-contain>
  82. <diy-style-contain title="排序组显示" class="fill-border-top">
  83. <diy-operation-list v-model="sortSet" @on-change="changeSort"></diy-operation-list>
  84. </diy-style-contain>
  85. <diy-style-contain title="购物车按钮" class="show-content fill-border-top">
  86. <el-radio-group v-model="shoppingCart" @change="updateData($event,'showShopCart')">
  87. <el-radio :label="1">显示</el-radio>
  88. <el-radio :label="2">隐藏</el-radio>
  89. </el-radio-group>
  90. <div class="shopping-cart-func" v-show="shoppingCart == 1">
  91. <div class="shop-cart-row" flex="cross:center">
  92. <div class="leabl">样式</div>
  93. <diy-tab v-model="shopCartStyleList" :default-index="shopCartStyle" @change="onShopCartStyle">
  94. <template v-slot="{item, isSelect}">
  95. <div flex="cross:center" :class="{'shop-cart-col': true,'selected': isSelect}">
  96. <img :src="item.src" style="width: 32px;">
  97. </div>
  98. </template>
  99. </diy-tab>
  100. </div>
  101. <div class="shop-cart-row" flex="cross:center" v-if="shopCartStyle == 0">
  102. <div class="leabl">文字</div>
  103. <el-input style="flex: 1;" v-model="shopCartText" placeholder="请输入内容" maxlength="4" size="small" show-word-limit @input="updateShopCartText($event,'showShopCart')"></el-input>
  104. </div>
  105. <div class="shop-cart-row" flex="cross:center" v-if="shopCartStyle != 3">
  106. <div class="leabl">颜色</div>
  107. <div flex="cross:center">
  108. <el-color-picker class="show-content-pick" color-format="colorFormat" v-model="shopCartColor" @change="onShopCart($event,'color')"></el-color-picker>
  109. <el-input v-model="shopCartColor" maxlength="8" @input="onShopCart($event,'color')" class="diy-text-btn"></el-input>
  110. </div>
  111. </div>
  112. <div class="shop-cart-row" flex="cross:center" v-if="shopCartStyle == 0">
  113. <div class="leabl">圆角</div>
  114. <div flex="cross:center">
  115. <el-slider style="width: 165px;" :min="0" :max="20" v-model="shopCartRadius" @change="onShopCart($event,'borderReduis')"></el-slider>
  116. <div style="margin-left: 16px;" class="diy-text-btn">{{shopCartRadius}}px</div>
  117. </div>
  118. </div>
  119. <div class="shop-cart-row" flex="cross:center" v-if="shopCartStyle != 3">
  120. <div class="leabl">背景</div>
  121. <div flex="cross:center">
  122. <el-color-picker class="show-content-pick" color-format="colorFormat" v-model="shopCartBgColor" @change="onShopCart($event,'backgroundColor')"></el-color-picker>
  123. <el-input v-model="shopCartBgColor" maxlength="8" @input="onShopCart($event,'backgroundColor')" class="diy-text-btn"></el-input>
  124. </div>
  125. </div>
  126. <div class="shop-cart-row" flex="cross:center" v-if="shopCartStyle <= 1">
  127. <div class="leabl">边框</div>
  128. <div flex="cross:center">
  129. <el-color-picker class="show-content-pick" color-format="colorFormat" v-model="shopCartBorderColor" @change="onShopCart($event,'borderColor')"></el-color-picker>
  130. <el-input v-model="shopCartBorderColor" maxlength="8" @input="onShopCart($event,'borderColor')" class="diy-text-btn"></el-input>
  131. </div>
  132. </div>
  133. <div class="shop-cart-row" flex="cross:center">
  134. <div class="leabl">尺寸</div>
  135. <el-radio-group v-model="shopCartSize" @change="onShopCart($event,'sizeType')">
  136. <el-radio :label="item.label" v-for="(item,index) in shopCartSizeList" :key="index">{{item.value}}</el-radio>
  137. </el-radio-group>
  138. </div>
  139. </div>
  140. </diy-style-contain>
  141. <diy-style-contain title="点击购物车按钮" style="padding-top: 0;">
  142. <el-radio-group v-model="addShopCartBtn" @change="onAddShopCartBtn">
  143. <el-radio :label="item.label" v-for="(item,index) in addShopCartBtnList" :key="index">{{item.value}}</el-radio>
  144. </el-radio-group>
  145. </diy-style-contain>
  146. <diy-style-contain title="角标设置" class="fill-border-top">
  147. <el-radio-group v-model="angleMark" @change="onAngleMark">
  148. <el-radio :label="item.label" v-for="(item,index) in angleMarkList" :key="index">{{item.value}}</el-radio>
  149. </el-radio-group>
  150. <div class="shopping-cart-func" v-show="angleMark == 2">
  151. <div class="shop-cart-row" flex="cross:center">
  152. <div class="leabl">样式</div>
  153. <diy-tab v-model="angleMarkStyleList" :default-index="angleMarkStyleIndex" @change="onAngleMarkChange($event, 'angleMarkStyle')">
  154. <template v-slot="{item, isSelect}">
  155. <div flex="cross:center" :class="{'shop-cart-col': true,'selected': isSelect}">
  156. <img :src="item.src" style="width: 28px;">
  157. </div>
  158. </template>
  159. </diy-tab>
  160. </div>
  161. <div class="shop-cart-row" flex="cross:center">
  162. <div class="leabl">文字</div>
  163. <el-input style="flex: 1;" v-model="angleMarkText" placeholder="请输入内容" maxlength="2" size="small" show-word-limit @input="onAngleMarkChange($event, 'angleMarkText')"></el-input>
  164. </div>
  165. </div>
  166. <div class="shopping-cart-func" v-show="angleMark == 3">
  167. <diy-img-setting :img-infos="imageUrl" def-img-count="1" :show-url="false" :suggest-site="2" suggest-size-text="建议图片宽度76,高度76。" :img-contain-style="{padding: 0}" :show-title="false" @change="addIconImg"></diy-img-setting>
  168. </div>
  169. </diy-style-contain>
  170. <diy-color class="fill-border-top" :color-infos="defaultForm.colorInfos" :def-color="defaultForm.defColor" @chang="updateColor"></diy-color>
  171. <diy-size-setting class="fill-border-top" top-name="边距" :size-infos="defaultForm.sizeInfos" :max-value="50" @chang="sliderChange($event, 'margin')"></diy-size-setting>
  172. <diy-size-setting class="fill-border-top" top-name="圆角设置" :size-infos="defaultForm.radiusInfos" :max-value="20" @chang="RadiusChange($event, 'radius')"></diy-size-setting>
  173. </div>
  174. </template>
  175. <script>
  176. Vue.component('store-commodity-group-style', {
  177. name: "store-commodity-group-style",
  178. mixins: [basicMixins],
  179. template: '#store-commodity-group-style',
  180. props: {
  181. activeItem: {
  182. type: Object,
  183. default () {
  184. return {}
  185. }
  186. }
  187. },
  188. data() {
  189. return {
  190. showLineList: [{
  191. type: "size",
  192. label: "显示条数",
  193. value: 10,
  194. unit: "个",
  195. maxValue: 20
  196. }, ],
  197. picktUrlIndex: -1,
  198. selectUrlList: "",
  199. chooseGoods: 1,
  200. defaultSelectList: [],
  201. // 风格
  202. style: 1,
  203. styleList: [{
  204. label: 1,
  205. src: "resources/img/decorate/store-commodity-group/style1.png"
  206. }, {
  207. label: 2,
  208. src: "resources/img/decorate/store-commodity-group/style2.png"
  209. }, {
  210. label: 3,
  211. src: "resources/img/decorate/store-commodity-group/style3.png"
  212. }, {
  213. label: 4,
  214. src: "resources/img/decorate/store-commodity-group/style4.png"
  215. }, {
  216. label: 5,
  217. src: "resources/img/decorate/store-commodity-group/style5.png"
  218. }, {
  219. label: 6,
  220. src: "resources/img/decorate/store-commodity-group/style6.png"
  221. }, {
  222. label: 7,
  223. src: "resources/img/decorate/store-commodity-group/style7.png"
  224. }],
  225. // 选择商品
  226. pickType: ['store_goods','store-commodity-cate'],
  227. pickIndex: -1,
  228. pickImgList: [],
  229. // 显示内容
  230. contentCheckList: [],
  231. /**
  232. {
  233. label: 2,
  234. name: "副标题",
  235. color: "",
  236. showAlpha: false
  237. }
  238. */
  239. showContentList: [{
  240. label: 1,
  241. name: "商品标题",
  242. color: "",
  243. showAlpha: false,
  244. field: 'goods_name'
  245. }, {
  246. label: 3,
  247. name: "商品价格",
  248. color: "",
  249. showAlpha: false,
  250. field: 'price'
  251. }, {
  252. label: 4,
  253. name: "划线原价",
  254. color: "",
  255. showAlpha: false,
  256. field: 'original_price'
  257. }, {
  258. label: 5,
  259. name: "商品销量",
  260. color: "",
  261. showAlpha: false,
  262. field: 'sales_num'
  263. }, {
  264. label: 6,
  265. name: "门店距离",
  266. color: "#FF7300",
  267. field: 'store_distance'
  268. }, {
  269. label: 0,
  270. name: "会员价",
  271. disableColor: false,
  272. field: 'member_price'
  273. }],
  274. sortSet: [{
  275. type: "checkbox",
  276. label: "排序内容",
  277. value: [],
  278. list: [{
  279. label: 'distance',
  280. value: "距离"
  281. }, {
  282. label: 'price',
  283. value: "价格"
  284. }, {
  285. label: 'sales_num',
  286. value: "销量"
  287. }, {
  288. label: 'comment_num',
  289. value: "评价"
  290. }],
  291. setKey: "contentList1"
  292. }],
  293. // 购物车
  294. shoppingCart: 1,
  295. shopCartStyle: 0,
  296. shopCartStyleList: [{
  297. label: 1,
  298. src: "resources/img/decorate/store-commodity-group/car3.png"
  299. }, {
  300. label: 2,
  301. src: "resources/img/decorate/store-commodity-group/car1.png"
  302. }, {
  303. label: 3,
  304. src: "resources/img/decorate/store-commodity-group/car2.png"
  305. }, {
  306. label: 4,
  307. src: "resources/img/decorate/store-commodity-group/shopping_cart.png"
  308. }, ],
  309. angleMarkStyleIndex: -1,
  310. angleMarkStyleList: [{
  311. label: 1,
  312. src: "resources/img/decorate/store-commodity-group/hot-1.png"
  313. }, {
  314. label: 2,
  315. src: "resources/img/decorate/store-commodity-group/hot-2.png"
  316. }, {
  317. label: 3,
  318. src: "resources/img/decorate/store-commodity-group/hot-3.png"
  319. }, ],
  320. angleMarkText: "",
  321. shopCartText: "",
  322. shopCartRadius: -1,
  323. shopCartBgColor: "",
  324. shopCartColor: "",
  325. shopCartBorderColor: "",
  326. shopCartSize: 1,
  327. shopCartSizeList: [{
  328. label: 1,
  329. value: "小"
  330. }, {
  331. label: 2,
  332. value: "中"
  333. }, {
  334. label: 3,
  335. value: "大"
  336. }],
  337. addShopCartBtn: 1,
  338. addShopCartBtnList: [{
  339. label: 1,
  340. value: "进入商品详情页"
  341. }, {
  342. label: 2,
  343. value: "商品加购"
  344. }],
  345. angleMark: 1,
  346. angleMarkList: [{
  347. label: 1,
  348. value: "不显示"
  349. }, {
  350. label: 2,
  351. value: "系统图标"
  352. }, {
  353. label: 3,
  354. value: "自定义"
  355. }],
  356. imageUrl: [],
  357. addonsFields: [],
  358. isExec: 0,
  359. addonsKeyFields: [],
  360. }
  361. },
  362. computed: {
  363. defaultSelectListIds(newVal) {
  364. var arr = []
  365. if (newVal && newVal.length) {
  366. arr = newVal.map(item => {
  367. return item.params.id
  368. })
  369. }
  370. return arr
  371. },
  372. },
  373. created() {
  374. this.initData()
  375. },
  376. methods: {
  377. changeGoodsList(e) {
  378. this.updateData(this.pickImgList, "goods")
  379. },
  380. selectedUrl(value) {
  381. console.log('多选分类`````',value)
  382. this.selectUrlList = value.map(item=>item.params)
  383. this.showLineList[0].value = 10
  384. console.log('数据---`````',this.selectUrlList)
  385. this.updateData(10, 'cateNum')
  386. this.updateData(this.selectUrlList, 'commCate')
  387. },
  388. delClassifyUrl(index) {
  389. this.selectUrlList.splice(index, 1)
  390. // this.updateData(this.pickImgList, "goods") // 选中列表
  391. },
  392. onChange5([{
  393. value
  394. }]) {
  395. this.updateData(value, 'cateNum')
  396. },
  397. changeSort([{ value }]){
  398. this.updateData(value, "filterList") // 选中列表
  399. },
  400. async initData(){
  401. // await this.getAddonsFields()
  402. this.initPageData()
  403. },
  404. initPageData() {
  405. // 设置默认值
  406. basicMixins.methods.init.call(this); // 以前的数据调用一下
  407. console.log('内容',this.result)
  408. let arr10 = ['computedStyle', 'iptBg']
  409. var comBgColor = {
  410. name: '商品背景', //名字
  411. color: getObjValue(this.result, arr10, this.defaultForm.defColor), //颜色
  412. showAlpha: false, //是否开启透明度
  413. }
  414. // 更改mixins初始数据
  415. this.defaultForm.colorInfos.push(comBgColor)
  416. // ======================== 首次初始渲染
  417. //
  418. let count = 10
  419. let { commCate } = this.result.data
  420. if(commCate){
  421. if(Array.isArray(commCate)){
  422. this.selectUrlList = commCate
  423. count = getObjValue(this.result, ['data', 'cateNum'], 10)
  424. }else { //兼容原有逻辑
  425. count = getObjValue(this.result, ['data', 'commCate', 'count'], 10)
  426. this.selectUrlList = [commCate]
  427. }
  428. }
  429. this.showLineList = [{
  430. type: "size",
  431. label: "显示条数",
  432. value: count,
  433. unit: "个",
  434. maxValue: 20
  435. }]
  436. this.chooseGoods = this.result.data.chooseGoods || 1
  437. // 风格
  438. this.style = this.result.data.style || 1
  439. this.onStyleList(this.style) // 更新视图
  440. // 选择商品
  441. let arr = ['data', 'goods']
  442. this.pickImgList = getObjValue(this.result, arr, [])
  443. this.defaultSelectList = getObjValue(this.result, arr, []);
  444. // 显示内容
  445. let arr1 = ['data', 'showContent']
  446. let contentCheckList = getObjValue(this.result, arr1)
  447. if (contentCheckList && contentCheckList.length) {
  448. this.showContentList = this.showContentList.map((item) => {
  449. let item1 = contentCheckList.find(item1 => {
  450. return item.label == item1.label && item1.color
  451. })
  452. if (item1) {
  453. item.color = item1.color
  454. }
  455. return item
  456. })
  457. }
  458. this.contentCheckList = contentCheckList ? contentCheckList.map(item => (item.label)) : [1, 2, 3, 4, 5, 0]
  459. this.filterSelectContentList()
  460. // 排序组显示 sortSet
  461. let [{ value }] = this.sortSet
  462. let sortCheckList = value
  463. if(this.result.data && this.result.data.hasOwnProperty('filterList')){
  464. let sortArr = ['data', 'filterList']
  465. sortCheckList = getObjValue(this.result, sortArr)
  466. if(sortCheckList){
  467. console.log('选择的值',sortCheckList)
  468. this.sortSet[0].value = sortCheckList
  469. }
  470. }
  471. this.updateData(sortCheckList, "filterList") // 选中列表
  472. // 购物车
  473. this.shoppingCart = this.result.data.showShopCart || 1
  474. let arr2 = ['data', 'shopCartStyle']
  475. let arr3 = ['computedStyle', 'shopCartStyle']
  476. let shopCartData = getObjValue(this.result, arr2, {
  477. index: 0,
  478. text: "",
  479. })
  480. let shopCartStyle = getObjValue(this.result, arr3, {
  481. color: "",
  482. borderReduis: 0,
  483. backgroundColor: "",
  484. borderColor: "",
  485. sizeType: 1
  486. })
  487. this.shopCartStyle = shopCartData.index || 0
  488. this.onShopCartStyle({}, this.shopCartStyle)
  489. this.shopCartText = shopCartData.text || ""
  490. this.shopCartColor = shopCartStyle.color || ""
  491. this.shopCartRadius = shopCartStyle.borderReduis || 0
  492. this.shopCartBgColor = shopCartStyle.backgroundColor || ""
  493. this.shopCartBorderColor = shopCartStyle.borderColor || ""
  494. this.shopCartSize = shopCartStyle.sizeType || 1
  495. // 购物车跳转
  496. let clickShopCartObJ = this.result.data.clickShopCartType
  497. this.addShopCartBtn = clickShopCartObJ ? clickShopCartObJ.label : 1
  498. // 角标
  499. let arr4 = ['data', 'angleMark']
  500. let angleMark = getObjValue(this.result, arr4, {})
  501. this.angleMark = angleMark.label || 1
  502. this.angleMarkText = angleMark.angleMarkText || ""
  503. if (angleMark.customImgUrl) {
  504. this.imageUrl.push({
  505. imgUrl: angleMark.customImgUrl
  506. })
  507. }
  508. let arr5 = ['data', 'angleMark', 'angleMarkStyle']
  509. let angleMarkStyle = getObjValue(this.result, arr5, {
  510. label: 0,
  511. src: "resources/img/decorate/store-commodity-group/hot-2.png"
  512. })
  513. this.angleMarkStyleIndex = angleMarkStyle.label-1
  514. // 尺寸
  515. let siazArr = ['computedStyle', 'searchIpts', 'marginBottom']
  516. let siazArr1 = ['computedStyle', 'searchIpts', 'marginLeft']
  517. let siazArr2 = ['computedStyle', 'searchIpts', 'marginTop']
  518. var marginArr = [{
  519. name: '上边距', //名字
  520. value: parseFloat(getObjValue(this.result, siazArr2, 10)), //值
  521. unit: "px", //单位
  522. disabled: false, //是否禁用
  523. maxValue: 50,
  524. }, {
  525. name: '下边距', //名字
  526. value: parseFloat(getObjValue(this.result, siazArr, 10)), //值
  527. unit: "px", //单位
  528. disabled: false, //是否禁用
  529. maxValue: 50,
  530. }, {
  531. name: '左右边距', //名字
  532. value: parseFloat(getObjValue(this.result, siazArr1, 10)), //值
  533. unit: "px", //单位
  534. disabled: false, //是否禁用
  535. maxValue: 20,
  536. }]
  537. this.defaultForm.sizeInfos = marginArr
  538. this.sliderChange(marginArr, 'margin')
  539. this.setDefaultSelectIds();
  540. },
  541. getContentItem(label) {
  542. return this.showContentList.find(item => {
  543. return item && (item.label === label)
  544. }) || {}
  545. },
  546. onStyleList($event) {
  547. // 更改操作
  548. if ($event == 1 || $event == 2) {
  549. let showContentList = [{
  550. label: 1,
  551. name: "商品标题",
  552. color: this.getContentItem(1).color,
  553. showAlpha: false,
  554. field: 'goods_name'
  555. }, {
  556. label: 2,
  557. name: "副标题",
  558. color: this.getContentItem(2).color,
  559. showAlpha: false,
  560. field: 'subtitle'
  561. }, {
  562. label: 3,
  563. name: "商品价格",
  564. color: this.getContentItem(3).color,
  565. showAlpha: false,
  566. field: 'price'
  567. }, {
  568. label: 4,
  569. name: "划线原价",
  570. color: this.getContentItem(4).color,
  571. showAlpha: false,
  572. field: 'original_price'
  573. }, {
  574. label: 5,
  575. name: "商品销量",
  576. color: this.getContentItem(5).color,
  577. showAlpha: false,
  578. field: 'sales_num'
  579. }, {
  580. label: 6,
  581. name: "门店距离",
  582. color: "#FF7300",
  583. field: 'store_distance'
  584. }, {
  585. label: 0,
  586. name: "会员价",
  587. disableColor: false,
  588. field: 'member_price'
  589. }];
  590. for (let i = 0; i < this.addonsFields.length; i++) {
  591. this.addonsFields[i].color = this.getContentItem(this.addonsFields[i].label).color;
  592. showContentList.push(this.addonsFields[i]);
  593. }
  594. this.showContentList = showContentList;
  595. } else if ($event == 3) {
  596. let = showContentList = [{
  597. label: 1,
  598. name: "商品标题",
  599. color: this.getContentItem(1).color,
  600. showAlpha: false,
  601. field: 'goods_name'
  602. }, {
  603. label: 3,
  604. name: "商品价格",
  605. color: this.getContentItem(3).color,
  606. showAlpha: false,
  607. field: 'price'
  608. }, {
  609. label: 4,
  610. name: "划线原价",
  611. color: this.getContentItem(4).color,
  612. showAlpha: false,
  613. field: 'original_price'
  614. }, {
  615. label: 5,
  616. name: "商品销量",
  617. color: this.getContentItem(5).color,
  618. showAlpha: false,
  619. field: 'sales_num'
  620. }, {
  621. label: 6,
  622. name: "门店距离",
  623. color: this.getContentItem(6).color,
  624. disableColor: false,
  625. field: 'store_distance'
  626. }, {
  627. label: 0,
  628. name: "会员价",
  629. disableColor: false,
  630. field: 'member_price'
  631. }]
  632. // let _this = this;
  633. // this.addonsFields.forEach(function(value, index, arr) {
  634. // value['color'] = _this.getContentItem(value.label).color;
  635. // showContentList.push(value);
  636. // })
  637. this.showContentList = showContentList;
  638. } else {
  639. this.showContentList = [{
  640. label: 1,
  641. name: "商品标题",
  642. color: this.getContentItem(1).color,
  643. showAlpha: false,
  644. field: 'goods_name'
  645. }, {
  646. label: 3,
  647. name: "商品价格",
  648. color: this.getContentItem(3).color,
  649. showAlpha: false,
  650. field: 'price'
  651. }, {
  652. label: 6,
  653. name: "门店距离",
  654. color: this.getContentItem(6).color,
  655. disableColor: false,
  656. field: 'store_distance'
  657. } ]
  658. }
  659. this.updateData($event, 'style')
  660. },
  661. onAngleMark(e) {
  662. var item = this.angleMarkList.find(it => {
  663. return it.label == e
  664. })
  665. this.updateData(item, "angleMark")
  666. },
  667. onAngleMarkChange(e, type) {
  668. this.updateData({
  669. [type]: e
  670. }, "angleMark")
  671. },
  672. // 图片
  673. addIconImg(arr) {
  674. this.imageUrl = arr
  675. this.updateData({
  676. customImgUrl: arr[0].imgUrl
  677. }, "angleMark")
  678. },
  679. onAddShopCartBtn(e) {
  680. var item = this.addShopCartBtnList.find(it => {
  681. return it.label == e
  682. })
  683. this.updateData(item, "clickShopCartType")
  684. },
  685. updateShopCartText(text) {
  686. this.updateData({
  687. text
  688. }, "shopCartStyle")
  689. },
  690. onShopCartStyle(e, index) {
  691. this.shopCartStyle = index
  692. this.updateData(Object.assign({
  693. index
  694. }, e), "shopCartStyle")
  695. },
  696. onShopCart(e, type) {
  697. this.updateStyle({
  698. [type]: e
  699. }, "shopCartStyle")
  700. },
  701. updateInput(val, item) {
  702. if (val.length == 0) {
  703. val = "transparent";
  704. }
  705. item.color = val
  706. // 更新
  707. },
  708. onContentChange() {
  709. this.filterSelectContentList()
  710. },
  711. onPickColor() {
  712. // 更新
  713. this.filterSelectContentList()
  714. },
  715. filterSelectContentList() {
  716. var result = this.showContentList.filter(item => {
  717. return this.contentCheckList.indexOf(item.label) !== -1
  718. })
  719. this.updateData(result, "showContent") // 选中列表
  720. },
  721. mouseenter(index) {
  722. this.pickIndex = index
  723. },
  724. mouseleave() {
  725. this.pickIndex = -1
  726. },
  727. delModel(index) {
  728. this.pickImgList.splice(index, 1)
  729. this.defaultSelectList.splice(index, 1);
  730. this.updateData(this.pickImgList, "goods") // 选中列表
  731. },
  732. selectNavUrl(e) {
  733. let tempList =[...this.pickImgList,...e]
  734. this.pickImgList = tempList.filter((item, index, self) => {
  735. return self.findIndex(t => t.params.id === item.params.id) === index;
  736. });
  737. console.log('this.pickImgList',this.pickImgList);
  738. this.updateData(this.pickImgList, "goods") // 选中列表
  739. this.setDefaultSelectIds();
  740. },
  741. setDefaultSelectIds() {
  742. let pickData = this.pickImgList;
  743. let selectIds = [];
  744. pickData.forEach(item => {
  745. selectIds.push(item.params.id);
  746. })
  747. this.defaultSelectList = selectIds.filter((item, index, selectIds) => selectIds.indexOf(item) === index);
  748. },
  749. updateColor(e) { // 选择颜色
  750. this.result.computedStyle.searchBox = e[0].color
  751. this.result.computedStyle.iptBg = e[1].color
  752. this.$emit("update", this.result)
  753. },
  754. upImgIndex(index, item) {
  755. this.imgIndex = index;
  756. this.result.data.titleStyle = item;
  757. this.$emit("update", this.result);
  758. },
  759. isObject(d) {
  760. if (!d) {
  761. return false
  762. }
  763. return Object.prototype.toString.call(d) === "[object Object]"
  764. },
  765. // 更新数据
  766. updateData(value, key) {
  767. if (this.isObject(this.result.data[key])) { // 对象格式
  768. var oldData = deepClone(this.result.data[key])
  769. this.result.data[key] = Object.assign(oldData, {
  770. ...value
  771. });
  772. } else { // 基础类型、数组
  773. this.result.data[key] = value;
  774. }
  775. console.log("gggggvvv",this.result)
  776. this.$emit("update", this.result);
  777. },
  778. updateStyle(value, key) {
  779. if (this.isObject(this.result.computedStyle[key])) { // 对象格式
  780. var oldData = deepClone(this.result.computedStyle[key])
  781. this.result.computedStyle[key] = Object.assign(oldData, {
  782. ...value
  783. });
  784. } else { // 基础类型、数组
  785. this.result.computedStyle[key] = value;
  786. }
  787. this.$emit("update", this.result);
  788. },
  789. // getAddonsFields: function() {
  790. // if (this.isExec > 0) {
  791. // return
  792. // }
  793. // return new Promise((resolve, reject) => {
  794. // resolve(request({
  795. // params: {
  796. // r: 'mall/diy/get-addons-fields',
  797. // type: 'home_page'
  798. // },
  799. // method: 'get',
  800. // }).then(e => {
  801. // if (e.data.code === 0) {
  802. // if (e.data.data.length > 0 && this.isExec == 0) {
  803. // let self = this;
  804. // e.data.data.forEach(function(value, index, arr) {
  805. // value.showAlpha = value.showAlpha ? true : false;
  806. // self.addonsFields.push(value);
  807. // self.addonsKeyFields.push(value['field']);
  808. // })
  809. // self.addonsFields.forEach(function(value, index, arr) {
  810. // self.showContentList.push(value);
  811. // self.contentCheckList.push(value);
  812. // })
  813. // }
  814. // }
  815. // this.isExec = 1;
  816. // }).catch(e => {
  817. // console.log(e);
  818. // reject()
  819. // }));
  820. // });
  821. // }
  822. }
  823. });
  824. </script>
  825. <style>
  826. .pickImgItem {
  827. position: relative;
  828. width: 50px;
  829. height: 50px;
  830. margin: 0 9px 9px 0;
  831. background-color: #ddd;
  832. }
  833. .pickImgItem .el-icon-close {
  834. position: absolute;
  835. top: 0;
  836. right: 0;
  837. font-size: 12px;
  838. }
  839. .add-goods-btn {
  840. border: 1px dashed #6b7685;
  841. line-height: 32px;
  842. height: 32px;
  843. border-radius: 4px;
  844. text-align: center;
  845. cursor: pointer;
  846. }
  847. .pick-goods {
  848. background: #f4f3f7;
  849. border-radius: 4px;
  850. padding: 20px;
  851. }
  852. .tip {
  853. position: absolute;
  854. top: 21px;
  855. left: 88px;
  856. font-size: 12px;
  857. color: rgb(153, 153, 153);
  858. }
  859. .show-content-pick {
  860. margin: 0 10px 0 12px;
  861. }
  862. .shoppingCartFunc {
  863. background: #f4f3f7;
  864. border-radius: 4px;
  865. padding: 20px;
  866. margin-top: 20px;
  867. }
  868. .shopping-cart-func {
  869. margin-top: 20px;
  870. }
  871. .shop-cart-row .leabl {
  872. width: 70px;
  873. text-align: center;
  874. }
  875. .shop-cart-col {
  876. width: 36px;
  877. height: 36px;
  878. box-sizing: border-box;
  879. justify-content: center;
  880. border-radius: 4px;
  881. margin-right: 20px;
  882. }
  883. .selected {
  884. border: 1px solid var(--diy-theme);
  885. }
  886. /* 清理组件默认样式 */
  887. .clear-diy-style .el-radio-button__inner {
  888. background-color: transparent;
  889. padding: 0;
  890. }
  891. .shop-cart-row .el-radio-group {
  892. display: flex;
  893. align-items: center;
  894. }
  895. .shop-cart-row .el-radio-button__inner {
  896. display: flex;
  897. width: 42px;
  898. height: 42px;
  899. align-items: center;
  900. justify-content: center;
  901. background-color: transparent;
  902. padding: 0;
  903. }
  904. .shop-cart-row {
  905. margin-bottom: 20px;
  906. }
  907. .clear-diy-style .com-pick-link-content {
  908. width: 100%;
  909. }
  910. .store-commodity-group-style .show-content .el-color-picker {
  911. height: 30px;
  912. }
  913. .store-commodity-group-style .show-content .el-checkbox {
  914. width: 100px;
  915. }
  916. /* 修改element基础样式 */
  917. .store-commodity-group-style .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  918. background-color: transparent;
  919. }
  920. .store-commodity-group-style {
  921. .icon-set-items {
  922. position: relative;
  923. .icon-set-items-close {
  924. position: absolute;
  925. right: 10px;
  926. top: 10px;
  927. }
  928. }
  929. }
  930. </style>