<!--pages/Bluetooth/Bluetooth.wxml-->
<view wx:if="{{selectindex !=4}}">
  <van-radio-group value="{{ selectRadio }}" bind:change="onChangeSelectRaio">
    <van-radio name="1" class="ma-2">注册绑定房间</van-radio>
    <van-radio name="2">仅注册</van-radio>
    <van-radio name="3">注册绑定已选房间</van-radio>
  </van-radio-group>
  <view class="">
    <view wx:if="{{deviceInfo.roomId}}" class="btnlist">
      <van-cell-group style="width:100%;">
        <van-cell title="蓝牙开锁" value="{{deviceInfo.deviceNum}}" bindtap="openTheDoor" is-link />
        <van-cell title="同步时间" value="{{lockStatus.lockTime}}" bindtap="synchronizationTime" is-link />
        <van-cell title="设置音量" value="" bindtap="setVoice" is-link />
        <van-cell title="读取锁状态" value="" bindtap="readLockStatus" is-link />
        <van-cell title="获取锁端私钥" value="{{privateKey}}" bindtap="getPirvateKey" is-link />
        <van-cell title="下发五组密钥" value="" bindtap="sendSetKey" is-link />
        <!-- sendSetKey ShowRoomMathods-->
        <van-cell title="重置门锁" value="" bindtap="resetLock" is-link />
        <van-cell title="设置WiFi" value="" bindtap="setWifi" is-link border="{{ false }}" />
        <van-cell title="WiFi" value="{{lockStatus.wifiSsid}}" label="" />
        <van-cell title="设置NB网关" value="" bindtap="setIP" is-link border="{{ false }}" />
        <van-cell title="网关" value="{{lockStatus.serverIp}}" label="" border="{{ false }}" />
        <van-cell title="端口" value="{{lockStatus.serverPort}}" label="" />
        <van-cell title="房间解绑" value="{{deviceInfo.roomName}} 解绑" bindtap="unbindRoomMethods" is-link />
      </van-cell-group>
    </view>
    <view class="bindRoom" wx:else>
      <van-cell title="已选房源" icon="location-o" value="{{selectRoomName}}" />
      <view wx:if="{{ selectRadio == 1 && !onlyResgiter }}">
        <van-button type="default" size="large" bindtap="bindroom">绑定房间</van-button>
      </view>
      <view wx:elif="{{ selectRadio == 2 && !onlyResgiter }}" class="mb-1">
        <van-button type="default" size="large" bindtap="addAdmin">注册设备</van-button>
      </view>
      <view wx:else="{{ selectRadio == 3 && !onlyResgiter }}" class="mb-1">
        <van-button type="default" size="large" bindtap="bindroom">注册绑定设备</van-button>
      </view>
    </view>
    <view wx:if="{{onlyResgiter && selectindex == 4}}">
      <van-cell title="蓝牙开锁" value="{{lockStatus.deviceNum}}" bindtap="openTheDoor" is-link />
      <van-cell title="同步时间" value="{{lockStatus.lockTime}}" bindtap="synchronizationTime" is-link />
      <van-cell title="设置音量" value="" bindtap="setVoice" is-link />
      <van-cell title="读取锁状态" value="" bindtap="readLockStatus" is-link />
    </view>
    <view class="locktext" wx:if="{{ lockStatus}}">
      <view class="lockli">版本号：{{lockStatus.softWareVersion}}</view>
      <view class="lockli">电量：{{lockStatus.power}}</view>
      <view class="lockli">NB信号：{{lockStatus.nbSignal}}</view>
      <view class="lockli">IMEI：{{lockStatus.nbIMEI}}</view>
      <view class="lockli">IMSI：{{lockStatus.nvIMSI}}</view>
      <view class="lockli">用户数量：{{lockStatus.appUserCount}}</view>
      <view class="lockli">黑名单用户数量：{{lockStatus.blackListCount}}</view>
      <view class="lockli">蓝牙扣数量：{{lockStatus.bleKeyCount}}</view>
      <view class="lockli">剩余可添加用户数量：{{lockStatus.remainCount}}</view>
      <view class="lockli">未上传开锁记录数量：{{lockStatus.notUploadCount}}</view>
      <view class="lockli">密码数量：{{lockStatus.pwdCount}}</view>
      <view class="lockli">指纹数量：{{lockStatus.fingerPrintsCount}}</view>
      <view class="lockli">门卡数量：{{lockStatus.RFCount}}</view>
      <view class="lockli">锁当前时间：{{lockStatus.lockTime}}</view>
      <view class="lockli">锁型号：{{lockStatus.lockerMode}}</view>
      <view class="lockli">锁SN号：{{lockStatus.lockSn}}</view>
      <view class="lockli">WiFi名：{{lockStatus.wifiSsid}}</view>
      <view class="lockli">服务器：{{lockStatus.serverIp}}</view>
      <view class="lockli">服务器端口：{{lockStatus.serverPort}}</view>
    </view>
    <van-popup show="{{ show }}" bind:close="onClose" position="bottom" custom-style="height: 60%">
      <tree dataTree="{{dataList}}" selectKey="{{selectKey}}" bind:select="handleSelect" isSelectLastNode="true" isOpenAll="{{false}}"></tree>
    </van-popup>
    <van-action-sheet show="{{ show1 }}" actions="{{ actions }}" bind:close="onClose1" bind:select="onSelect1" />
    <van-popup show="{{ showWifi }}" custom-style="width: 90%" bind:close="onCloseWifi" round>
      <view class="addword">
        <van-field value="{{ wifiName }}" placeholder="请输入wifi名称" label="wifi" border="{{ true }}" bind:change="onChangeWifi" />
        <van-field value="{{ wifiPassword }}" placeholder="请输入wifi密码" label="密码" border="{{ true }}" bind:change="onChangeWifi1" />
        <view class=""><button type="primary" bindtap="confirmSetWifi">确认设置</button></view>
      </view>
    </van-popup>
    <van-popup show="{{ showIP }}" custom-style="width: 90%" bind:close="onCloseIP" round>
      <view class="addword">
        <van-field value="{{ IPName }}" placeholder="请输入IP" label="IP" border="{{ true }}" bind:change="onChangeIP" />
        <van-field value="{{ IPport }}" placeholder="请输入端口" label="PORT" border="{{ true }}" bind:change="onChangeIP1" />
        <view class=""><button type="primary" bindtap="confirmSetIP">确认设置</button></view>
      </view>
    </van-popup>
    <van-popup show="{{ showRoom }}" custom-style="width: 90%" bind:close="onCloseRoom" round>
      <view class="addword">
        <van-cell-group>
          <picker bindchange="bindPickerChange" value="{{index}}" range="{{firstAuthList}}">
            <van-cell title="请选房源" value="{{selectRoomList[0].name}}" is-link />
          </picker>
          <picker bindchange="bindPickerChangeSecond" value="{{indexSecond}}" range="{{secondAuthList}}">
            <van-cell title="请选楼宇" value="{{selectRoomList[1].name}}" is-link />
          </picker>
          <picker bindchange="bindPickerChangeThree" value="{{indexThree}}" range="{{threeAuthList}}">
            <van-cell title="请选单元" value="{{selectRoomList[2].name}}" is-link />
          </picker>
          <picker bindchange="bindPickerChangeFour" value="{{indexFour}}" range="{{fourAuthList}}">
            <van-cell title="请选楼层" value="{{selectRoomList[3].name}}" is-link />
          </picker>
          <picker bindchange="bindPickerChangeFive" value="{{indexFive}}" range="{{romeLockerList}}">
            <van-cell title="请选房间" value="{{selectRoomList[4].name}}" is-link />
          </picker>
        </van-cell-group>
        <!-- <view class=""><button type="primary" bindtap="issueFiveSetKey">确认下发</button></view> -->
        <view class=""><button type="primary" bindtap="sendSetKey">确认下发</button></view>
      </view>
    </van-popup>
  </view>
</view>
<view class="containerOne" wx:else>
  <view class="lock-info">
    <view class="line-container">
      <text class="mac">设备MAC</text>
      <text class="type">{{lock.mac}}</text>
    </view>
    <view class="line-container">
      <view class="line" />
    </view>
    <view class="line-container">
      <text class="mac">设备类型</text>
      <text class="type">{{lock.lockType}}</text>
    </view>
    <view class="line-container">
      <text class="mac">绑定房间</text>
      <text class="type">{{deviceInfo.roomName}}</text>
    </view>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="bindLock" disabled="{{isBindLock}}">绑定管理员</button>
    <button class="button-action" type='primary' bindtap="unbindLock" disabled="{{!isBindLock}}">重置门锁</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="changemanId" disabled="{{!resgiterdevice}}">注册到平台</button>
    <!-- <button class="button-action" type='primary' bindtap="changemanId">注册到平台</button> -->
    <button class="button-action" type='primary' bindtap="bindRoomMethods" disabled="{{resgiterdevice}}">绑定房间</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="queryBindState">查询状态</button>
    <button class="button-action" type='primary' bindtap="queryBattery" disabled="{{isJack}}">查询电量</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="queryNbImei" disabled="{{!isNbLock}}">查询IMEI</button>
    <button class="button-action" type='primary' bindtap="login" disabled="{{!isBindLock | lockModel < 70 | isJack}}">进登录态</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="openLock" disabled="{{!isBindLock}}">{{isJack ? '蓝牙上电' : '蓝牙解锁'}}</button>
    <button class="button-action" type='primary' bindtap="syncClock" disabled="{{!isBindLock | isJack}}">同步时钟</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="addPincode" disabled="{{!isBindLock | isPincodeAdd | isJack}}">添加密码</button>
    <button class="button-action" type='primary' bindtap="delPincode" disabled="{{!isBindLock | !isPincodeAdd | isJack}}">删除密码</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="addRfCard" disabled="{{!isBindLock | isRfCardAdd | isJack}}">添加房卡</button>
    <button class="button-action" type='primary' bindtap="delRfCard" disabled="{{!isBindLock | !isRfCardAdd | isJack}}">删除房卡</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="addFingerprint" disabled="{{!isBindLock | !isFpLock | isFingerprintAdd}}">添加指纹</button>
    <button class="button-action" type='primary' bindtap="delFingerprint" disabled="{{!isBindLock | !isFpLock | !isFingerprintAdd}}">删除指纹</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="changeAdminPincode" disabled="{{!isBindLock | !isFpLock}}">修改管理密码</button>
    <button class="button-action" type='primary' bindtap="genOfflinePincode" disabled="{{!isBindLock | isJack}}">生成离线密码</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="queryLockSlotState" disabled="{{!isBindLock}}">查询方舌状态</button>
    <button class="button-action" type='primary' bindtap="queryLockUnlockState" disabled="{{!isBindLock}}">查询门锁状态</button>
  </view>

  <view class='row'>
    <button class="button-action" type='primary' bindtap="changeLockUnlockState" disabled="{{!isBindLock}}">{{isUnloked ? '退出常开模式' : '进入常开模式'}}</button>
    <button class="button-action" type='primary' bindtap="changeLockMutedState" disabled="{{!isBindLock}}">{{isMuted ? '退出静音模式' : '进入静音模式'}}</button>
  </view>
  <view class='row'>
    <button class="button-action" type='primary' bindtap="changeLockNbState" disabled="{{!isBindLock}}">{{isNbEnable ? '禁用NB功能' : '打开NB功能'}}</button>
    <button class="button-action" type='primary' bindtap="changeshow2">配网</button>
  </view>
  <!-- <view class="row">
    <button class="button-action" type="primary" bindtap="addFaceprint">添加人脸</button>
    <button class="button-action" type="primary" bindtap="delFaceprint">删除人脸</button>
  </view> -->
  <van-popup show="{{ show }}" bind:close="onClose" position="bottom" custom-style="height: 60%">
    <tree dataTree="{{dataList}}" selectKey="{{selectKey}}" bind:select="handleSelect" isSelectLastNode="true" isOpenAll="{{false}}"></tree>
  </van-popup>
  <van-popup show="{{ show2 }}" round bind:close="onClose1" custom-style="width: 90%;">
    <view class="wificontact">
      <van-field value="{{ WifiName }}" placeholder="请输入wifi名称" border="{{ false }}" bind:change="onChange" />
      <van-field value="{{ WifiPwd }}" placeholder="请输入wifi密码" border="{{ false }}" bind:change="onChange1" />
      <van-button block type="primary" bindtap="configurewifj">确定</van-button>
    </view>
  </van-popup>
  <!-- 注册到平台的弹出层 -->
  <van-popup show="{{ showreg }}" bind:close="onClosereg" custom-style="width: 85%;" round>
    <view class="regdevice">
      <view class="radiolists">
        <van-radio-group value="{{ selectRadio1 }}" bind:change="onChangeSelectRaio1">
          <van-radio name="1201" class="ma-2">NB智能锁</van-radio>
          <van-radio name="1221" class="ma-2">cat1智能锁</van-radio>
          <van-radio name="1231" class="ma-2">蓝牙锁</van-radio>
          <van-radio name="1241" class="ma-2">Wifi人脸智能锁</van-radio>
        </van-radio-group>
      </view>
      <view class="sheetlist" bindtap="changesheetshow">
        <span class="platformIdlist">选择运营商：</span>
        <span>{{platformname}}</span>
      </view>
      <van-button block type="primary" bindtap="resgiterDeviceMethods1">确定</van-button>
    </view>
  </van-popup>
</view>
<van-action-sheet show="{{ sheetshow }}" actions="{{ actions1 }}" bind:close="onClose1" bind:select="onSelect" />