createActive.vue 7.2 KB
<template>
  <div class="container">
    <div class="title">基础设置</div>
    <van-cell-group class="all">
      <van-cell title="活动标题" style="font-size:14px;">
        <template slot="default">
          <van-field
            v-model="title"
            placeholder="请输入活动标题"
            class="right"
            style="font-size:14px;"
          />
        </template>
      </van-cell>
      <van-cell title="消费后领券" style="font-size:14px;">
        <template slot="default">
          <van-switch v-model="coupon" size="20px" class="right" />
        </template>
      </van-cell>
      <van-cell title="新客专享" style="font-size:14px;">
        <template slot="default">
          <van-switch v-model="newCustomer" size="20px" class="right" />
        </template>
      </van-cell>
      <van-cell title="领券条件" style="font-size:14px;">
        <template slot="default">
          <div class="condition">
            <span class="phone">手机号必填</span>
            <van-switch v-model="condition" size="20px" />
          </div>
        </template>
      </van-cell>
    </van-cell-group>
    <div class="title">券设置</div>
    <van-cell-group class="all">
      <van-cell title="活动标题" style="font-size:14px;">
        <template slot="default">
          <van-field
            v-model="title2"
            placeholder="请输入活动标题"
            class="right"
            style="font-size:14px;"
          />
        </template>
      </van-cell>
      <van-cell title="券类型" style="font-size:14px;">
        <template slot="default">
          <van-radio-group v-model="type" class="right">
            <van-radio name="1" style="float:left;">代金券</van-radio>
            <van-radio name="2" style="float:right;">折扣券</van-radio>
          </van-radio-group>
        </template>
      </van-cell>
      <van-cell title="代金券金额" style="font-size:14px;">
        <template slot="default">
          <div class="npbr">
            <van-field
              class="right noborder"
              readonly
              clickable
              :value="cashCoupon"
              placeholder="输入代金券金额"
              @touchstart.native.stop="show = true"
            />
            <van-number-keyboard
              v-model="cashCoupon"
              :show="show"
              :maxlength="6"
              @blur="show = false"
            />
          </div>
        </template>
      </van-cell>
      <van-cell title="使用门槛" style="font-size:14px;">
        <template slot="default">
          <div class="npbr">
            <van-field
              class="right noborder"
              readonly
              clickable
              :value="limit"
              placeholder="输入使用门槛"
              @touchstart.native.stop="show2 = true"
            />
            <van-number-keyboard
              v-model="limit"
              :show="show2"
              :maxlength="6"
              @blur="show2 = false"
            />
          </div>
        </template>
      </van-cell>
      <van-cell title="活动开始时间" style="font-size:14px;">
        <template slot="default">
          <div class="npbr">
            <van-field
              class="right"
              v-model="startTime1"
              placeholder="选择活动开始时间"
              readonly="readonly"
              @click="startShow = true"
            />
            <van-popup v-model="startShow" position="bottom" :overlay="true">
              <van-datetime-picker
                v-model="startTime"
                type="date"
                @cancel="startShow = false"
                @confirm="handleStartTime"
                @change="startTimeChange"
              />
            </van-popup>
          </div>
        </template>
      </van-cell>
      <van-cell title="活动结束时间" style="font-size:14px;">
        <template slot="default">
          <div class="npbr">
            <van-field
              class="right"
              v-model="endTime1"
              placeholder="选择活动结束时间"
              readonly="readonly"
              @click="endShow = true"
            />
            <van-popup v-model="endShow" position="bottom" :overlay="true">
              <van-datetime-picker
                v-model="endTime"
                type="date"
                @cancel="endShow = false"
                @confirm="handleEndTime"
                @change="endTimeChange"
              />
            </van-popup>
          </div>
        </template>
      </van-cell>
      <div class="des">描述</div>
      <van-field
        class="area"
        v-model="message"
        rows="3"
        autosize
        type="textarea"
        placeholder="请输入描述"
        show-word-limit
      />
    </van-cell-group>
    <div class="creat">创建活动</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: "",
      title2: "",
      coupon: "",
      newCustomer: "",
      condition: "",
      type: "",
      show: false,
      show2: false,
      cashCoupon: "",
      limit: "",
      startTime: new Date(),
      startTime1: "",
      endTime: new Date(),
      endTime1: "",
      startShow: false,
      endShow: false,
      message: ""
    };
  },
  methods: {
    timeFormat(time) {
      let year = 1900 + time.getYear();
      let month = "0" + (time.getMonth() + 1);
      let date = "0" + time.getDate();
      return year + "-" + month.substring(month.length-2, month.length)  + "-" + date.substring(date.length-2, date.length)
       + " "
    },
    startTimeChange(e) {
      let startTimeArr = e.getValues();
      this.startTime1 = `${startTimeArr[0]}-${startTimeArr[1]}-${startTimeArr[2]}`;
    },
    handleStartTime(value) {
      this.startTime1 = this.timeFormat(value)
      this.startShow = false
    },
    handleEndTime(value) {
      this.endTime1 = this.timeFormat(value)
      this.endShow = false
    },
    endTimeChange(e) {
      let endTimeArr = e.getValues();
      this.endTime1 = `${endTimeArr[0]}-${endTimeArr[1]}-${endTimeArr[2]}`;
    }
  },
  mounted() {}
};
</script>
<style></style>

<style scoped>
.condition {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.phone {
  margin-right: 10px;
}
.all >>> input {
  text-align: right;
}
.noborder >>> .van-cell:not(:last-child)::after {
  display: none !important;
}
.npbr .van-cell:not(:last-child)::after {
  display: none !important;
}
.creat {
  margin-top: 80px;
  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;
  margin-left: 2%;
  margin-bottom: 16px;
}
.container {
  height: auto;
  display: flex;
  flex-direction: column;
  background: rgba(248, 248, 248, 1);
  min-height: 100%;
}
.area >>> .van-field__control {
  background: #f8f8f8;
  padding: 12px;
}
.des {
  padding: 5px 18px 0px;
  font-size: 14px;
  color: #2d476a;
}

.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;
}
.van-cell__title {
  color: #2d476a !important;
}
</style>