style.php 37 KB

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