<template>
  <el-row>
    <el-col :span="10" :offset="2">
      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()">
        <el-form-item>
          <p>淘客订单查询：一次最多查询一条订单号</p>
        </el-form-item>
        <el-form-item prop="orderNo">
          <el-input
            type="textarea"
            :rows="5"
            placeholder="请输入订单号"
            v-model="dataForm.orderNo">
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="dataFormSubmit()">淘客检测</el-button>
        </el-form-item>
        <el-form-item>
          <p>检测结果：</p>
          <el-input
            type="textarea"
            :rows="5"
            placeholder=""
            disabled
            v-model="ordersearchResult">
          </el-input>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'tools-ordersearch',
  data () {
    return {
      dataForm: {
        orderNo: ''
      },
      ordersearch: '', // 1454509298597998128
      ordersearchResult: '',
      dataRule: {
        orderNo: [
          { required: true, message: '订单号不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    dataFormSubmit () {
      this.$refs['dataForm'].validate((valid) => {
        console.log(valid)
        if (!valid) {
          return
        }
        this.$http({
          url: this.$http.adornUrl('/tb/getOrderMsg'),
          method: 'post',
          data: this.$http.adornData({
            'orderNo': this.dataForm.orderNo
          })
        }).then(({ data }) => {
          if (data.status) {
            const { taoke } = data.data
            this.ordersearch = data.data
            this.ordersearchResult = taoke ? '是' : '否'
          } else {
            this.$message.error(data.msg)
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
