<template>
  <!--
	1.手机蓝牙打开
	2.微信也许访问蓝牙和位置信息
	3.重启蓝牙设备
	4.不行的时候,删掉手机中蓝牙,重新链接
	-->
  <view class="content">

    <button size="mini" type="primary" @tap="startBluetoothDeviceDiscovery">搜索周边设备</button>
    <button size="mini" type="warn" @tap="stopBluetoothDevicesDiscovery">停止搜索</button>
    <button type="primary" @tap="labelTest">测试打印</button>

    <scroll-view class="device_list" scroll-y="true" show-scrollbar="true">
      <radio-group>
        <!--  v-if="item.name.length>0" -->
        <view v-for="(item,index) in devicesList" :key="index" class="device_item">
          <view style="font-size: 32rpx; color: #333;">
            <radio :value="item.deviceId" @tap="select_deviceId(item)" />{{ item.name }}
          </view>
          <view style="font-size: 20rpx">信号强度: {{ item.RSSI }}dBm ({{ Math.max(100+item.RSSI,0) }}%)</view>
          <view style="font-size: 20rpx">deviceId: {{ item.deviceId }}</view>
          <view style="font-size: 20rpx">Service数量: {{ item.advertisServiceUUIDs.length || 0 }}</view>

          <radio-group v-if="deviceId===item.deviceId">
            <view
              v-for="(service,service_index) in serviceList"
              :key="service_index"
              style="font-size: 20rpx"
            >
              <radio style="transform:scale(0.7)" :value="service.uuid" @tap="select_service(service)" />
              {{ service.uuid }}
            </view>
          </radio-group>
        </view>
      </radio-group>
    </scroll-view>
    <canvas canvas-id="shareCanvas" style="width: 240px; height: 240px;" />
  </view>
</template>

<script>
// import PrinterJobs from '@/unit/print/printerjobs.js'
// import printerUtil from '@/unit/print/printerutil.js'
// import util from '@/unit/print/util.js'
// import drawQrcode from '@/unit/print/weapp.qrcode.esm.js'
import Bluetooth from '@/unit/print/bluetooth.js'
import tsc from '@/unit/CHITEN_SDK_APP/tsc.js'
// import encode from '@/unit/CHITEN_SDK_APP/encoding.js'

const bluetooth = new Bluetooth()

export default {
  components: {},
  data() {
    return {
      isOpenBle: false, // 是否已经打开蓝牙，默认为false
      devicesList: [], // 设备列表
      serviceList: [], // 服务列表
      deviceId: '', // 选中的deviceId
      data: {
        looptime: 0,
        currentTime: 1,
        lastData: 0,
        oneTimeData: 0,
        buffSize: [],
        buffIndex: 0,
        printNum: [],
        printNumIndex: 0,
        printerNum: 1,
        currentPrint: 1,
        isLabelSend: false,
        isQuery: false
      }
    }
  },
  // 页面卸载是关闭蓝牙链接
  onUnload() {
    bluetooth.closeBLEConnection()
    bluetooth.closeBluetoothAdapter()
  },
  // 页面打开,获取位置,打开蓝牙链接
  onLoad() {
    this.initBlueUnit()
    uni.getLocation({
      type: 'wgs84',
      success: function(res) {
        console.log('当前位置的经度：' + res.longitude)
        console.log('当前位置的纬度：' + res.latitude)
      }
    })

    bluetooth.openBluetoothAdapter()
  },
  methods: {
    initBlueUnit: function() {
      this.data = {
        looptime: 0,
        currentTime: 1,
        lastData: 0,
        oneTimeData: 0,
        buffSize: [],
        buffIndex: 0,
        printNum: [],
        printNumIndex: 0,
        printerNum: 1,
        currentPrint: 1,
        isLabelSend: false,
        isQuery: false
      }
      var list = []
      var numList = []
      var j = 0
      for (let i = 10; i < 200; i += 10) {
        list[j] = i
        j++
      }
      for (let i = 1; i < 10; i++) {
        numList[i - 1] = i
      }
      this.data.buffSize = list // [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190]
      this.data.oneTimeData = list[1] // 20
      this.data.printNum = numList // [1,2,3,4,5,6,7,8,9]
      this.data.printerNum = numList[0] // 1
    },
    Send: async function(buff) {
      console.log(bluetooth)
      const _this = this
      var currentTime = this.data.currentTime
      var loopTime = this.data.looptime
      var lastData = this.data.lastData
      var onTimeData = this.data.oneTimeData
      var printNum = this.data.printerNum
      var currentPrint = this.data.currentPrint
      var buf
      var dataView
      if (currentTime < loopTime) {
        buf = new ArrayBuffer(onTimeData)
        dataView = new DataView(buf)
        for (let i = 0; i < onTimeData; ++i) {
          dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
        }
      } else {
        buf = new ArrayBuffer(lastData)
        dataView = new DataView(buf)
        for (let i = 0; i < lastData; ++i) {
          dataView.setUint8(i, buff[(currentTime - 1) * onTimeData + i])
        }
      }
      console.log(bluetooth.deviceId,
        bluetooth.serviceId,
        bluetooth.writeId)
      await plus.bluetooth.writeBLECharacteristicValue({
        deviceId: bluetooth.deviceId,
        serviceId: bluetooth.serviceId,
        characteristicId: bluetooth.writeId,
        value: buf,
        success: function(res) {
          if (currentPrint === printNum) {
            wx.showToast({
              title: '已打印第' + currentPrint + '张成功'
            })
          }
        },
        fail: function(e) {
          console.log(e)
          wx.showToast({
            title: '打印第' + currentPrint + '张失败',
            icon: 'none'
          })
        },
        complete: function() {
          currentTime++
          if (currentTime <= loopTime) {
            // console.log(_this.data.currentTime, currentTime);
            _this.data.currentTime = currentTime
            _this.Send(buff)
          } else {
            if (currentPrint === printNum) {
              _this.data.looptime = 0
              _this.data.lastData = 0
              _this.data.currentTime = 1
              _this.data.isLabelSend = false
              _this.data.currentPrint = 0
            } else {
              currentPrint++
              _this.data.currentPrint = currentPrint
              _this.data.currentTime = 1
              _this.Send(buff)
            }
          }
        }
      })
    },
    prepareSend: function(buff) {
      var time = this.data.oneTimeData
      var looptime = parseInt(buff.length / time)
      var lastData = parseInt(buff.length % time)
      this.data.looptime = looptime + 1
      this.data.lastData = lastData
      this.data.currentTime = 1
      this.Send(buff)
    },
    labelTest: function() {
      this.initBlueUnit()

      var command = tsc.dlabelPrinter.createNew()
      // command.setSize(40, 30);
      // 此指令可将标签纸向前推送至下一张标签纸的起点开始打印
      // command.setHome();
      // 向上拉回指定长度
      command.setBackFeed(6)
      command.setSize(80, 40)
      // 清除数据缓存
      command.setCls()
      // 设置两张标签之间的间隙距离
      command.setGap(8)
      // 设置方框
      command.setBox(0, 0, 635, 315, 1)
      command.setBar(0, 40, 640, 2)
      command.setBar(0, 80, 640, 2)
      command.setBar(0, 120, 640, 2)
      command.setBar(0, 160, 640, 2)
      command.setBar(0, 200, 366, 2)
      command.setBar(0, 240, 366, 2)
      command.setBar(0, 280, 640, 2)
      // command.setBar(0, 320, 366, 2);
      // 竖线-1
      command.setBar(115, 0, 2, 40)
      command.setBar(115, 40, 2, 40)
      command.setBar(115, 80, 2, 40)
      command.setBar(115, 120, 2, 40)
      command.setBar(115, 160, 2, 40)
      command.setBar(115, 200, 2, 40)
      command.setBar(115, 240, 2, 40)
      command.setBar(115, 280, 2, 40)
      // 竖线-2
      command.setBar(360, 40, 2, 40)
      command.setBar(360, 80, 2, 40)
      command.setBar(360, 120, 2, 40)
      command.setBar(360, 160, 2, 40)
      command.setBar(360, 200, 2, 40)
      command.setBar(360, 240, 2, 40)
      command.setBar(360, 280, 2, 40)
      // 竖线-3
      command.setBar(475, 40, 2, 40)
      command.setBar(475, 80, 2, 40)
      command.setBar(475, 120, 2, 40)
      command.setBar(475, 280, 2, 40)
      /*
				// 文字
				command.setText(10, 6, "TSS24.BF2", 0, 1, 1, "物料名称")
				command.setText(126, 6, "TSS24.BF2", 0, 1, 1, "0.053mm透明保护膜8-15g(XD-P51Y)鑫道")
				// row2
				command.setText(10, 46, "TSS24.BF2", 0, 1, 1, "物料编码")
				command.setText(126, 46, "TSS24.BF2", 0, 1, 1, "3221000229")
				command.setText(366, 46, "TSS24.BF2", 0, 1, 1, "供应商")
				command.setText(481, 46, "TSS24.BF2", 0, 1, 1, "深圳华强北")
				// row3
				command.setText(10, 86, "TSS24.BF2", 0, 1, 1, "物料规格")
				command.setText(126, 86, "TSS24.BF2", 0, 1, 1, "80mm*250mm")
				command.setText(366, 86, "TSS24.BF2", 0, 1, 1, "分切日期")
				command.setText(481, 86, "TSS24.BF2", 0, 1, 1, "2023-07-29")
				// row4
				command.setText(10, 126, "TSS24.BF2", 0, 1, 1, "Lot no.")
				command.setText(126, 126, "TSS24.BF2", 0, 1, 1, "W08-230628-0064")
				command.setText(366, 126, "TSS24.BF2", 0, 1, 1, "储位")
				command.setText(481, 126, "TSS24.BF2", 0, 1, 1, "L-11")
				// row5
				command.setText(10, 166, "TSS24.BF2", 0, 1, 1, "场内批次号")
				command.setText(126, 166, "TSS24.BF2", 0, 1, 1, "W08-230628-0064-001")
				// row6
				command.setText(10, 206, "TSS24.BF2", 0, 1, 1, "检测日期")
				command.setText(126, 206, "TSS24.BF2", 0, 1, 1, "2023-06-28")
				// row7
				command.setText(10, 246, "TSS24.BF2", 0, 1, 1, "存储条件")
				command.setText(126, 246, "TSS24.BF2", 0, 1, 1, "2-5°≤40%")
				// row8
				command.setText(10, 286, "TSS24.BF2", 0, 1, 1, "分切单号")
				command.setText(126, 286, "TSS24.BF2", 0, 1, 1, "230705004")
				command.setText(366, 286, "TSS24.BF2", 0, 1, 1, "生产日期")
				command.setText(481, 286, "TSS24.BF2", 0, 1, 1, "2023-06-26")
				*/

      command.setQrcode(366, 166, 'L', 5, 'A', '1025849662131312')

      // command.setBarCode(120, 170, "128", 48, 0, 0, 2, 2, "12345678")
      // command.setBar(300, 80, 5, 150);
      command.setPagePrint()
      this.data.isLabelSend = true
      this.prepareSend(command.getData())
    },

    // 搜索周边设备
    startBluetoothDeviceDiscovery() {
      uni.showLoading({
        title: '蓝牙搜索中'
      })

      const self = this
      self.devicesList = []

      setTimeout(() => {
        plus.bluetooth.startBluetoothDevicesDiscovery({
          success: res => {
            plus.bluetooth.onBluetoothDeviceFound(devices => {
              // console.log("发现设备: " + JSON.stringify(devices));
              // 不重复,就添加到devicesList中,
              if (!self.devicesList.some(item => {
                return item.deviceId === devices.devices[0]
                  .deviceId
              })) {
                if (devices.devices[0]?.name !== '') {
                  self.devicesList.push(devices.devices[0])
                }
              }
            })
          },
          fail: res => {
            uni.hideLoading()
            // self.showToast(`搜索设备失败` + JSON.stringify(err))
          }
        })
      }, 200)
    },

    // 停止搜索蓝牙设备
    stopBluetoothDevicesDiscovery() {
      uni.hideLoading()
      bluetooth.stopBluetoothDevicesDiscovery()
    },

    // 选中设备
    async select_deviceId(item) {
      this.deviceId = item.deviceId
      bluetooth.deviceId = item.deviceId
      uni.setStorageSync('deviceId', bluetooth.deviceId)

      this.serviceList = []

      try {
        // 1.链接设备
        // const result = await bluetooth.createBLEConnection()
        // 2.寻找服务
        const result2 = await bluetooth.getBLEDeviceServices()

        console.log('获取服务: ' + JSON.stringify(result2))

        this.serviceList = result2
      } catch (e) {
        // TODO handle the exception
        console.log('e: ' + JSON.stringify(e))
        if (e.message === 'already connect') {
          // 2.寻找服务
          const result2 = await bluetooth.getBLEDeviceServices()
          this.serviceList = result2
        }
      }
    },

    // 选中服务
    async select_service(res) {
      bluetooth.serviceId = res.uuid
      uni.setStorageSync('serviceId', res.uuid)
      // console.log(JSON.parse(JSON.stringify(this.serviceList)));

      try {
        // const result = await bluetooth.getBLEDeviceCharacteristics()
      } catch (e) {
        // TODO handle the exception
        console.log('e: ' + JSON.stringify(e))
      }
    },

    // 打印一次
    pickUpOnce() {
      bluetooth.notifyBLECharacteristicValue()
      const self = this
      setTimeout(() => {
        self.writeBLECharacteristicValue()
      }, 500)
    },

    // 写入控制命令
    async writeBLECharacteristicValue() {
      // 打印机可识别的数据格式为8进制格式, 如下
      // 转换为8位无符号整型数组
      const buffer = new Uint8Array([
        66, 65, 67, 75, 70, 69, 69, 68, 32, 54, 13, 10, 83, 73, 90, 69, 32, 54, 48, 32, 109, 109,
        44, 52, 48, 32, 109, 109, 13, 10, 67, 76, 83, 13, 10, 71, 65, 80, 32, 56, 32, 109, 109, 44,
        48, 32, 109, 109, 13, 10, 66, 79, 88, 32, 48, 44, 48, 44, 52, 55, 53, 44, 51, 49, 53, 44,
        49, 13, 10, 66, 65, 82, 32, 48, 44, 52, 48, 44, 52, 56, 48, 44, 50, 13, 10, 66, 65, 82, 32,
        48, 44, 56, 48, 44, 52, 56, 48, 44, 50, 13, 10, 66, 65, 82, 32, 48, 44, 49, 50, 48, 44, 52,
        56, 48, 44, 50, 13, 10, 66, 65, 82, 32, 48, 44, 49, 54, 48, 44, 52, 56, 48, 44, 50, 13, 10,
        66, 65, 82, 32, 48, 44, 50, 48, 48, 44, 51, 54, 54, 44, 50, 13, 10, 66, 65, 82, 32, 48, 44,
        50, 52, 48, 44, 51, 54, 54, 44, 50, 13, 10, 66, 65, 82, 32, 48, 44, 50, 56, 48, 44, 51, 54,
        54, 44, 50, 13, 10, 66, 65, 82, 32, 48, 44, 51, 50, 48, 44, 51, 54, 54, 44, 50, 13, 10, 66,
        65, 82, 32, 49, 49, 53, 44, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 49, 49, 53, 44,
        52, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 49, 49, 53, 44, 56, 48, 44, 50, 44, 52,
        48, 13, 10, 66, 65, 82, 32, 49, 49, 53, 44, 49, 50, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65,
        82, 32, 49, 49, 53, 44, 49, 54, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 49, 49, 53,
        44, 50, 48, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 49, 49, 53, 44, 50, 52, 48, 44,
        50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 49, 49, 53, 44, 50, 56, 48, 44, 50, 44, 52, 48, 13,
        10, 66, 65, 82, 32, 51, 54, 48, 44, 52, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 51,
        54, 48, 44, 56, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 51, 54, 48, 44, 49, 50, 48,
        44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 51, 54, 48, 44, 49, 54, 48, 44, 50, 44, 52, 48,
        13, 10, 66, 65, 82, 32, 51, 54, 48, 44, 50, 48, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82,
        32, 51, 54, 48, 44, 50, 52, 48, 44, 50, 44, 52, 48, 13, 10, 66, 65, 82, 32, 51, 54, 48, 44,
        50, 56, 48, 44, 50, 44, 52, 48, 13, 10, 84, 69, 88, 84, 32, 49, 48, 44, 54, 44, 34, 84, 83,
        83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44, 34, 206, 239, 193, 207, 195,
        251, 179, 198, 34, 13, 10, 84, 69, 88, 84, 32, 49, 50, 54, 44, 54, 44, 34, 84, 83, 83, 50,
        52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44, 34, 48, 46, 48, 53, 51, 109, 109, 205,
        184, 195, 247, 177, 163, 187, 164, 196, 164, 56, 45, 49, 53, 103, 40, 88, 68, 45, 80, 53,
        49, 89, 41, 246, 206, 181, 192, 34, 13, 10, 84, 69, 88, 84, 32, 49, 48, 44, 52, 54, 44, 34,
        84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44, 34, 206, 239, 193, 207,
        177, 224, 194, 235, 34, 13, 10, 84, 69, 88, 84, 32, 49, 50, 54, 44, 52, 54, 44, 34, 84, 83,
        83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44, 34, 51, 50, 50, 49, 48, 48, 48,
        50, 50, 57, 34, 13, 10, 84, 69, 88, 84, 32, 51, 54, 54, 44, 52, 54, 44, 34, 84, 83, 83, 50,
        52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44, 34, 185, 169, 211, 166, 201, 204, 34,
        13, 10, 84, 69, 88, 84, 32, 49, 48, 44, 56, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50,
        34, 44, 48, 44, 49, 44, 49, 44, 34, 206, 239, 193, 207, 185, 230, 184, 241, 34, 13, 10, 84,
        69, 88, 84, 32, 49, 50, 54, 44, 56, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44,
        48, 44, 49, 44, 49, 44, 34, 56, 48, 109, 109, 42, 50, 53, 48, 109, 109, 34, 13, 10, 84, 69,
        88, 84, 32, 51, 54, 54, 44, 56, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48,
        44, 49, 44, 49, 44, 34, 183, 214, 199, 208, 200, 213, 198, 218, 34, 13, 10, 84, 69, 88, 84,
        32, 49, 48, 44, 49, 50, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49,
        44, 49, 44, 34, 76, 111, 116, 32, 110, 111, 46, 34, 13, 10, 84, 69, 88, 84, 32, 49, 50, 54,
        44, 49, 50, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44,
        34, 87, 48, 56, 45, 50, 51, 48, 54, 50, 56, 45, 48, 48, 54, 52, 34, 13, 10, 84, 69, 88, 84,
        32, 51, 54, 54, 44, 49, 50, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44,
        49, 44, 49, 44, 34, 180, 162, 206, 187, 34, 13, 10, 84, 69, 88, 84, 32, 49, 48, 44, 49, 54,
        54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44, 34, 179,
        161, 196, 218, 197, 250, 180, 206, 186, 197, 34, 13, 10, 84, 69, 88, 84, 32, 49, 50, 54,
        44, 49, 54, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49, 44,
        34, 87, 48, 56, 45, 50, 51, 48, 54, 50, 56, 45, 48, 48, 54, 52, 45, 48, 48, 49, 34, 13, 10,
        84, 69, 88, 84, 32, 49, 48, 44, 50, 48, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34,
        44, 48, 44, 49, 44, 49, 44, 34, 188, 236, 178, 226, 200, 213, 198, 218, 34, 13, 10, 84, 69,
        88, 84, 32, 49, 50, 54, 44, 50, 48, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44,
        48, 44, 49, 44, 49, 44, 34, 50, 48, 50, 51, 45, 48, 54, 45, 50, 56, 34, 13, 10, 84, 69, 88,
        84, 32, 49, 48, 44, 50, 52, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44,
        49, 44, 49, 44, 34, 180, 230, 180, 162, 204, 245, 188, 254, 34, 13, 10, 84, 69, 88, 84, 32,
        49, 50, 54, 44, 50, 52, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49,
        44, 49, 44, 34, 50, 45, 53, 161, 227, 161, 220, 52, 48, 37, 34, 13, 10, 84, 69, 88, 84, 32,
        49, 48, 44, 50, 56, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44,
        49, 44, 34, 183, 214, 199, 208, 181, 165, 186, 197, 34, 13, 10, 84, 69, 88, 84, 32, 49, 50,
        54, 44, 50, 56, 54, 44, 34, 84, 83, 83, 50, 52, 46, 66, 70, 50, 34, 44, 48, 44, 49, 44, 49,
        44, 34, 50, 51, 48, 55, 48, 53, 48, 48, 52, 34, 13, 10, 81, 82, 67, 79, 68, 69, 32, 51, 54,
        54, 44, 49, 54, 54, 44, 76, 44, 53, 44, 65, 44, 48, 44, 34, 49, 48, 50, 53, 56, 52, 57, 54,
        54, 50, 49, 51, 49, 51, 49, 50, 34, 13, 10, 80, 82, 73, 78, 84, 32, 49, 44, 49, 13, 10
      ])

      this.printbuffs(buffer)
    },

    printbuffs(buffer) {
      // 1.并行调用多次会存在写失败的可能性
      // 2.建议每次写入不超过20字节
      // 分包处理，延时调用
      const maxChunk = 20
      const delay = 20
      for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
        const subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length)
        setTimeout(this.printbuff, j * delay, subPackage)
      }
    },

    printbuff(buffer) {
      bluetooth.writeBLECharacteristicValue(buffer)
    }

  }
}
</script>

<style>
	.content {
		height: calc(100vh - 85px);
		margin-top: 85px;
	}

	page {
		color: #333;
	}

	button {
		margin: 10upx;
	}

	.devices_summary {
		margin-top: 5rpx;
		padding: 20rpx;
		font-size: 30rpx;
	}

	.device_list {
		margin: 5rpx 20rpx 5rpx 20rpx;
		border: 1rpx solid #ddd;
		border-radius: 10rpx;
		background-color: #FdFdFd;
		min-height: 0rpx;
		max-height: calc(100vh - 300px);
		width: 700rpx;

	}

	.device_item {
		border-bottom: 1rpx solid #ddd;
		padding: 20rpx;
		color: #666;

	}

	.device_item_hover {
		background-color: rgba(0, 0, 0, .1);
	}

	.connected_info {
		position: fixed;
		bottom: 0;
		width: 100%;
		background-color: #F0F0F0;
		padding: 10px;
		padding-bottom: 20px;
		margin-bottom: env(safe-area-inset-bottom);
		font-size: 14px;
		min-height: 100px;
		box-shadow: 0px 0px 3px 0px;
	}

	.connected_info .operation {
		position: absolute;
		display: inline-block;
		right: 30px;
	}
</style>
