cat-style.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <?php
  2. $mchId = Yii::$app->user->identity->mch_id;
  3. ?>
  4. <style>
  5. .cat-style .table-body {
  6. padding: 0;
  7. background-color: #fff;
  8. }
  9. .cat-style .el-card__body {
  10. padding: 0;
  11. }
  12. .cat-style .cat-style .text {
  13. cursor: pointer;
  14. background: #409eff;
  15. width: 90px;
  16. color: #fff;
  17. }
  18. .new-table-body {
  19. padding: 20px;
  20. background-color: #fff;
  21. margin-bottom: 0;
  22. }
  23. .cat-style .cat-style-model {
  24. background-color: rgba(0, 0, 0, 0.5);
  25. position: absolute;
  26. top: 0;
  27. left: 0;
  28. height: 100%;
  29. width: 100%;
  30. -webkit-border-radius: 25px;
  31. -moz-border-radius: 25px;
  32. border-radius: 25px;
  33. }
  34. .cat-style .cat-style-nmodel {
  35. background-color: transparent;
  36. }
  37. .cat-style .button-item {
  38. padding: 9px 25px;
  39. margin-top: 20px;
  40. }
  41. .cat-style .image-box {
  42. width: 340px;
  43. border: 1px solid #f2f4f5;
  44. cursor: pointer;
  45. border-radius: 25px;
  46. margin-right: 5px;
  47. padding: 30px 0;
  48. position: relative;
  49. }
  50. .cat-style .image-box .active {
  51. position: absolute;
  52. top: 0;
  53. left: 0;
  54. z-index: 99;
  55. }
  56. .cat-style .image-box .text {
  57. cursor: pointer;
  58. background: #409eff;
  59. text-align: center;
  60. position: absolute;
  61. top: 245px;
  62. left: auto;
  63. line-height: 30px;
  64. width: 90px;
  65. color: #fff;
  66. }
  67. .cat-style .tab-box {
  68. margin-bottom: 20px;
  69. }
  70. .cat-style .tab-box .btn {
  71. cursor: pointer;
  72. padding: 7px 15px;
  73. margin-right: 10px;
  74. border: 1px solid #E3E3E3;
  75. -webkit-border-radius: 4px;
  76. -moz-border-radius: 4px;
  77. border-radius: 4px;
  78. }
  79. .cat-style .tab-box .active {
  80. background: #409eff;
  81. color: #FFFFFF;
  82. }
  83. .cats-third-style {
  84. margin-left: 10px;
  85. width: 300px;
  86. }
  87. .cats-third-style .el-color-picker__trigger {
  88. height: 28px;
  89. width: 60px;
  90. }
  91. .cats-third-style .el-input__inner {
  92. height: 28px;
  93. line-height: 28px;
  94. width: 96px;
  95. border: none;
  96. background-color: #EBEEF5;
  97. }
  98. .cats-third-style .el-slider {
  99. width: 60px;
  100. }
  101. .m-left-12 {
  102. margin-left: 12px;
  103. }
  104. .label-style {
  105. display: inline-block;
  106. height: 28px;
  107. line-height: 28px;
  108. width: 90px;
  109. }
  110. </style>
  111. <template id="cat-style">
  112. <div class="cat-style">
  113. <el-card v-loading="listLoading" shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 0 0;">
  114. <el-form :model="form" :rules="rules" ref="form" label-width="200px" size="small">
  115. <el-card shadow="never" style="border:0;">
  116. <el-row class="table-body">
  117. <!--
  118. <div class="tab-box" flex="dir:left">
  119. <div :class="{'active': activeName == 'one' ? true : false}" class="btn" @click="handleClick('one')">一级分类样式
  120. </div>
  121. <div :class="{'active': activeName == 'two' ? true : false}" class="btn" @click="handleClick('two')">二级分类样式
  122. </div>
  123. <div :class="{'active': activeName == 'three' ? true : false}" class="btn" @click="handleClick('three')">三级分类样式
  124. </div>
  125. </div>
  126. -->
  127. <div v-if="activeName == 'one'">
  128. <div flex="dir:left">
  129. <div v-for="item in catList[0]" @mouseenter="enter(item.value)" @mouseleave="leave(item.value)">
  130. <div class="image-box" flex="main:center" :style="{'border': item.value == form.cat_style ? '1px solid #409eff' : '1px solid #F2F4F5'}">
  131. <div>
  132. <div :class="item.value == selectModel ? 'cat-style-model': 'cat-style-nmodel'"></div>
  133. <img :src="item.pic_url">
  134. </div>
  135. <com-image class="active" v-if="item.value == form.cat_style" width="80px" height="80px" :src="cat_select">
  136. </com-image>
  137. <div v-if="item.value == selectModel" @click="setStyle(item.value)" class="text">
  138. 启用该样式
  139. </div>
  140. </div>
  141. </div>
  142. <div class="cats-third-style" v-if="this.form.cat_style == 3">
  143. <div flex>
  144. <span class="label-style">一级背景颜色</span>
  145. <div class="m-left-12"><el-color-picker v-model="form.cats_third_style.aLevelBgColor"></el-color-picker></div>
  146. <div class="m-left-12"><el-input v-model="form.cats_third_style.aLevelBgColor" /></div>
  147. </div>
  148. <div flex>
  149. <span class="label-style">二级背景颜色</span>
  150. <div class="m-left-12"><el-color-picker v-model="form.cats_third_style.bLevelBgColor"></el-color-picker></div>
  151. <div class="m-left-12"><el-input v-model="form.cats_third_style.bLevelBgColor" /></div>
  152. </div>
  153. <div flex>
  154. <span class="label-style">三级背景颜色</span>
  155. <div class="m-left-12"><el-color-picker v-model="form.cats_third_style.cLevelBgColor"></el-color-picker></div>
  156. <div class="m-left-12"><el-input v-model="form.cats_third_style.cLevelBgColor" /></div>
  157. </div>
  158. <div flex>
  159. <span class="label-style">一级字体颜色</span>
  160. <div class="m-left-12"><el-color-picker v-model="form.cats_third_style.fontColor"></el-color-picker></div>
  161. <div class="m-left-12"><el-input v-model="form.cats_third_style.fontColor" /></div>
  162. </div>
  163. <div flex>
  164. <span class="label-style">二级字体颜色</span>
  165. <div class="m-left-12"><el-color-picker v-model="form.cats_third_style.bFontColor"></el-color-picker></div>
  166. <div class="m-left-12"><el-input v-model="form.cats_third_style.bFontColor" /></div>
  167. </div>
  168. <div flex>
  169. <span class="label-style">三级字体颜色</span>
  170. <div class="m-left-12"><el-color-picker v-model="form.cats_third_style.cFontColor"></el-color-picker></div>
  171. <div class="m-left-12"><el-input v-model="form.cats_third_style.cFontColor" /></div>
  172. </div>
  173. <div flex>
  174. <span class="label-style">字体大小</span>
  175. <div class="m-left-12">
  176. <el-slider :min="14" :max="18" v-model="form.cats_third_style.fontSize"></el-slider>
  177. </div>
  178. <div class="m-left-12"><el-input v-model="form.cats_third_style.fontSize"></div>
  179. </div>
  180. <div flex>
  181. <span class="label-style">字体粗细</span>
  182. <div class="m-left-12" style="display: flex;align-items:center;padding-top:4px;">
  183. <el-radio-group v-model="form.cats_third_style.fontWeight">
  184. <el-radio label="lighter">细</el-radio>
  185. <el-radio label="normal">中</el-radio>
  186. <el-radio label="bold">粗</el-radio>
  187. </el-radio-group>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <!--
  194. <div v-if="activeName == 'two'">
  195. <div flex="dir:left">
  196. <div v-for="item in catList[1]" flex="main:center" @mouseenter="enter(item.value)" @mouseleave="leave(item.value)">
  197. <div class="image-box" flex="main:center" :style="{'border': item.value == form.cat_style ? '1px solid #409eff' : '1px solid #F2F4F5'}">
  198. <div>
  199. <div :class="item.value == selectModel ? 'cat-style-model': 'cat-style-nmodel'"></div>
  200. <img :src="item.pic_url">
  201. </div>
  202. <com-image class="active" v-if="item.value == form.cat_style" width="80px" height="80px" :src="cat_select">
  203. </com-image>
  204. <div v-if="item.value == selectModel" @click="setStyle(item.value)" class="text">
  205. 启用该样式
  206. </div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. <div v-if="activeName == 'three'">
  212. <div flex="dir:left">
  213. <div v-for="item in catList[2]" flex="main:center" @mouseenter="enter(item.value)" @mouseleave="leave(item.value)">
  214. <div class="image-box" flex="main:center" :style="{'border': item.value == form.cat_style ? '1px solid #409eff' : '1px solid #F2F4F5'}">
  215. <div>
  216. <div :class="item.value == selectModel ? 'cat-style-model': 'cat-style-nmodel'"></div>
  217. <img :src="item.pic_url">
  218. </div>
  219. <com-image class="active" v-if="item.value == form.cat_style" width="80px" height="80px" :src="cat_select">
  220. </com-image>
  221. <div v-if="item.value == selectModel" @click="setStyle(item.value)" class="text">
  222. 启用该样式
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. -->
  229. </el-row>
  230. </el-card>
  231. <el-card shadow="never" style="border:0;">
  232. <!--
  233. <template>
  234. <div slot="header">
  235. <span>显示设置</span>
  236. </div>
  237. <el-row class="new-table-body">
  238. <el-form-item label="" prop="cat_goods_count">
  239. <template slot='label'>
  240. <span>每个分类商品显示总数</span>
  241. <el-tooltip effect="dark" content="每个分类板块显示的商品最大数(0~100)" placement="top">
  242. <i class="el-icon-info"></i>
  243. </el-tooltip>
  244. </template>
  245. <el-input v-model="form.cat_goods_count" style="width:30%" type="number">
  246. <template slot="append">个</template>
  247. </el-input>
  248. </el-form-item>
  249. <el-form-item prop="cat_goods_cols">
  250. <template slot='label'>
  251. <span>商品每行显示数量</span>
  252. <el-tooltip effect="dark" content="默认首页显示" placement="top">
  253. <i class="el-icon-info"></i>
  254. </el-tooltip>
  255. </template>
  256. <el-select v-model="form.cat_goods_cols" placeholder="请选择">
  257. <el-option v-for="item in catGoodsCols" :key="item.value" :label="item.label" :value="item.value">
  258. </el-option>
  259. </el-select>
  260. </el-form-item>
  261. </el-row>
  262. </template>
  263. -->
  264. <el-button class="button-item" :loading="btnLoading" size="small" type="primary" @click="onSubmit">
  265. 保存
  266. </el-button>
  267. </el-card>
  268. </el-form>
  269. </el-card>
  270. </div>
  271. </template>
  272. <script>
  273. Vue.component('cat-style', {
  274. template: '#cat-style',
  275. data() {
  276. return {
  277. catList: [
  278. [{
  279. value: 1,
  280. pic_url: '/resources/img/mall/cat/style-1.png'
  281. },
  282. // {
  283. // value: 2,
  284. // pic_url: '/resources/img/mall/cat/style-2.png'
  285. // },
  286. {
  287. value: 3,
  288. pic_url: '/resources/img/mall/cat/style-3.png'
  289. },
  290. {
  291. value: 4,
  292. pic_url: '/resources/img/mall/cat/style-4.png'
  293. }
  294. ],
  295. [{
  296. value: 2,
  297. pic_url: '/resources/img/mall/cat/two-c.png'
  298. }],
  299. [{
  300. value: 3,
  301. pic_url: '/resources/img/mall/cat/three-b.png'
  302. }],
  303. ],
  304. mchCatList: [
  305. [{
  306. value: 3,
  307. pic_url: '/resources/img/mall/cat/mch-one-a.png'
  308. },
  309. {
  310. value: 1,
  311. pic_url: '/resources/img/mall/cat/mch-one-b.png',
  312. },
  313. ],
  314. [{
  315. value: 2,
  316. pic_url: '/resources/img/mall/cat/mch-two-a.png',
  317. },
  318. {
  319. value: 4,
  320. pic_url: '/resources/img/mall/cat/mch-two-c.png',
  321. }
  322. ],
  323. [{
  324. value: 6,
  325. pic_url: '/resources/img/mall/cat/mch-three-a.png',
  326. },
  327. {
  328. value: 7,
  329. pic_url: '/resources/img/mall/cat/mch-three-b.png',
  330. },
  331. ],
  332. ],
  333. cat_select: '/resources/img/mall/cat/select.png',
  334. selectModel: 0,
  335. catGoodsCols: [{
  336. label: '1',
  337. value: 1
  338. },
  339. {
  340. label: '2',
  341. value: 2
  342. },
  343. {
  344. label: '3',
  345. value: 3
  346. },
  347. ],
  348. form: {
  349. cat_style: 1,
  350. cats_third_style: {
  351. aLevelBgColor: '#fff',
  352. bLevelBgColor: '#fff',
  353. cLevelBgColor: '#fff',
  354. fontColor: '#000',
  355. bFontColor: '#000',
  356. cFontColor: '#000',
  357. fontSize: 14,
  358. fontWeight: 'normal'
  359. },
  360. },
  361. btnLoading: false,
  362. listLoading: false,
  363. activeName: 'one',
  364. selectSet: 0,
  365. rules: {
  366. cat_goods_count: [{
  367. required: true,
  368. message: '每个分类商品显示总数不能为空',
  369. trigger: 'change'
  370. }, ],
  371. cat_goods_cols: [{
  372. required: true,
  373. message: '商品每行显示数量不能为空',
  374. trigger: 'change'
  375. }, ]
  376. },
  377. is_mch: <?= $mchId > 0 ? 1 : 0 ?>,
  378. }
  379. },
  380. methods: {
  381. //样式切换
  382. setStyle(value) {
  383. this.form.cat_style = value;
  384. this.selectModel = 0;
  385. },
  386. enter(value) {
  387. if (this.form.cat_style == value) {
  388. return;
  389. }
  390. this.selectModel = value;
  391. },
  392. leave(value) {
  393. if (this.form.cat_style == value) {
  394. return;
  395. }
  396. if (this.selectModel == value) {}
  397. },
  398. handleClick(name) {
  399. this.activeName = name;
  400. },
  401. onSubmit() {
  402. this.$refs.form.validate((valid) => {
  403. if (valid) {
  404. this.btnLoading = true;
  405. let para = Object.assign({}, this.form);
  406. request({
  407. params: {
  408. r: 'mall/cate/style'
  409. },
  410. data: para,
  411. method: 'post'
  412. }).then(e => {
  413. if (e.data.code === 0) {
  414. this.$message.success(e.data.msg);
  415. // navigateTo({r: 'mall/cat/index'});
  416. } else {
  417. this.$message.error(e.data.msg);
  418. }
  419. this.btnLoading = false;
  420. }).catch(e => {
  421. this.btnLoading = false;
  422. });
  423. }
  424. });
  425. },
  426. //获取列表
  427. getList() {
  428. this.listLoading = true;
  429. request({
  430. params: {
  431. r: 'mall/cate/style'
  432. },
  433. }).then(e => {
  434. if (e.data.code == 0) {
  435. if (e.data.data) {
  436. let cats_third_style = this.form.cats_third_style
  437. // this.form = e.data.data.setting;
  438. Object.assign(this.form, e.data.data.setting)
  439. for (let i in cats_third_style) {
  440. if (!this.form.cats_third_style[i]) {
  441. this.form.cats_third_style[i] = cats_third_style[i]
  442. }
  443. }
  444. }
  445. // let catStyle = this.form.cat_style;
  446. // if (catStyle == 2 || catStyle == 4 || catStyle == 5) {
  447. // this.activeName = 'two'
  448. // } else if (catStyle == 6 || catStyle == 7) {
  449. // this.activeName = 'three'
  450. // }
  451. }
  452. this.listLoading = false;
  453. }).catch(e => {
  454. this.listLoading = false;
  455. });
  456. },
  457. },
  458. mounted() {
  459. this.getList();
  460. if (this.is_mch) {
  461. this.catList = this.mchCatList;
  462. }
  463. }
  464. })
  465. </script>