bluetooth.wxml 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <page>
  2. <wxs module="utils">
  3. module.exports.max = function (n1, n2) {
  4. return Math.max(n1, n2)
  5. }
  6. module.exports.len = function (arr) {
  7. arr = arr || []
  8. return arr.length
  9. }
  10. </wxs>
  11. <view class="page-bluebooth-list" style="display:{{scanBtn}}">
  12. <view class="body-toolBar">
  13. <image class="bltImg" src="/images/blt-link.png"></image>
  14. <view style="display: flex;flex-direction: row;justify-content: center;">
  15. <button class="scanBtn" loading="{{isFinding}}" bindtap="scanBluetoothDevicesHandle">{{btnName}}</button>
  16. <view bindtap="onStartQr" style="margin-top: 25rpx;margin-left: 40rpx;width:50rpx;height:50rpx;background-color: white;border-radius: 50%;box-shadow:0 0 10rpx 10rpx white;">
  17. <image src='/images/scan.png' style="width:50rpx;height:50rpx;" > </image>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="body-content">
  22. <view class="device-list-box">
  23. <scroll-view class="device_list" scroll-y scroll-with-animation>
  24. <view class="devices_summary">
  25. <text>扫描到的新设备: </text><text style="color:#FD7400;">{{devices.length}}</text>
  26. </view>
  27. <view class="devicesBox">
  28. <view wx:for="{{devices}}" wx:key="index" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" class="device_item">
  29. <view class="bluetooth-status-box">
  30. <view class="bluebooth-status-line">
  31. <view class="bluebooth-status-image-view">
  32. <image id="{{item.icon}}" src='/images/bluebooth.png'></image>
  33. </view>
  34. <view class="bluebooth-status-name-view">
  35. <text>{{item.name}}</text>
  36. </view>
  37. </view>
  38. <view class="bluebooth-status-info-sub">
  39. <text>信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</text>
  40. </view>
  41. <view class="bluebooth-status-info-sub">
  42. <text>UUID: {{item.deviceId}}</text>
  43. </view>
  44. </view>
  45. <view class="bluebooth-process-box">
  46. <view class="bluebooth-process-btn">
  47. <button style="margin-right: 10px;" hover-class='blue-icon-button-hover' size="mini" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" bindtouchend="onBLEConnectionHandle">连接设备</button>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="devices_summary">
  53. <text>最近连接的设备: </text>
  54. </view>
  55. <view class="devicesBox">
  56. <view wx:for="{{alreadyConnectDevices}}" wx:key="index" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" class="device_item">
  57. <view class="bluetooth-status-box">
  58. <view class="bluebooth-status-line">
  59. <view class="bluebooth-status-image-view">
  60. <image id="{{item.icon}}" src='/images/bluebooth.png'></image>
  61. </view>
  62. <view class="bluebooth-status-name-view">
  63. <text>{{item.name}}</text>
  64. </view>
  65. </view>
  66. <!-- <view class="bluebooth-status-info-sub">
  67. <text>信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</text>
  68. </view> -->
  69. <view class="bluebooth-status-info-sub">
  70. <text>UUID: {{item.deviceId}}</text>
  71. </view>
  72. </view>
  73. <view class="bluebooth-process-box">
  74. <view class="bluebooth-process-btn">
  75. <button style="margin-right: 10px;" hover-class='blue-icon-button-hover' size="mini" data-device-id="{{item.deviceId}}" data-name="{{item.name || item.localName}}" bindtouchend="onBLEConnectionHandle">连接设备</button>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </scroll-view>
  81. </view>
  82. </view>
  83. </view>
  84. <mp-dialog title="操作提示" show="{{showBleOpenFailDig}}" bindbuttontap="bluetoothOpenEvent" buttons="{{[ {text: '取消'}, {text: '重试'}]}}">
  85. <view>当前蓝牙不可用,请检查手机蓝牙是否已打开后再试!</view>
  86. </mp-dialog>
  87. <mp-dialog title="操作提示" show="{{showBleOtherErrorDig}}" bindbuttontap="bluetoothOtherErrorEvent" buttons="{{[ {text: '确定'}]}}">
  88. <view>{{bleOtherErrorReeponseMsg}}</view>
  89. </mp-dialog>
  90. <!-- <view class="qrbtn">
  91. <button type="primary" bindtouchend="onStartQr">扫码连接</button>
  92. </view> -->
  93. <loading hidden="{{loadingHidden}}"></loading>
  94. </page>