style.php 36 KB

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