判断两个时间大小

vue+vant

        <van-field
          readonly
          clickable
          name="datetimePicker"
          :value="custFlowInfo.newAppointTime"
          label="预约时间"
          placeholder="点击选择预约时间"
          @click="showPicker.time = true"
        />
        <van-popup v-model="showPicker.time" position="bottom">
          <van-datetime-picker
            type="datetime"
            :min-date="minDate"
            @confirm="onConfirmTime"
            @cancel="showPicker.time = false"
          />
        </van-popup>


js部分

// appointmentTime是  ‘2020-04-03 18:00’这种字符串形式

  data() {
    return {
      oldAppointTime: new Date(this.itemData.appointmentTime).getTime(),
    }
  },
    

    onConfirmTime(time) {
      this.custFlowInfo.newAppointTime = formatDateHourMinute(time);
      if (this.oldAppointTime > new Date(time).getTime()) {
        this.custFlowInfo.newAppointTime = ''
        Toast.fail('新预约时间应大于原预约时间')
      }

  

posted @ 2021-06-06 16:46  soon_k  阅读(103)  评论(0编辑  收藏  举报