<wxs src="../../../utils/format.wxs" module="format" />
<view class="myqr" wx:if="{{myqr_show}}">
  <view>
    <image class="cancel" src="/static/images/cancel.png" bindtouchstart="qrtouchstart"></image>
  </view>
  <view>
    <image class="img" src="{{myqr_url}}" mode="widthFix" />
  </view>
  <view>
    <image class="btn" style="float:unset" bindtap="saveShare" src="/static/images/right.png" />
  </view>
</view>

<view>
<image src="/static/images/csr.png" style="width: 80px;height: 80px;position: fixed;z-index: 9;top: 360rpx;right: 15rpx;"></image>
<contact-button  class="csr"   type="default-dark" style="opacity: 0;position: fixed;z-index: 99999;right: 15rpx; width: 100rpx;height: 100rpx;top:400rpx" session-from="weapp" size="27">
			</contact-button>
</view>

<view class="container">
  <view class="orders-switch">
    <view class="item {{ showType == 0 ? 'active' : ''}}" bindtap="switchTab" data-index='0'>
      <view class="txt">全部预检单</view>
    </view>
    <view class="item {{ showType == 1 ? 'active' : ''}}" bindtap="switchTab" data-index='1'>
      <view class="txt">未预检</view>
    </view>
    <view class="item {{ showType == 2 ? 'active' : ''}}" bindtap="switchTab" data-index='2'>
      <view class="txt">已预检</view>
    </view>
    <view class="item {{ showType == 3 ? 'active' : ''}}" bindtap="switchTab" data-index='3'>
      <view class="txt">自定义预检</view>
    </view>

  </view>
  <view class="no-order" wx:if="{{orderList.length <= 0}}">
    <view class="c">
      <text>还没有预检工单呢</text>
    </view>
  </view>

  <view class="orders">

    <view class='book' wx:for="{{orderList}}" wx:for-item="item" wx:key="item">
      <view style="border-bottom:0.5rpx dashed #999">
        <view class="status">{{item.status==0?'未预检':'已预检'}}</view>
        <view class="bookname">工单号：{{item.bookNo}}</view>
        <view class="address">服务地址：{{item.stationName}}-{{item.address}}</view>
        <view class="serviceTime">预约时间：{{item.serviceTime}}</view>
        <view class="serviceTime" wx:if="{{item.status==1}}">服务时间：{{item.createTime}}</view>
        <view class="goodsname">客户名称：{{item.userName}}</view>
      </view>

      <!-- 预检项目 -->
      <view class="content" wx:for="{{item.items}}" wx:for-item='detail' wx:key='*this'>
        <view class="category">服务项:{{detail.categoryName}}</view>
        <view class="device">
          {{detail.deviceName}}
          <span wx:if="{{detail.positionName}}">(</span>
          <span>{{detail.positionName}}</span>
          <span wx:if="{{detail.positionName}}">)</span>
        </view>

        <view class="problem">
          <view class="item" wx:for="{{detail.problemsName}}" wx:for-item='problem' wx:key='*this'>{{problem}}</view>
          <view class="item" wx:if="{{detail.memo}}">备注:{{detail.memo}}</view>
        </view>
        <view class="problem">
          <image class="img" src="{{pic}}" wx:for="{{detail.picUrls}}" wx:for-item='pic' wx:key='*this' />
        </view>

      </view>


      <view class="tool">
        <!--  <button class="btn" bindtap="openMap" data-lng="{{item.lng}}" data-lat="{{item.lat}}" data-address="{{substring(item.stationName,1,2)+item.address}}">地图</button> -->
        <button class="btn" data-mobile="{{item.userPhone}}" bindtap="makeCall">联系客户</button>
        <button class="btn" wx:if="{{item.status==0}}" style="color:darkred" bindtap="goPre" data-id="{{item.id}}"
          data-bookNo="{{item.bookNo}}" data-userPhone="{{item.userPhone}}">去预检</button>

        <button class="btn" bindtap="editPre" data-bookno="{{item.bookNo}}"
          wx:if="{{format.substrDate(item.createTime)==today}}">修改</button>
      </view>
    </view>

  </view>
</view>