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
149
150
| <template>
| <div v-if="templateShow">
| <Form :model="form" :label-width="120">
| <FormItem label="每日场次设置">
| <Row :gutter="16" class="row">
| <Col class="time-item" @click.native="handleClickTime(item,index)" v-for="(item,index) in this.times" :key="index" span="3">
| <div class="time" :class="{'active':item.check}">{{item.time}}:00</div>
| </Col>
| </Row>
| </FormItem>
| <FormItem label="秒杀规则">
| <Input type="textarea" :autosize="{minRows: 4,}" v-model="form.seckillRule" placeholder="申请规则" clearable style="width: 360px; margin-left:10px" />
| </FormItem>
| <FormItem>
| <div class="foot-btn">
| <Button @click="closeCurrentPage" style="margin-right: 5px">返回</Button>
| <Button type="primary" :loading="submitLoading" @click="handleSubmit">提交</Button>
| </div>
| </FormItem>
| </Form>
| </div>
| </template>
|
| <script>
| import { getSetting, setSetting } from "@/api/index";
| export default {
| data() {
| return {
| templateShow:false, // 设置是否显示
| submitLoading: false,
| times: [], //时间集合 1-24点
| form: {
| seckillRule: "",
| },
| };
| },
| mounted() {
| /**
| * 初始化
| */
| this.init();
| },
| methods: {
| /**
| * 关闭当前页面
| */
| closeCurrentPage() {
| this.$store.commit("removeTag", "manager-seckill-add");
| localStorage.pageOpenedList = JSON.stringify(
| this.$store.state.app.pageOpenedList
| );
| this.$router.go(-1);
| },
| /**
| * 提交秒杀信息
| */
| async handleSubmit() {
| let hours = this.times
| .filter((item) => {
| return item.check;
| })
| .map((item) => {
| return item.time;
| })
| .join(",");
|
| let result = await setSetting("SECKILL_SETTING", {
| seckillRule: this.form.seckillRule,
| hours,
| });
| if (result.success) {
| this.$Message.success("设置成功!");
| this.init();
| }
| },
|
| /**
| * 初始化当前信息
| */
| async init() {
| let result = await getSetting("SECKILL_SETTING");
| if (result.success) {
| this.templateShow = true
| this.form.seckillRule = result.result.seckillRule;
| this.times=[]
| for (let i = 0; i < 24; i++) {
| // 将数据拆出
| if (result.result.hours) {
| let way = result.result.hours.split(",");
| way.forEach((hours) => {
| if (hours == i) {
| this.times.push({
| time: i,
| check: true,
| });
| }
| });
| }
| if (!this.times[i]) {
| this.times.push({
| time: i,
| check: false,
| });
| }
| }
| }
| },
| /**
| * 选中时间
| */
| handleClickTime(val, index) {
| val.check = !val.check;
| },
| },
| };
| </script>
|
| <style scoped lang="scss">
| .row {
| width: 50%;
| }
| .foot-btn {
| margin-left: 10px;
| }
| .time-list {
| display: flex;
| flex-wrap: wrap;
| }
| .active {
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
| color: #fff;
| background: $theme_color !important;
| }
| .time {
| width: 100%;
| cursor: pointer;
| transition: 0.35s;
| border-radius: 0.8em;
| justify-content: center;
| align-items: center;
| display: flex;
| background: #f3f5f7;
| height: 100%;
| }
| .time-item {
| height: 50px;
| margin: 8px 0;
| font-size: 15px;
| }
| </style>
|
|