<template>
  <view class="content">
    <view class="banner">
      <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
        <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
          <swiper-item v-for="(item, index) in data" :key="index">
            <view class="swiper-item" @click="clickBannerItem(item)">
              <image :src="imgUrl+item.image" mode="aspectFill" :draggable="false" />
            </view>
          </swiper-item>
        </swiper>
      </uni-swiper-dot>
    </view>

    <view class="container">
      <view class="item" @click="buleTeeth">
        <image :src = "imgUrl+'/index/bluetooth.png'"/>
      </view>

      <view class="item" @click="scan">
        <image :src = "imgUrl+'/index/scan.png'"/>
      </view>
    </view>
  </view>
</template>

<script>

  export default {
    data:function(){
      return {
        current: 0,
        swiperDotIndex: 0,
        data: [{
          image: '/index/banner-index.png'
        }
        ]
      }
    },
    computed: {
      imgUrl() {
        return getApp().globalData.config.imgUrl;
      }
    },
    onLoad: function() {
    },
    onShow(){
    },
    methods:{
      buleTeeth(){
        this.$modal.showToast('功能开发中~')
      },
      scan(){
        if(window.location.href.indexOf("localhost") != -1){
          this.scan2();
        }else{
          uni.navigateTo({
            url: '/pages/weitiandi/device/scan'
          });
        }


        // uni.scanCode({
        //   success: function (res) {
        //     console.log('条码类型：' + res.scanType);
        //     console.log('条码内容：' + res.result);
        //     getDeviceInfoFromQrcode(res.result).then(res=>{
        //       if(res.data != null){
        //         let imei = res.data.imei;
        //         let ccid = res.data.ccid;
        //         uni.navigateTo({
        //           url: '/pages/weitiandi/device/index?id='+imei+'&ccid='+ccid
        //         });
        //       }
        //     });
        //   }
        // });
      },
      scan2(){
        getDeviceInfoFromQrcode("http://wetiandi.com/app/index.php?i=1&j=1&c=entry&m=wdl_shopping&do=wepay&sn=GD1B342399").then(res=>{
            if(res.data != null){
                  let imei = res.data.imei;
                  let ccid = res.data.ccid;
                  uni.navigateTo({
                    url: '/pages/weitiandi/device/index?id='+imei+'&ccid='+ccid
                  });
            }
        });
      }
    }
  }
</script>

<style>
  .content {
    background: rgb(249, 252, 255);
    inset: 0;
    position: absolute;
  }


  .swiper {
    height: 22vh;
  }
.banner{
  height: 22vh;
  width: 100%;
  margin-top:1vh
}
  .swiper-box {
    height: 22vh;
  }

  .swiper-item {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    height: 300rpx;
    line-height: 300rpx;
  }

  @media screen and (min-width: 500px) {
    .uni-swiper-dot-box {
      width: 400px;
      /* #ifndef APP-NVUE */
      margin: 0 auto;
      /* #endif */
      margin-top: 8px;
    }

    .image {
      width: 100%;
    }
  }
  .item{
    display: inline-block;
    width: 50%;
  }
  .item image{
    height: 12vh;
  }
</style>
