<template>
  <view class="flex-col page">
    <view class="flex-col section_2">
      <view class="flex-col section_3">
        <view class="justify-between search">
		  <u-input class="search-input" v-model="value" :focus="inputFocus" @focus="focusEvent" @blur="blurEvent" placeholder="请输入评级编号" border="surround" :clearable="true" ></u-input>
          <view class="flex-col items-center text-wrapper" @click="search">
            <text>搜索</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
	import { ratingSearch } from '@/service/grading.js';
	
  export default {
    data() {
      return {
		  value: '',
		  inputFocus: true
	  };
    },
	methods: {
		async search(){
			if(!this.value) return this.$msg('请输入评级编号');
			let res = await ratingSearch(this.value);
			let data = res.data.datas.data;
			
			if(data.length > 0){ // 查询到订单，默认取第一条
				let id = data[0].id;
				this.$url('/packages/ratingQueryDetail/ratingQueryDetail?id='+ id);
			}else{
				uni.showModal({
					title: '提示',
					content: '该评级编号暂无订单，换个编号试试？',
					showCancel: false
				})
			}
		},
		focusEvent(){
			this.inputFocus = true;
		},
		blurEvent(){
			this.inputFocus = false;
		}
	}
  };
</script>

<style scoped lang="css">
  .page {
    background-color: #f6f6f6;
    width: 100%;
    overflow-y: auto;
    height: 100%;
  }
  .search-input{
	  width: 492rpx;
	  height: 84rpx;
  }
  .section_2 {
    padding: 32rpx 32rpx 16rpx;
    flex: 1 1 auto;
    background-color: rgb(255, 255, 255);
    overflow-y: auto;
  }
  .section_3 {
    padding: 6rpx 0;
    background-color: rgb(246, 246, 246);
    border-radius: 10rpx;
  }
  .search {
    margin-left: 31rpx;
    margin-right: 6rpx;
  }
  .group_4 {
    align-self: center;
    color: rgb(195, 195, 195);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 40rpx;
    white-space: nowrap;
  }
  .text-wrapper {
    padding: 20rpx 0;
    color: rgb(255, 255, 255);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
    background-color: rgb(231, 162, 63);
    border-radius: 6rpx;
    width: 130rpx;
    height: 84rpx;
  }
  .image_6 {
    margin-bottom: 4rpx;
    width: 37rpx;
    height: 34rpx;
  }
  .text_2 {
    margin-left: 10rpx;
  }
</style>