quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
  <!--
        作者:wangxw
        时间:2019-05-05
        描述:分类模板
    -->
  <div class="d-s-s">
    <!--分类不同样式展示-->
    <div class="model-container">
      <div class="img-box">
        <el-image v-if="formData.category_style==10" :src="category_10" fit="fill"></el-image>
        <el-image v-if="formData.category_style==20" :src="category_20" fit="fill"></el-image>
        <el-image v-if="formData.category_style==30" :src="category_30" fit="fill"></el-image>
        <el-image v-if="formData.category_style==40" :src="category_40" fit="fill"></el-image>
      </div>
    </div>
    <!--图片展示参数-->
    <div class="param-container flex-1">
      <div class="common-form"><span>展示设置</span></div>
      <el-form size="small" :model="formData" label-width="100px">
        <el-form-item label="分类页样式:">
          <el-radio-group v-model="formData.category_style">
            <el-radio :label="10">一级分类(大图)</el-radio>
            <el-radio :label="20">一级分类(小图)</el-radio>
            <el-radio :label="40">一级分类(列表)</el-radio>
            <el-radio :label="30">二级分类</el-radio>
          </el-radio-group>
          <p class="gray9">建议:一级分类(大图)尺寸建议710*300,其它均为等比图片即可,如:240*240</p>
        </el-form-item>
        <el-form-item label="分享标题:"><el-input v-model="formData.share_title"></el-input></el-form-item>
      </el-form>
    </div>
 
    <!--提交-->
    <div class="common-button-wrapper"><el-button size="small" type="primary" @click="Submit()">保存</el-button></div>
  </div>
</template>
 
<script>
  import PageApi from '@/api/page.js';
  import category_10 from '@/assets/img/category_10.jpg';
  import category_20 from '@/assets/img/category_20.jpg';
  import category_30 from '@/assets/img/category_30.jpg';
  import category_40 from '@/assets/img/category_40.jpg';
export default {
  data() {
    return {
      /*表单数据对象*/
      formData: {
        category_style: null
      },
      /*展示样式*/
      category_10:category_10,
      category_20:category_20,
      category_30:category_30,
      category_40:category_40,
    };
  },
  created() {
 
    this.getData();
 
  },
  methods: {
 
    /*获取数据*/
    getData() {
      let self = this;
      PageApi.getCategory({}, true).then(res => {
        self.formData=res.data.model;
      }).catch(error => {
        self.loading = false;
      });
    },
 
    /*提交*/
    Submit() {
      let self = this;
      self.loading = true;
      let Params = self.formData;
      PageApi.postCategory(Params,true)
        .then(data => {
          self.loading = false;
          self.$message({
            message: '恭喜你,修改成功',
            type: 'success'
          });
          self.getData();
        })
        .catch(error => {
          self.loading = false;
        });
    }
  }
};
</script>
 
<style scoped="scoped">
.model-container {
  width: 300px;
  height: calc(100vh - 150px);
  margin-right: 30px;
}
.model-container img{width: 100%;}
.model-container .img-box{ box-shadow: 0 0 16px 0 rgba(0,0,0,.1);}
.param-container {
  padding: 20px;
  height: calc(100vh - 150px);
  border: 1px solid #cccccc;
}
</style>