cat-style.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. </style>
  84. <template id="cat-style">
  85. <div class="cat-style">
  86. <el-card v-loading="listLoading" shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 0 0;">
  87. <el-form :model="form" :rules="rules" ref="form" label-width="200px" size="small">
  88. <el-card shadow="never" style="border:0;">
  89. <el-row class="table-body">
  90. <div class="tab-box" flex="dir:left">
  91. <div :class="{'active': activeName == 'one' ? true : false}" class="btn" @click="handleClick('one')">一级分类样式
  92. </div>
  93. <div :class="{'active': activeName == 'two' ? true : false}" class="btn" @click="handleClick('two')">二级分类样式
  94. </div>
  95. <div :class="{'active': activeName == 'three' ? true : false}" class="btn" @click="handleClick('three')">三级分类样式
  96. </div>
  97. </div>
  98. <div v-if="activeName == 'one'">
  99. <div flex="dir:left">
  100. <div v-for="item in catList[0]" @mouseenter="enter(item.value)" @mouseleave="leave(item.value)">
  101. <div class="image-box" flex="main:center" :style="{'border': item.value == form.cat_style ? '1px solid #409eff' : '1px solid #F2F4F5'}">
  102. <div>
  103. <div :class="item.value == selectModel ? 'cat-style-model': 'cat-style-nmodel'"></div>
  104. <img :src="item.pic_url">
  105. </div>
  106. <com-image class="active" v-if="item.value == form.cat_style" width="80px" height="80px" :src="cat_select">
  107. </com-image>
  108. <div v-if="item.value == selectModel" @click="setStyle(item.value)" class="text">
  109. 启用该样式
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <div v-if="activeName == 'two'">
  116. <div flex="dir:left">
  117. <div v-for="item in catList[1]" flex="main:center" @mouseenter="enter(item.value)" @mouseleave="leave(item.value)">
  118. <div class="image-box" flex="main:center" :style="{'border': item.value == form.cat_style ? '1px solid #409eff' : '1px solid #F2F4F5'}">
  119. <div>
  120. <div :class="item.value == selectModel ? 'cat-style-model': 'cat-style-nmodel'"></div>
  121. <img :src="item.pic_url">
  122. </div>
  123. <com-image class="active" v-if="item.value == form.cat_style" width="80px" height="80px" :src="cat_select">
  124. </com-image>
  125. <div v-if="item.value == selectModel" @click="setStyle(item.value)" class="text">
  126. 启用该样式
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div v-if="activeName == 'three'">
  133. <div flex="dir:left">
  134. <div v-for="item in catList[2]" flex="main:center" @mouseenter="enter(item.value)" @mouseleave="leave(item.value)">
  135. <div class="image-box" flex="main:center" :style="{'border': item.value == form.cat_style ? '1px solid #409eff' : '1px solid #F2F4F5'}">
  136. <div>
  137. <div :class="item.value == selectModel ? 'cat-style-model': 'cat-style-nmodel'"></div>
  138. <img :src="item.pic_url">
  139. </div>
  140. <com-image class="active" v-if="item.value == form.cat_style" width="80px" height="80px" :src="cat_select">
  141. </com-image>
  142. <div v-if="item.value == selectModel" @click="setStyle(item.value)" class="text">
  143. 启用该样式
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </el-row>
  150. </el-card>
  151. <!-- <el-card shadow="never" style="border:0;">
  152. <template>
  153. <div slot="header">
  154. <span>显示设置</span>
  155. </div>
  156. <el-row class="new-table-body">
  157. <el-form-item label="" prop="cat_goods_count">
  158. <template slot='label'>
  159. <span>每个分类商品显示总数</span>
  160. <el-tooltip effect="dark" content="每个分类板块显示的商品最大数(0~100)" placement="top">
  161. <i class="el-icon-info"></i>
  162. </el-tooltip>
  163. </template>
  164. <el-input v-model="form.cat_goods_count" style="width:30%" type="number">
  165. <template slot="append">个</template>
  166. </el-input>
  167. </el-form-item>
  168. <el-form-item prop="cat_goods_cols">
  169. <template slot='label'>
  170. <span>商品每行显示数量</span>
  171. <el-tooltip effect="dark" content="默认首页显示" placement="top">
  172. <i class="el-icon-info"></i>
  173. </el-tooltip>
  174. </template>
  175. <el-select v-model="form.cat_goods_cols" placeholder="请选择">
  176. <el-option v-for="item in catGoodsCols" :key="item.value" :label="item.label" :value="item.value">
  177. </el-option>
  178. </el-select>
  179. </el-form-item>
  180. </el-row>
  181. </template>
  182. <el-button class="button-item" :loading="btnLoading" size="small" type="primary" @click="onSubmit">
  183. 保存
  184. </el-button>
  185. </el-card> -->
  186. </el-form>
  187. </el-card>
  188. </div>
  189. </template>
  190. <script>
  191. Vue.component('cat-style', {
  192. template: '#cat-style',
  193. data() {
  194. return {
  195. catList: [
  196. [{
  197. value: 1,
  198. pic_url: '/resources/img/mall/cat/one-d.png'
  199. }],
  200. [{
  201. value: 2,
  202. pic_url: '/resources/img/mall/cat/two-c.png'
  203. }],
  204. [{
  205. value: 3,
  206. pic_url: '/resources/img/mall/cat/three-b.png'
  207. }],
  208. ],
  209. mchCatList: [
  210. [{
  211. value: 3,
  212. pic_url: '/resources/img/mall/cat/mch-one-a.png'
  213. },
  214. {
  215. value: 1,
  216. pic_url: '/resources/img/mall/cat/mch-one-b.png',
  217. },
  218. ],
  219. [{
  220. value: 2,
  221. pic_url: '/resources/img/mall/cat/mch-two-a.png',
  222. },
  223. {
  224. value: 4,
  225. pic_url: '/resources/img/mall/cat/mch-two-c.png',
  226. }
  227. ],
  228. [{
  229. value: 6,
  230. pic_url: '/resources/img/mall/cat/mch-three-a.png',
  231. },
  232. {
  233. value: 7,
  234. pic_url: '/resources/img/mall/cat/mch-three-b.png',
  235. },
  236. ],
  237. ],
  238. cat_select: '/resources/img/mall/cat/select.png',
  239. selectModel: 0,
  240. catGoodsCols: [{
  241. label: '1',
  242. value: 1
  243. },
  244. {
  245. label: '2',
  246. value: 2
  247. },
  248. {
  249. label: '3',
  250. value: 3
  251. },
  252. ],
  253. form: {},
  254. btnLoading: false,
  255. listLoading: false,
  256. activeName: 'one',
  257. selectSet: 0,
  258. rules: {
  259. cat_goods_count: [{
  260. required: true,
  261. message: '每个分类商品显示总数不能为空',
  262. trigger: 'change'
  263. }, ],
  264. cat_goods_cols: [{
  265. required: true,
  266. message: '商品每行显示数量不能为空',
  267. trigger: 'change'
  268. }, ]
  269. },
  270. is_mch: <?= $mchId > 0 ? 1 : 0 ?>,
  271. }
  272. },
  273. methods: {
  274. //样式切换
  275. setStyle(value) {
  276. this.form.cat_style = value;
  277. this.selectModel = 0;
  278. },
  279. enter(value) {
  280. if (this.form.cat_style == value) {
  281. return;
  282. }
  283. this.selectModel = value;
  284. },
  285. leave(value) {
  286. if (this.form.cat_style == value) {
  287. return;
  288. }
  289. if (this.selectModel == value) {}
  290. },
  291. handleClick(name) {
  292. this.activeName = name;
  293. },
  294. onSubmit() {
  295. this.$refs.form.validate((valid) => {
  296. if (valid) {
  297. this.btnLoading = true;
  298. let para = Object.assign({}, this.form);
  299. request({
  300. params: {
  301. r: 'mall/cate/style'
  302. },
  303. data: para,
  304. method: 'post'
  305. }).then(e => {
  306. if (e.data.code === 0) {
  307. this.$message.success(e.data.msg);
  308. // navigateTo({r: 'mall/cat/index'});
  309. } else {
  310. this.$message.error(e.data.msg);
  311. }
  312. this.btnLoading = false;
  313. }).catch(e => {
  314. this.btnLoading = false;
  315. });
  316. }
  317. });
  318. },
  319. //获取列表
  320. getList() {
  321. this.listLoading = true;
  322. request({
  323. params: {
  324. r: 'mall/cate/style'
  325. },
  326. }).then(e => {
  327. if (e.data.code == 0) {
  328. if (e.data.data) {
  329. this.form = e.data.data.setting;
  330. }
  331. let catStyle = this.form.cat_style;
  332. if (catStyle == 2 || catStyle == 4 || catStyle == 5) {
  333. this.activeName = 'two'
  334. } else if (catStyle == 6 || catStyle == 7) {
  335. this.activeName = 'three'
  336. }
  337. }
  338. this.listLoading = false;
  339. }).catch(e => {
  340. this.listLoading = false;
  341. });
  342. },
  343. },
  344. mounted() {
  345. this.getList();
  346. if (this.is_mch) {
  347. this.catList = this.mchCatList;
  348. }
  349. }
  350. })
  351. </script>