123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <wxs module="utils">
- module.exports.max = function(n1, n2) {
- return Math.max(n1, n2)
- }
- module.exports.len = function(arr) {
- arr = arr || []
- return arr.length
- }
- module.exports.fill0 = function(num) {
- if (!num) {
- return '00'
- }
- return ('00' + num).slice(-2)
- }
- </wxs>
-
- <block wx:if="{{!connected}}">
- <button bindtap="openBluetoothAdapter">开始扫描</button>
- <button bindtap="stopBluetoothDevicesDiscovery">停止扫描</button>
- <button bindtap="closeBluetoothAdapter">结束流程</button>
- <button bindtap="clearDevices">清空列表</button>
- <view class="devices_summary">已发现 {{devices.length}} 个外围设备:</view>
- <view class="device_list">
- <view wx:for="{{devices}}" wx:key="index"
- class="device_item">
- <view style="font-size: 16px; color: #333;">{{item.name || item.localName}}</view>
- <view style="font-size: 10px">信号强度: {{item.RSSI}}dBm ({{utils.max(0, item.RSSI + 100)}}%)</view>
- <view style="font-size: 10px">mac地址: {{item.deviceId}}</view>
- <view
- class="device_item_btn"
- hover-class="btn_hover"
- data-device-id="{{item.deviceId}}"
- data-name="{{item.name || item.localName}}"
- data-index="{{index}}"
- bindtap="createBLEConnection"
- >连接</view>
- </view>
- </view>
- </block>
- <view class="wrap" wx:else>
- <view class="stopConnect">
- <view>{{mac}}</view>
- <view class="btn_connect" hover-class="btn_hover" bindtap="closeBLEConnection">断开连接</view>
- </view>
-
- <view class="btn_wrap">
- <button bindtap="setSystemTime">设置系统时间</button>
- <button bindtap="getSystemTime">获取系统时间</button>
- <button bindtap="updateUserList">更新用户列表</button>
- <button bindtap="updateUserInformation">更新个人用户信息</button>
- <button bindtap="requestHis">请求同步历史记录</button>
- <button bindtap="quit">退回蓝牙连接页面</button>
- </view>
- <!-- <view class="weight_wrap"> -->
- <scroll-view class="log" scroll-y style='height:{{2*height}}rpx' scroll-into-view="{{jumpPoint}}">
- <view class="logList" wx:for="{{information}}">
- {{item}}
- </view>
- </scroll-view>
- </view>
|