step-two.vue 3.24 KB
<template>
  <div class="step-two">
    <div class="input-group-box">
      <input-group
        :value="value"
        @input="input"
        :error="error"
        :pattern="/^[A-Za-z0-9]+$/"
      ></input-group>
      <div
        class="err-box"
        v-show="error"
      >提示:当前输入的{{errText}}</div>
    </div>
    <div class="line"></div>
    <div class="title">如何查找挪车码</div>
    <div class="tips-box">
      <div class="sprite-icon icon-car-tips"></div>
      <div class="tips-text">请在<span>挪车贴</span>上寻找“挪车码”</div>
    </div>
    <div
      :class="['btn',{'btn-disabled':value.length < 6}]"
      @click="submit"
      @touchstart="touchstart"
      @touchend="touchend"
    >提交</div>
  </div>
</template>

<script type='text/ecmascript-6'>
import InputGroup from '@c/InputGroup'
import { car } from '@r/api'
export default {
  name: 'step-two',
  data () {
    return {
      value: '',
      error: false,
      errText: ''
    }
  },
  props: {
    values: null
  },
  components: {
    'input-group': InputGroup,
  },
  mounted () {
  },
  methods: {
    input (val) {
      this.value = val
      this.error = false
    },
    submit () {
      let { value, values } = this
      if (value.length < 6) return
      this.showLoading('校检中...')
      car.checkCode({ code: value }).then(res => {
        if (res) {
          let { code, message } = res
          if (code == 0) {
            car.bindCarCode({
              ...values,
              code: value
            }).then(_res_ => {
              console.log(_res_)
              if (_res_) {
                if (_res_.code == 0) {
                  this.$emit('step_two_success')
                } else {
                  this.showToast(_res_.message)
                }
              } else {
                this.showToast('系统异常')
              }
            })
          } else {
            this.error = true
            this.errText = message
          }
        } else {
          this.showToast('系统异常')
        }
      })
    }
  }
}
</script>

<style scoped lang='scss'>
.step-two {
  padding: 0 20px;
  .input-group-box {
    padding: 40px 0 66px;
    position: relative;
    .err-box {
      font-size: 12px;
      color: #fa5151;
      position: absolute;
      top: 90px;
      left: 0;
    }
  }
  .line {
    width: 100%;
    height: 2px;
    background: #e9e9e9;
    border-radius: 1px;
  }
  .title {
    font-size: 14px;
    color: #3b3b3b;
    margin: 20px 0 10px;
    text-align: center;
  }
  .tips-box {
    width: 100%;
    height: 119px;
    background: #ffffff;
    box-shadow: 0 1px 4px 0 rgba(59, 147, 217, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
    padding-right: 10px;
    .sprite-icon {
      transform: translateX(38px);
    }
    .tips-text {
      font-size: 12px;
      color: #2a2a2a;
      span {
        color: #52e8ff;
      }
    }
  }
  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 226px;
    height: 30px;
    background: #008fff;
    border-radius: 18.5px;
    margin: 81px auto 0;
    font-size: 14px;
    color: #ffffff;
  }
  .btn-disabled {
    background: #e0e0e0;
  }
}
</style>