createBigWheelActive.vue 27.3 KB
Newer Older
xd's avatar
xd committed
1 2
<template>
  <div class="container">
leiqingsong's avatar
leiqingsong committed
3
    <div class="title">活动设置</div>
xd's avatar
xd committed
4
    <van-cell-group class="all">
leiqingsong's avatar
leiqingsong committed
5
      <van-cell :required="true" title="活动标题" style="font-size:14px;">
xd's avatar
xd committed
6 7 8 9 10 11 12 13 14
        <template slot="default">
          <van-field
            v-model="basicInfo.title"
            placeholder="请输入活动标题"
            class="right"
            style="font-size:14px;"
          />
        </template>
      </van-cell>
leiqingsong's avatar
leiqingsong committed
15
      <van-cell :required="true" title="活动开始时间" style="font-size:14px;">
xd's avatar
xd committed
16
        <template slot="default">
xd's avatar
xd committed
17 18 19 20
          <div class="nobr">
            <van-field
              class="right"
              v-model="basicInfo.startTime1"
xd's avatar
xd committed
21
              placeholder="请选择开始时间"
xd's avatar
xd committed
22 23
              readonly="readonly"
              @click="basicInfo.startShow = true"
xd's avatar
xd committed
24
            />
25
            <van-popup v-model="basicInfo.startShow" position="bottom" :overlay="true">
xd's avatar
xd committed
26 27
              <van-datetime-picker
                v-model="basicInfo.startTime"
leiqingsong's avatar
leiqingsong committed
28
                type="datetime"
29
                :min-date="minStartDate"
xd's avatar
xd committed
30
                @cancel="basicInfo.startShow = false"
xd's avatar
xd committed
31
                @confirm="handleBasicSTime"
xd's avatar
xd committed
32 33 34 35
                @change="startTimeChange"
              />
            </van-popup>
          </div>
xd's avatar
xd committed
36 37
        </template>
      </van-cell>
leiqingsong's avatar
leiqingsong committed
38
      <van-cell :required="true" title="活动结束时间" style="font-size:14px;">
xd's avatar
xd committed
39
        <template slot="default">
xd's avatar
xd committed
40 41 42 43
          <div class="jpsl">
            <van-field
              class="right"
              v-model="basicInfo.endTime1"
xd's avatar
xd committed
44
              placeholder="请选择结束时间"
xd's avatar
xd committed
45 46
              readonly="readonly"
              @click="basicInfo.endShow = true"
xd's avatar
xd committed
47
            />
48
            <van-popup v-model="basicInfo.endShow" position="bottom" :overlay="true">
xd's avatar
xd committed
49 50
              <van-datetime-picker
                v-model="basicInfo.endTime"
leiqingsong's avatar
leiqingsong committed
51
                type="datetime"
52
                :min-date="minEndDate"
xd's avatar
xd committed
53
                @cancel="basicInfo.endShow = false"
xd's avatar
xd committed
54
                @confirm="handleBasicETime"
xd's avatar
xd committed
55 56 57 58
                @change="endTimeChange"
              />
            </van-popup>
          </div>
xd's avatar
xd committed
59 60
        </template>
      </van-cell>
leiqingsong's avatar
leiqingsong committed
61 62
      <van-cell title="背景图片" style="font-size: 14px">
        <van-uploader v-model="bg_imgs" :max-count="1" :after-read="afterBGRead" />
xd's avatar
xd committed
63
      </van-cell>
leiqingsong's avatar
leiqingsong committed
64
      <van-cell :required="true" title="活动Logo" style="font-size: 14px">
leiqingsong's avatar
leiqingsong committed
65
        <van-uploader :max-count="1" v-model="logo_imgs" :after-read="afterLogoRead"></van-uploader>
xd's avatar
xd committed
66
      </van-cell>
leiqingsong's avatar
leiqingsong committed
67
      <van-cell :required="true" title="会员单日参与次数" style="font-size: 14px">
xd's avatar
xd committed
68
        <template slot="default">
69 70 71 72 73
          <div class="jpsl">
            <van-field
              class="right noborder"
              readonly
              clickable
leiqingsong's avatar
leiqingsong committed
74 75 76
              :value="basicInfo.jointimes"
              placeholder="请输入限制次数"
              @touchstart.native.stop="basicInfo.jointimes_show = true"
77 78
            />
            <van-number-keyboard
leiqingsong's avatar
leiqingsong committed
79 80 81 82
              v-model="basicInfo.jointimes"
              :show="basicInfo.jointimes_show"
              :maxlength="6"
              @blur="basicInfo.jointimes_show = false"
83 84
            />
          </div>
xd's avatar
xd committed
85 86
        </template>
      </van-cell>
leiqingsong's avatar
leiqingsong committed
87
      <van-cell :required="true" title="会员总参与次数" style="font-size: 14px">
xd's avatar
xd committed
88
        <template slot="default">
xd's avatar
xd committed
89
          <div class="jpsl">
90 91 92 93
            <van-field
              class="right noborder"
              readonly
              clickable
leiqingsong's avatar
leiqingsong committed
94 95 96
              :value="basicInfo.total_join"
              placeholder="请输入限制次数"
              @touchstart.native.stop="basicInfo.total_join_show = true"
97 98
            />
            <van-number-keyboard
leiqingsong's avatar
leiqingsong committed
99 100 101 102
              v-model="basicInfo.total_join"
              :show="basicInfo.total_join_show"
              :maxlength="6"
              @blur="basicInfo.total_join_show = false"
103 104
            />
          </div>
xd's avatar
xd committed
105 106 107 108
        </template>
      </van-cell>
    </van-cell-group>
    <div class="title">奖品设置</div>
109
    <van-cell-group class="all sz" v-for="(list, index) in prizeList" :key="index">
110 111 112 113 114 115 116
      <van-icon
        v-if="prizeList.length > 1"
        name="close"
        size="20"
        class="close"
        @click="removePrice(index)"
      />
leiqingsong's avatar
leiqingsong committed
117
      <van-cell :required="true" title="奖项设置">
leiqingsong's avatar
leiqingsong committed
118 119 120 121
        <van-radio-group v-model="prizeList[index].type" class="right">
          <van-radio name="1" style="float:left;margin-right:10px;">优惠券</van-radio>
          <van-radio name="2" style="float:right;">谢谢参与</van-radio>
        </van-radio-group>
xd's avatar
xd committed
122
      </van-cell>
leiqingsong's avatar
leiqingsong committed
123
      <template v-if="prizeList[index].type == 1">
leiqingsong's avatar
leiqingsong committed
124
        <van-cell :required="true" center>
leiqingsong's avatar
leiqingsong committed
125 126 127 128 129 130 131
          <template slot="title">
            <span class="custom-title">奖项名称</span>
          </template>
          <template slot="default">
            <van-field class="right" v-model="prizeList[index].name" placeholder="请输入奖项名称" />
          </template>
        </van-cell>
132
        <van-cell
leiqingsong's avatar
leiqingsong committed
133
          :required="true"
134 135 136 137 138 139
          title="选择优惠券"
          :value="prizeList[index].checked_coupon.name"
          is-link
          @click="handleCheckCoupon(index)"
          center
        />
leiqingsong's avatar
leiqingsong committed
140
        <van-cell :required="true" title="总发放数量限制" style="font-size:14px;">
leiqingsong's avatar
leiqingsong committed
141 142 143 144 145 146
          <template slot="default">
            <div class="jpsl">
              <van-field
                class="right noborder"
                readonly
                clickable
147
                :value="prizeList[index].total_limit"
leiqingsong's avatar
leiqingsong committed
148
                placeholder="请输入限制次数"
149
                @touchstart.native.stop="prizeList[index].total_limit_show = true"
leiqingsong's avatar
leiqingsong committed
150 151
              />
              <van-number-keyboard
152 153
                v-model="prizeList[index].total_limit"
                :show="prizeList[index].total_limit_show"
leiqingsong's avatar
leiqingsong committed
154
                :maxlength="6"
155
                @blur="prizeList[index].total_limit_show = false"
leiqingsong's avatar
leiqingsong committed
156
              />
xd's avatar
xd committed
157
            </div>
leiqingsong's avatar
leiqingsong committed
158 159
          </template>
        </van-cell>
leiqingsong's avatar
leiqingsong committed
160
        <van-cell :required="true" title="每日发放数量限制" style="font-size:14px;">
161 162 163
          <template slot="default">
            <div class="jpsl">
              <van-field
leiqingsong's avatar
leiqingsong committed
164 165 166
                class="right noborder"
                readonly
                clickable
167
                :value="prizeList[index].preLimit"
leiqingsong's avatar
leiqingsong committed
168
                placeholder="请输入限制次数"
169
                @touchstart.native.stop="prizeList[index].preLimit_show = true"
leiqingsong's avatar
leiqingsong committed
170 171
              />
              <van-number-keyboard
172 173
                v-model="prizeList[index].preLimit"
                :show="prizeList[index].preLimit_show"
leiqingsong's avatar
leiqingsong committed
174
                :maxlength="6"
175
                @blur="prizeList[index].preLimit_show = false"
xd's avatar
xd committed
176
              />
177 178
            </div>
          </template>
179
        </van-cell>
leiqingsong's avatar
leiqingsong committed
180
        <van-cell :required="true" title="每人限领数量" style="font-size:14px;">
181 182 183
          <template slot="default">
            <div class="jpsl">
              <van-field
leiqingsong's avatar
leiqingsong committed
184 185 186
                class="right noborder"
                readonly
                clickable
187
                :value="prizeList[index].limit"
leiqingsong's avatar
leiqingsong committed
188
                placeholder="请输入限制数量"
189
                @touchstart.native.stop="prizeList[index].limit_show = true"
leiqingsong's avatar
leiqingsong committed
190 191
              />
              <van-number-keyboard
192 193
                v-model="prizeList[index].limit"
                :show="prizeList[index].limit_show"
leiqingsong's avatar
leiqingsong committed
194
                :maxlength="6"
195
                @blur="prizeList[index].limit_show = false"
xd's avatar
xd committed
196
              />
197 198 199 200
            </div>
          </template>
        </van-cell>
      </template>
leiqingsong's avatar
leiqingsong committed
201
      <van-cell :required="true" style="font-size:14px;" class="cs gl">
leiqingsong's avatar
leiqingsong committed
202 203 204
        <template slot="title">
          <span class="custom-title">中奖概率</span>
        </template>
xd's avatar
xd committed
205
        <template slot="default">
206 207 208 209 210
          <div class="jpsl">
            <van-field
              class="right noborder"
              readonly
              clickable
leiqingsong's avatar
leiqingsong committed
211 212
              :value="prizeList[index].probability"
              @touchstart.native.stop="prizeList[index].probability_show = true"
213
            />
leiqingsong's avatar
leiqingsong committed
214
            <span class="bfb">%</span>
215
            <van-number-keyboard
leiqingsong's avatar
leiqingsong committed
216 217 218
              v-model="prizeList[index].probability"
              :show="prizeList[index].probability_show"
              @blur="prizeList[index].probability_show = false"
219 220
            />
          </div>
xd's avatar
xd committed
221 222
        </template>
      </van-cell>
xd's avatar
xd committed
223
      <div class="add" @click="addPrice">添加奖项</div>
xd's avatar
xd committed
224
    </van-cell-group>
leiqingsong's avatar
leiqingsong committed
225
    <!-- 活动描述 -->
leiqingsong's avatar
leiqingsong committed
226
    <van-cell :required="true" class="detail">
xd's avatar
xd committed
227 228 229 230 231 232 233 234 235 236 237 238
      <div class="border">
        <div class="des">活动描述</div>
        <van-field
          class="area"
          v-model="message"
          rows="2"
          autosize
          type="textarea"
          placeholder="请输入描述"
          show-word-limit
        />
      </div>
leiqingsong's avatar
leiqingsong committed
239
    </van-cell>
leiqingsong's avatar
leiqingsong committed
240
    <!-- 活动图片 -->
xd's avatar
xd committed
241 242
    <div class="detail" style="margin-top:0;">
      <div class="des">活动图片</div>
243
      <van-uploader v-model="fileList_show" multiple :max-count="9" :after-read="afterImgRead" />
xd's avatar
xd committed
244
    </div>
leiqingsong's avatar
leiqingsong committed
245
    <!-- 奖品介绍 -->
leiqingsong's avatar
leiqingsong committed
246
    <van-cell :required="true" class="detail">
leiqingsong's avatar
leiqingsong committed
247 248 249 250 251 252 253 254 255 256 257 258
      <div class="border">
        <div class="des">奖品介绍</div>
        <van-field
          class="area"
          v-model="prize_produce"
          rows="2"
          autosize
          type="textarea"
          placeholder="请输入描述"
          show-word-limit
        />
      </div>
leiqingsong's avatar
leiqingsong committed
259
    </van-cell>
260
    <div class="creat" @click="handleCreate">创建活动</div>
leiqingsong's avatar
leiqingsong committed
261

262
    <van-action-sheet v-model="show" :actions="coupons" cancel-text="取消" @select="onSelect" />
xd's avatar
xd committed
263 264 265 266
  </div>
</template>

<script>
leiqingsong's avatar
leiqingsong committed
267
import axios from "axios";
268
import * as API_Active from "@/api/active";
leiqingsong's avatar
leiqingsong committed
269
import { Toast } from "vant";
xd's avatar
xd committed
270 271 272
export default {
  data() {
    return {
273 274
      minStaetDate: null,
      minEndDate: null,
275 276
      // 选择优惠券 当前下标
      current_index: -1,
leiqingsong's avatar
leiqingsong committed
277 278 279
      logo_imgs: [],
      bg_imgs: [],
      show: false,
280
      coupons: [],
xd's avatar
xd committed
281
      basicInfo: {
282
        title: "",
xd's avatar
xd committed
283
        startTime: new Date(),
284
        startTime1: "",
xd's avatar
xd committed
285
        endTime: new Date(),
286
        endTime1: "",
xd's avatar
xd committed
287
        startShow: false,
leiqingsong's avatar
leiqingsong committed
288
        endShow: false,
289
        jointimes: "",
leiqingsong's avatar
leiqingsong committed
290
        jointimes_show: false,
291
        total_join: "",
leiqingsong's avatar
leiqingsong committed
292
        total_join_show: false
xd's avatar
xd committed
293
      },
294
      // 抽奖设置
xd's avatar
xd committed
295
      LuckyDraw: {
xd's avatar
xd committed
296
        name: "",
leiqingsong's avatar
leiqingsong committed
297 298 299 300
        number: "1",
        winningNumber: "1",
        quantity: true,
        addNumber: "1",
xd's avatar
xd committed
301 302
        show: false,
        show2: false,
303 304
        show3: false,
        show4: false
xd's avatar
xd committed
305
      },
306
      // 奖品设置
xd's avatar
xd committed
307 308
      prizeList: [
        {
309 310 311 312
          name: "",
          timeLine_type: "",
          type: "",
          discountsMoney: "",
xd's avatar
xd committed
313 314 315 316 317
          discountsShow: false,
          full: "",
          fullMoney: "",
          fullShow: false,
          validity: "",
xd's avatar
xd committed
318
          startTime: new Date(),
319
          startTime1: "",
xd's avatar
xd committed
320
          startShow: false,
xd's avatar
xd committed
321
          endTime: new Date(),
322
          endTime1: "",
xd's avatar
xd committed
323
          endShow: false,
324 325 326 327 328 329 330 331 332
          total_limit: "",
          total_limit_show: false,
          preLimit: "",
          preLimit_show: false,
          limit: "",
          limit_show: false,
          probability: "",
          probability_show: false,
          checked_coupon: {}
xd's avatar
xd committed
333 334
        }
      ],
xd's avatar
xd committed
335 336 337 338
      title: "",
      title2: "",
      coupon: "",
      newCustomer: "",
leiqingsong's avatar
leiqingsong committed
339
      condition: "1",
xd's avatar
xd committed
340 341 342
      type: "",
      startShow: false,
      endShow: false,
343
      // 活动描述
344
      message: "",
345
      // 活动图片
346
      fileList_show: [],
xd's avatar
xd committed
347
      fileList: [],
348
      prize_produce: "",
xd's avatar
xd committed
349 350
      pTime: new Date(),
      confirmTime: new Date()
xd's avatar
xd committed
351 352
    };
  },
353
  created() {
354 355
    this.minStartDate = new Date();
    this.minEndDate = new Date();
356
  },
xd's avatar
xd committed
357
  methods: {
leiqingsong's avatar
leiqingsong committed
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
    // 获取模板数据
    getTemplateDate(id) {
      API_Active.getTemplateData(id).then(res => {
        // 构造数据
        // res.activityInfo
        this.basicInfo.title = res.data.activityInfo.activityName;
        let start_time = res.data.activityInfo.startTime;
        this.basicInfo.startTime1 =
          `${start_time.substring(0, 4)}-${start_time.substring(
            4,
            6
          )}-${start_time.substring(6, 8)}` + start_time.substring(8);
        let end_time = res.data.activityInfo.endTime;
        this.basicInfo.endTime1 =
          `${end_time.substring(0, 4)}-${end_time.substring(
            4,
            6
          )}-${end_time.substring(6, 8)}` + end_time.substring(8);
        this.bg_imgs[0] = { url: res.data.activityInfo.backImage };
        this.logo_imgs[0] = { url: res.data.activityInfo.logo };
leiqingsong's avatar
leiqingsong committed
378 379
        this.basicInfo.jointimes = res.data.activityInfo.joinLimit?.toString();
        this.basicInfo.total_join = res.data.activityInfo.totalLimit?.toString();
leiqingsong's avatar
leiqingsong committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
        this.message = res.data.activityInfo.des;
        let imgs = JSON.parse(res.data.activityInfo.image);
        let img_list = [];
        imgs.forEach(i => {
          let item = {};
          item.url = i;
          img_list.push(item);
        });
        this.fileList = img_list;
        this.prize_produce = res.data.activityInfo.prizeDesc;
        // this.prizeList = res.data.activityPrizes;
        let prizes = [];
        res.data.activityPrizes.forEach((p, index) => {
          let item = {
            name: "",
            timeLine_type: "",
            type: "",
            discountsMoney: "",
            discountsShow: false,
            full: "",
            fullMoney: "",
            fullShow: false,
            validity: "",
            startTime: new Date(),
            startTime1: "",
            startShow: false,
            endTime: new Date(),
            endTime1: "",
            endShow: false,
            total_limit: "",
            total_limit_show: false,
            preLimit: "",
            preLimit_show: false,
            limit: "",
            limit_show: false,
            probability: "",
            probability_show: false,
            checked_coupon: {}
          };
          if (p.prizeType === 2) {
            item.type = "1";
          } else if (p.prizeType === 1) {
            item.type = "2";
          }
          item.name = p.prizeName;
          item.id = index;
          item.total_limit = p.quantity?.toString();
          item.limit = p.personLimit?.toString();
          item.probability = p.probability?.toString();
          item.preLimit = p.limitReceive?.toString();
430
          this.checked_coupon = JSON.parse(p.coupon);
leiqingsong's avatar
leiqingsong committed
431 432 433 434 435
          prizes.push(item);
        });
        this.prizeList = prizes;
      });
    },
436 437 438 439 440 441 442 443
    handleCheckCoupon(index) {
      this.show = true;
      this.current_index = index;
    },
    onSelect(val) {
      this.prizeList[this.current_index].checked_coupon = val;
      this.show = false;
    },
leiqingsong's avatar
leiqingsong committed
444 445 446 447 448 449
    getCoupons() {
      let id = sessionStorage.getItem("oyStallCode") || 1;
      API_Active.getAllCouponsByOyStallCode(id).then(res => {
        this.coupons = res.data;
      });
    },
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
    afterImgRead(file) {
      if (file.length) {
        // let imgs = [];
        file.forEach(e => {
          let params = new FormData();
          params.append("file", e.file);
          let url = "http://139.155.48.151:8084/admin/auth/util/saveImg";
          axios.post(url, params).then(res => {
            let img_url = JSON.parse(JSON.stringify(res.data.data.imgPath));
            // imgs.push(img_url);
            this.fileList.push(img_url);
          });
        });
      } else {
        let params = new FormData();
        params.append("file", file.file);
        let url = "http://139.155.48.151:8084/admin/auth/util/saveImg";
        axios.post(url, params).then(res => {
          this.fileList.push(JSON.parse(JSON.stringify(res.data.data.imgPath)));
        });
      }
      console.log(this.fileList);
    },
leiqingsong's avatar
leiqingsong committed
473 474
    async afterLogoRead(file) {
      let logo_img = await this.getImgUrl(file.file);
475 476 477 478 479 480
      let item = {
        url: logo_img,
        status: "done",
        message: "上传成功"
      };
      this.logo_imgs[0] = item;
leiqingsong's avatar
leiqingsong committed
481 482 483
    },
    async afterBGRead(file) {
      let bg_img = await this.getImgUrl(file.file);
484 485 486 487 488 489
      let item = {
        url: bg_img,
        status: "done",
        message: "上传成功"
      };
      this.bg_imgs[0] = item;
leiqingsong's avatar
leiqingsong committed
490 491 492 493 494 495
    },
    // 上传图片
    async getImgUrl(file) {
      let params = new FormData();
      params.append("file", file);
      let url = "http://139.155.48.151:8084/admin/auth/util/saveImg";
496 497 498
      const img = await axios.post(url, params);
      let urls = img.data.data.imgPath;
      return urls;
leiqingsong's avatar
leiqingsong committed
499
    },
500 501 502 503
    radioChange(val) {
      // console.log(val);
    },
    handleCreate() {
504 505 506 507 508 509 510 511 512 513 514 515 516
      if (
        this.basicInfo.title == '' ||
        this.basicInfo.startTime1 == '' ||
        this.basicInfo.endTime1 == '' ||
        this.logo_imgs.length == 0 ||
        this.basicInfo.jointimes == '' || 
        this.basicInfo.total_join == '' ||
        this.message == '' || 
        this.prize_produce == ''
      ) {
        this.$toast('请完整填写表单!');
        return;
      }
leiqingsong's avatar
leiqingsong committed
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
      this.prizeList.forEach(item => {
        if (item.type == "") {
          this.$toast('奖项类型必选!');
          return;
        }
        if (item.type == 1) {
          if (item.name == '' ||
            item.checked_coupon == {} ||
            item.total_limit == '' ||
            item.limit == '' ||
            item.preLimit == '' ||
            item.probability == ''
          ) {
            this.$toast('请填写完整奖项设置!');
            return;
          }
        } else {
          if(item.probability === '') {
            this.$toast('奖项概率不允许为空');
            return;
          }
        }
      })
leiqingsong's avatar
leiqingsong committed
540 541 542
      if (
        new Date(this.basicInfo.startTime1) >= new Date(this.basicInfo.endTime1)
      ) {
leiqingsong's avatar
leiqingsong committed
543 544 545
        this.$toast("活动开始时间应小于活动开始时间");
        return;
      }
546
      let params_prizeList = [];
leiqingsong's avatar
leiqingsong committed
547
      let total_probability = 0;
548
      this.prizeList.forEach((p, index) => {
549
        let temp = {};
550
        temp.id = index;
551 552 553
        temp.prizeName = p.name;
        if (p.type == 1) {
          temp.prizeType = 2;
554 555 556
        } else if (p.type == 2) {
          temp.prizeType = 1;
          temp.prizeName = "谢谢惠顾";
557
        }
558 559
        temp.quantity = p.total_limit;
        temp.personLimit = p.limit;
leiqingsong's avatar
leiqingsong committed
560
        temp.probability = p.probability;
leiqingsong's avatar
leiqingsong committed
561
        total_probability += Number(p.probability);
562
        temp.limitReceive = p.preLimit;
563
        temp.couponId = p.checked_coupon.id;
564
        temp.coupon = JSON.stringify(p.checked_coupon);
565 566
        params_prizeList.push(temp);
      });
leiqingsong's avatar
leiqingsong committed
567
      if (total_probability != 100) {
leiqingsong's avatar
leiqingsong committed
568
        this.$toast("所有奖项概率之和必须为100%");
leiqingsong's avatar
leiqingsong committed
569 570
        return;
      }
571 572
      let params = {
        activityInfo: {
leiqingsong's avatar
leiqingsong committed
573
          id: 0,
574 575 576 577
          activityName: this.basicInfo.title,
          activityType: "wheel",
          startTime: this.basicInfo.startTime1,
          endTime: this.basicInfo.endTime1,
leiqingsong's avatar
leiqingsong committed
578 579 580 581
          backImage: this.bg_imgs[0] ? this.bg_imgs[0].url : "",
          logo: this.logo_imgs[0] ? this.logo_imgs[0].url : "",
          joinLimit: this.basicInfo.jointimes,
          totalLimit: this.basicInfo.total_join,
582

leiqingsong's avatar
leiqingsong committed
583
          des: this.message,
leiqingsong's avatar
leiqingsong committed
584 585
          image: JSON.stringify(this.fileList),
          prizeDesc: this.prize_produce
586 587 588 589
        },
        activityPrizes: params_prizeList
      };
      API_Active.createActive(params).then(res => {
leiqingsong's avatar
leiqingsong committed
590 591 592 593 594
        if (res.result === "fail") {
          this.$toast(res.errorMsg);
          return;
        }
        Toast.success("创建成功");
595
        setTimeout(() => {
leiqingsong's avatar
leiqingsong committed
596 597 598 599 600 601 602 603 604
          this.$router.push({
            name: "createSuccess",
            params: {
              activityId: res.data.activityInfo.id,
              activityType: "wheel",
              logo: this.logo_imgs[0].url,
              des: this.message
            }
          });
605 606
        }, 200);
      });
607
    },
xd's avatar
xd committed
608
    startTimeChange(e) {
xd's avatar
xd committed
609
      let startTimeArr = e.getValues();
xd's avatar
xd committed
610 611
      this.basicInfo.startTime1 = `${startTimeArr[0]}-${startTimeArr[1]}-${startTimeArr[2]}`;
    },
xd's avatar
xd committed
612
    startTimeChange2(e, index) {
xd's avatar
xd committed
613
      console.log(111);
614

615
      this.prizeList[index].startTime1 = this.timeFormat(e);
616
      console.log(this.prizeList[index].startTime1, "2222");
xd's avatar
xd committed
617
    },
xd's avatar
xd committed
618
    handlePSTime(index) {
xd's avatar
xd committed
619 620
      this.prizeList[index].startTime1 = this.timeFormat(this.confirmTime);
      this.prizeList[index].startShow = false;
xd's avatar
xd committed
621
    },
622
    timeFormat(time) {
xd's avatar
xd committed
623 624 625
      let year = 1900 + time.getYear();
      let month = "0" + (time.getMonth() + 1);
      let date = "0" + time.getDate();
leiqingsong's avatar
leiqingsong committed
626 627
      let hour = "0" + time.getHours();
      let minute = "0" + time.getMinutes();
xd's avatar
xd committed
628 629 630 631 632 633
      return (
        year +
        "-" +
        month.substring(month.length - 2, month.length) +
        "-" +
        date.substring(date.length - 2, date.length) +
leiqingsong's avatar
leiqingsong committed
634 635 636 637 638
        " " +
        hour.substring(hour.length - 2, hour.length) +
        ":" +
        minute.substring(minute.length - 2, minute.length) +
        ":00"
xd's avatar
xd committed
639
      );
xd's avatar
xd committed
640 641 642
    },
    endTimeChange(e) {
      let endTimeArr = e.getValues();
xd's avatar
xd committed
643
      this.basicInfo.endTime1 = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`;
xd's avatar
xd committed
644
    },
xd's avatar
xd committed
645
    handleBasicETime(value) {
xd's avatar
xd committed
646 647
      this.basicInfo.endShow = false;
      this.basicInfo.endTime1 = this.timeFormat(value);
xd's avatar
xd committed
648
    },
649 650
    endTimeChange2(e, index) {
      this.prizeList[index].endTime1 = this.timeFormat(e);
xd's avatar
xd committed
651
    },
xd's avatar
xd committed
652
    ///点击确定不修改处理
653 654 655 656 657
    handleStartTime(e, index) {
      console.log(e, "e");

      this.prizeList[index].startTime1 = this.timeFormat(e);
      this.prizeList[index].startShow = false;
xd's avatar
xd committed
658
    },
659 660 661 662 663
    handleEndTime(e, index) {
      console.log(e, "e");

      this.prizeList[index].endTime1 = this.timeFormat(e);
      this.prizeList[index].endShow = false;
xd's avatar
xd committed
664
    },
xd's avatar
xd committed
665
    //////
xd's avatar
xd committed
666
    handlePETime(index) {
xd's avatar
xd committed
667 668
      this.prizeList[index].endTime1 = this.timeFormat(this.confirmTime);
      this.prizeList[index].endShow = false;
xd's avatar
xd committed
669
    },
xd's avatar
xd committed
670
    // 数字大写转小写
xd's avatar
xd committed
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
    numberToUpperCase(textIndex) {
      let newString = "";
      let newTextIndex = textIndex + "";

      function sum(value, index) {
        var newValue = "";
        if (textIndex === 9) {
          return !index ? "十" : "";
        }
        let isSeat = ~~textIndex > 9 && ~~textIndex < 19;
        switch (~~value) {
          case 1:
            newValue = !index ? (isSeat ? "" : "一") : "十一";
            break;
          case 2:
            newValue = !index ? (isSeat ? "" : "二") : "十二";
            break;
          case 3:
            newValue = !index ? (isSeat ? "" : "三") : "十三";
            break;
          case 4:
            newValue = !index ? (isSeat ? "" : "四") : "十四";
            break;
          case 5:
            newValue = !index ? (isSeat ? "" : "五") : "十五";
            break;
          case 6:
            newValue = !index ? (isSeat ? "" : "六") : "十六";
            break;
          case 7:
            newValue = !index ? (isSeat ? "" : "七") : "十七";
            break;
          case 8:
            newValue = !index ? (isSeat ? "" : "八") : "十八";
            break;
          case 9:
            newValue = !index ? (isSeat ? "" : "九") : "九十";
            break;
          case 0:
            newValue = "十";
            break;
          default:
            break;
        }
        return newValue;
      }

      for (let i = 0; i < newTextIndex.length; i++) {
        newString += sum(newTextIndex.substring(i, i + 1), i);
      }
      return newString;
xd's avatar
xd committed
722 723
    },
    addPrice() {
leiqingsong's avatar
leiqingsong committed
724 725 726 727
      if (this.prizeList.length > 7) {
        this.$toast("最多设置8个奖项");
        return;
      }
xd's avatar
xd committed
728 729
      this.prizeList.push({
        name: "",
730
        timeLine_type: "",
xd's avatar
xd committed
731 732 733 734 735 736 737
        type: "",
        discountsMoney: "",
        discountsShow: false,
        full: "",
        fullMoney: "",
        fullShow: false,
        validity: "",
xd's avatar
xd committed
738
        startTime: new Date(),
xd's avatar
xd committed
739 740
        startTime1: "",
        startShow: false,
xd's avatar
xd committed
741
        endTime: new Date(),
xd's avatar
xd committed
742 743
        endTime1: "",
        endShow: false,
744 745 746 747
        total_limit: "",
        total_limit_show: false,
        preLimit: "",
        preLimit_show: false,
xd's avatar
xd committed
748
        limit: "",
749 750 751 752
        limit_show: false,
        probability: "",
        probability_show: false,
        checked_coupon: {}
xd's avatar
xd committed
753 754 755
      });
    },
    removePrice(index) {
756
      this.prizeList.splice(index, 1);
xd's avatar
xd committed
757 758
    },
    handleBasicSTime(value) {
xd's avatar
xd committed
759 760 761
      this.basicInfo.startShow = false;
      this.basicInfo.startTime1 = this.timeFormat(value);
    }
xd's avatar
xd committed
762
  },
xd's avatar
xd committed
763
  mounted() {
leiqingsong's avatar
leiqingsong committed
764 765 766 767 768 769
    if (this.$route.query.activityId) {
      // 有模板数据
      console.log("有模板数据");
      let template_id = this.$route.query.templateId;
      this.getTemplateDate(template_id);
    }
xd's avatar
xd committed
770 771
    this.pTime = this.timeFormat(this.pTime);
    console.log(this.pTime, "time");
leiqingsong's avatar
leiqingsong committed
772
    this.getCoupons();
xd's avatar
xd committed
773
  }
xd's avatar
xd committed
774 775 776 777 778
};
</script>
<style></style>

<style scoped>
779 780
.l-yh,
.r-yh {
xd's avatar
xd committed
781 782 783 784 785 786 787
  width: 55%;
  display: flex;
  align-items: center;
}
.l-yh {
  width: 45%;
}
xd's avatar
xd committed
788 789 790 791 792 793 794 795 796 797 798
.bfb {
  position: absolute;
  right: 3px;
  top: 0;
}
.all >>> input {
  text-align: right;
}
.small {
  font-size: 10px;
}
xd's avatar
xd committed
799 800
.creat,
.add {
xd's avatar
xd committed
801 802 803 804 805 806 807 808 809
  width: 96%;
  height: 40px;
  background: rgba(117, 178, 253, 1);
  border-radius: 10px;
  text-align: center;
  line-height: 40px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
xd's avatar
xd committed
810 811
  margin: 0 auto;
  margin-top: 80px;
xd's avatar
xd committed
812 813 814
  margin-bottom: 16px;
}
.add {
xd's avatar
xd committed
815
  margin: 12px auto;
xd's avatar
xd committed
816
}
xd's avatar
xd committed
817 818 819
.area {
  background-color: #f8f8f8;
  width: 100%;
xd's avatar
xd committed
820 821 822
}
.des {
  font-size: 14px;
xd's avatar
xd committed
823 824 825
  font-weight: bold;
  color: rgba(45, 71, 106, 1);
  margin-bottom: 12px;
xd's avatar
xd committed
826 827 828
}

.phone {
xd's avatar
xd committed
829
  margin-right: 10px;
xd's avatar
xd committed
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
}
.title {
  background-color: #f8f8f8;
  height: 36px;
  line-height: 36px;
  font-size: 12px;
  padding-left: 16px;
  color: #2d476a;
}
[data-v-08d4afe1] .van-cell {
  height: 100%;
  font-size: 14px;
}
.right {
  padding: 0;
}
xd's avatar
xd committed
846 847 848
.nobr >>> .van-cell:not(:last-child)::after {
  display: none !important;
}
xd's avatar
xd committed
849
.right >>> .van-cell:not(:last-child)::after {
850
  display: none !important;
xd's avatar
xd committed
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868
}
.noborder >>> .van-cell:not(:last-child)::after {
  border: none;
}
.gl >>> .van-field__control {
  margin-right: 18px;
}
.name >>> .van-cell__value {
  font-size: 14px;
  font-weight: 400;
  color: rgba(45, 71, 106, 1);
}
.cs >>> .van-cell__title {
  flex: 3;
}
.task >>> .van-cell__title {
  flex: 7;
}
xd's avatar
xd committed
869 870 871
.validity >>> .van-cell__value {
  flex: 2;
}
xd's avatar
xd committed
872 873
.container {
  background: rgba(248, 248, 248, 1);
xd's avatar
xd committed
874 875 876 877 878
  height: auto;
  display: flex;
  flex-direction: column;
  background: rgba(248, 248, 248, 1);
  min-height: 100%;
xd's avatar
xd committed
879 880 881 882 883 884
}

.van-cell__title {
  color: #2d476a !important;
}
.type {
xd's avatar
xd committed
885
  height: 84px;
xd's avatar
xd committed
886 887 888 889
}
.mj {
  height: 40px;
  display: flex;
xd's avatar
xd committed
890
  justify-content: space-between;
xd's avatar
xd committed
891
  align-items: center;
xd's avatar
xd committed
892
  margin: 10px 0;
xd's avatar
xd committed
893 894 895
}
.sz {
  position: relative;
xd's avatar
xd committed
896
  padding-top: 10px;
xd's avatar
xd committed
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920
}
.je {
  width: 88px;
  height: 36px;
  display: flex;
  align-items: center;
  background: rgba(248, 248, 248, 1);
  border-radius: 10px;
}
.word {
  margin: 0 7px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(45, 71, 106, 1);
}
.end {
  margin-right: 0;
}
.tm {
  background-color: transparent;
}
.je >>> .van-cell:not(:last-child)::after {
  display: none;
}
921 922 923
.jpsl >>> .van-cell:not(:last-child)::after {
  display: none;
}
xd's avatar
xd committed
924
.all {
xd's avatar
xd committed
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
  box-shadow: 0px 1px 3px 0px rgba(221, 221, 221, 1);
  padding-bottom: 1px;
}
.detail {
  margin-top: 12px;
  background-color: #fff;
  /* height: 135px; */
  padding: 12px 16px 0 16px;
}
.border {
  border-bottom: 1px solid #ebedf0;
  padding-bottom: 9px;
}
.close {
  position: absolute;
  z-index: 999;
  top: 0;
xd's avatar
xd committed
942
}
xd's avatar
xd committed
943 944 945 946 947
.condition {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
xd's avatar
xd committed
948 949 950 951 952 953 954 955 956 957 958 959 960
.van-cell:not(:last-child)::after {
  right: 14px;
}
.yhType {
  padding: 14px;
}
.yhbr {
  border-bottom: 1px solid #f8f8f8;
  font-size: 14px;
}
.top {
  display: flex;
  justify-content: space-between;
xd's avatar
xd committed
961
  align-items: center;
xd's avatar
xd committed
962
}
xd's avatar
xd committed
963
</style>
964 965 966 967 968

<style lang="scss">
.container {
  .cs {
    .van-cell__value {
969
      flex: 2;
970 971 972 973
    }
  }
}
</style>