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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<template>
  <div>
    <div class="product-content">
      <el-form size="small" ref="form" :model="form" label-width="150px">
        <!--基础设置-->
        <Basic :form="form"></Basic>
 
        <!--时间设置-->
        <Datetime :form="form"></Datetime>
 
        <!--其它-->
        <Other :form="form"></Other>
      </el-form>
    </div>
 
    <!--提交-->
    <div class="common-button-wrapper">
      <el-button size="small" @click="cancelFunc">取消</el-button>
      <el-button size="small" type="primary" @click="onSubmit" :disabled="loading">提交</el-button>
    </div>
  </div>
</template>
 
<script>
import PlusApi from '@/api/plus/groupbuy'
import Basic from './part/Basic.vue';
import Datetime from './part/Datetime.vue';
import Other from './part/Other.vue';
 
export default {
  components: {
    /*基础设置*/
    Basic,
    /*时间设置*/
    Datetime,
    /*其它*/
    Other
  },
  data() {
    return {
      form: {
        /*活动名称*/
        active_name: '',
        /*广告图片ID*/
        image_id: 0,
        /*活动广告图*/
        file_path:'',
        /*活动描述*/
        description: '',
        /*活动时间*/
        start_time: '',
        end_time: '',
        /*是否生效,默认1为生效,0为不生效*/
        status: 1,
        /*团购失败处理方式:0失败退款1自动团购成功*/
        fail_type: 0,
        /*默认排序*/
        sort: 100,
        /*凑团时间*/
        together_time: 24,
        file: {
          file_path:'',
          file_id:0
        }
      },
      /*判断是否正在加载*/
      loading: false,
    };
  },
  created() {},
  methods: {
 
    /*提交表单*/
    onSubmit() {
      let self = this;
      if(self.form.end_time == null || self.form.end_time == ''){
        self.$message({
          message: '请填写活动结束时间',
          type: 'error'
        });
        return;
      }
      self.$refs.form.validate(valid => {
        if (valid) {
          let params = self.form;
          self.loading = true;
          PlusApi.addActive(params, true)
            .then(data => {
              self.loading = false;
              self.$message({
                message: '恭喜你,添加成功',
                type: 'success'
              });
              self.$router.push('/plus/groupbuy/active/index');
            })
            .catch(error => {
              self.loading = false;
            });
        }
      });
    },
 
    /*取消*/
    cancelFunc() {
      this.$router.back(-1);
    }
  }
};
</script>
 
<style scoped>
.product-add {
  padding: 20px;
  background: #fff;
}
.tips {
  color: #999;
  font-size: 12px;
  margin-top: 5px;
}
.ad-picture {
  width: 300px;
  height: 124px;
  border-radius: 16px;
  border: 1px dashed #cccccc;
  color: #409eff;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-picture:hover {
  border: 1px dashed #409eff;
}
.ad-picture img {
  object-fit: fill;
  width: 100%;
  height: 100%;
}
.gray {
  color: #999;
  font-size: 12px;
}
.ml10 {
  margin-left: 10px;
}
</style>