<template>
  <view class="wrap">
	  <view class="search-header">
	    <scanlistener
	    v-if="showScanlistener"
	    suffixIcon="scan"
	    v-model="keyword"
	  	:focus="focusStart"
	    :placeholder="$t('请输入订单号')"
	    @iconClick="()=>{scanCode()}"
	    @confirm="searchCode"
	    @submit="keyword=$event;searchCode()"
	    ></scanlistener>
	  </view>
    <view style="height: 60px; background: #2f4dae"></view>
  </view>
</template>

<script>
import {uniIcons} from '@dcloudio/uni-ui';
export default {
  components: { uniIcons },
  data() {
    return {
	    keyword: "",
      focusStart: false,
    }
  },
  onLoad: function(option) {
    uni.setNavigationBarTitle({
      title: this.$t('搜索')
    })
  },
  methods: {
    scanCode() {
      uni.scanCode({
        success: (res) => {
          this.keyword = res.result;
          this.searchCode();
        },
      });
    },
    searchCode(){
      setTimeout(() => {
        const pages = getCurrentPages()
        const lastPage = pages[pages.length - 2]
        console.log({lastPage})
        lastPage.$vm.search && lastPage.$vm.search(this.keyword)

        uni.navigateBack()
      }, 100)
    }
  }
}
</script>

<style lang="scss" scoped>
.tabs{
  margin-top: 10rpx;
  button{
    flex: 1;
  }
}
.mr-10{
  margin-right: 10rpx;
}
.flex-1{
  flex: 1;
}
.justify-between{
  justify-content: space-between;
}
.item{
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 20rpx;
}
.radio{
  width: 50rpx;
  height: 50rpx;
  vertical-align: center;
  margin-right: 10rpx;
}
.action-bar{
  margin: 20rpx 0;
}
.search-header {
  // padding-bottom: 0px;
  ::v-deep .uni-easyinput__content {
    border-radius: 20px;
    padding-right: 10px;
    background: rgba($color: #fff, $alpha: 0.5) !important;
    border: none;
  }

  ::v-deep .uni-input-placeholder {
    padding-left: 8px;
    color: #b2c9f3;
  }

  ::v-deep .uni-input-input {
    padding-left: 8px;
  }
}
</style>
