<template>
  <div>
    <div style="height: 44px;">
      <mt-search
        v-model="value"
        cancel-text="取消"
        placeholder="搜索">
      </mt-search>
    </div>

    <group title="" label-width="5em">
      <popup-picker :title="title1" :data="list1" v-model="value1" @on-show="onShow" @on-hide="onHide" @on-change="onChange" placeholder="请选择"></popup-picker>
      <popup-picker :title="title2" :data="list2" v-model="value2" @on-show="onShow" @on-hide="onHide" @on-change="onChange" placeholder="请选择"></popup-picker>
    </group>
    <ul class="serviceDetailWrap" v-if="dataList.length>0">
      <li v-for="(i, index) in dataList" :key="i.id">
        <div class="serviceDetailTop serviceDetailTop1" :style="{'background-image':'url('+i.logoUrl+')'}">
          <p>
            <span style="color: #ffbe00;font-weight: 600;font-size: 16px;">{{i.companyName}}</span>
          </p>
          <p style="padding: 8px 0">
            <span style="color: #ff4949">营业时间:{{i.workTime}}</span>
          </p>
          <!--<p>-->
            <!--<span>联系人：余红艳</span>-->
          <!--</p>-->
          <p>

            <span>热线电话:{{i.reportTel}}</span>

          </p>
        </div>
        <p style="display: flex;justify-content: space-between;">
          <span class="fontSize12">位置:{{i.companyAddress}}</span>
          <!--<span @click="toLinkApp(i.lonId,i.latId,i.companyName)">-->
             <!--<img src="../../assets/images/service/serviceNav.png" height="18" width="18"/>-->
          <!--</span>-->
        </p>

        <!--<p>-->
          <!--<span class="fontSize12">服务范围：{{i.mainBusines}}</span>-->
        <!--</p>-->
        <!--<p>-->
        <!--<span></span>-->
        <!--</p>-->
        <p style="display: flex;justify-content: space-between;padding-top: 5px;">
          <span class="serviceStar fontSize12">{{i.mainBusines}}</span>
          <span @click="callPhone(i.reportTel)">
            <img src="../../assets/images/service/serviceIphone.png" height="18" width="18"/>
          </span>
        </p>

        <p style="display: flex;justify-content: space-between;padding-top: 5px;" @click="toInsureDetail(i.id)">
          <span class=" fontSize12">查看详情</span>
          <span>
            <img src="../../assets/images/service/rightArrow.png" height="16" width="16"/>
          </span>
        </p>
      </li>


      <!--<li>-->
        <!--<div class="serviceDetailTop serviceDetailTop2">-->
          <!--<p>-->
            <!--<span style="color: #ffbe00;font-weight: 600;font-size: 16px;">途虎养车磁湖东路店</span>-->
          <!--</p>-->
          <!--<p>-->
            <!--<span style="color: #ff4949">营业时间：08:00-21:00</span>-->
          <!--</p>-->
          <!--<p>-->
            <!--<span>联系人：梁浩</span>-->
          <!--</p>-->
          <!--<p>-->

            <!--<span>联系电话：13339906728</span>-->

          <!--</p>-->
        <!--</div>-->
        <!--<p style="display: flex;justify-content: space-between;">-->
          <!--<span class="fontSize12">位置: 黄石西塞山区磁湖东路26号途虎养车</span>-->
          <!--<span @click="toLinkApp('115.089421','30.211496','途虎养车磁湖东路店')">-->
             <!--<img src="../../assets/images/service/serviceNav.png" height="18" width="18"/>-->
          <!--</span>-->
        <!--</p>-->

        <!--<p>-->
          <!--<span class="fontSize12">服务范围：轮胎更换，美容洗车，车品安装</span>-->
        <!--</p>-->
        <!--&lt;!&ndash;<p>&ndash;&gt;-->
        <!--&lt;!&ndash;<span></span>&ndash;&gt;-->
        <!--&lt;!&ndash;</p>&ndash;&gt;-->
        <!--<p style="display: flex;justify-content: space-between;padding-top: 5px;">-->
          <!--<span class="serviceStar fontSize12">维修、保养、美容</span>-->
          <!--<span @click="callPhone('13339906728')">-->
            <!--<img src="../../assets/images/service/serviceIphone.png" height="18" width="18"/>-->
          <!--</span>-->
        <!--</p>-->
      <!--</li>-->


    </ul>
    <p v-else style="padding-top: 20px">暂无数据</p>
  </div>
</template>

<script>

import { queryInsuranceCompanyList } from '@/api/service/service.js'

export default {
  name: "insure",
  data () {
    return {
      value:'',
      title1: '全部服务',
      value1: ['全部'],
      list1: [['全部', '汽车', '美容']],
      title2: '附近',
      value2: ['3KM'],
      list2: [['3KM', '10KM', '20KM']],
      dataList:[],
    }
  },
  mounted() {
    window.toLinkApp = this.toLinkApp;
    window.callPhone = this.callPhone;

  },
  created() {
    this.queryInsuranceCompanyList(this.carNumber)
  },
  methods: {
    queryInsuranceCompanyList(){  // 获取停车记录数据
      var salt = this.$utils.myCommonSalt(32);
      var jsondata = {
        app_id: this.$utils.myVarAppid,
        deviceInfo: this.$utils.myDeviceInfo,
        salt: salt,
        sign_type: "md5",
        orgId: this.$utils.myOrgId,
        companyName: "",
        companyNo: "",
        id: "",
        latId: "",
        lonId: "",
        raidus: "",
        servicesType: "",

      }
      jsondata.sign = this.$utils.signObject(jsondata)

      // jsondata.sign = md5sign
      queryInsuranceCompanyList(jsondata).then(response => {
        console.log(response)
        this.dataList = response.data

      })
    },
    callPhone(telNum) {
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
      if (isAndroid) {
        // alert("我是安卓");
        window.JSInterface.callAppPhone(telNum);
      }
      if (isIOS) {
        // alert("我是苹果");
        window.webkit.messageHandlers.callAppPhone.postMessage({ "phoneNumber": telNum})
      }
    },
    toLinkApp(lon,lat,name){
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
      if (isAndroid) {
        // alert("我是安卓");
        window.JSInterface.toApp(lon,lat,name);
      }
      if (isIOS) {
        // alert("我是苹果");
        window.webkit.messageHandlers.toApp.postMessage({ "lon": lon, "lat": lat, "name":name})
      }

    },
    toInsureDetail(_id){
      this.$router.push(
      {
        path:'insureDetail',
        query: {
          id: _id
        }
      })
    },
    onChange (val) {
      console.log('val change', val)
    },
    changeList10 () {
      this.list1 = [['小米1', 'iPhone1', '华为1', '情怀1', '三星1', '其他1', '不告诉你1']]
    },
    changeList11 () {
      this.list1[0].push('我是push条目')
    },
    changeList20 () {

    },

    onShow () {
      console.log('on show')
    },
    onHide (type) {
      console.log('on hide', type)
    }
  },
}
</script>

<style scoped lang="scss">
  .serviceDetailWrap {
    padding: 10px 10px;
    > li {
      /*height: 160px;*/
      padding-bottom: 10px;
      margin-bottom: 10px;
      border-bottom: 1px solid #eee;
      /*display: flex;*/
    }
  }

  .serviceDetailTop {
    padding-left: 130px;

    margin-bottom: 5px;
    background-repeat: no-repeat;
    background-size: 120px 83px;
  }

  .serviceStar{
    padding-left: 20px;
    background: url("../../assets/images/service/serviceStar.png") no-repeat 0 center;
    background-size: 16px 16px;
    color: #ff4949;
  }
  .fontSize12{
    font-size: 13px;
  }
</style>
