init
This commit is contained in:
23
xhs-mini-demos/component-case/ibeacon/ibeacon.css
Normal file
23
xhs-mini-demos/component-case/ibeacon/ibeacon.css
Normal file
@@ -0,0 +1,23 @@
|
||||
.page-body-info {
|
||||
margin-top: 25px;
|
||||
padding: 15px 30px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.devices_summary {
|
||||
padding: 5px;
|
||||
font-size: 15px;
|
||||
}
|
||||
.device_list {
|
||||
height: 150px;
|
||||
border-radius: 3px;
|
||||
flex: 1;
|
||||
}
|
||||
.device_item {
|
||||
border-bottom: 1px solid var(--weui-FG-3);
|
||||
padding: 5px;
|
||||
color: var(--weui-FG-HALF);
|
||||
}
|
||||
.device_item_hover {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
47
xhs-mini-demos/component-case/ibeacon/ibeacon.js
Normal file
47
xhs-mini-demos/component-case/ibeacon/ibeacon.js
Normal file
@@ -0,0 +1,47 @@
|
||||
Page({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: 'iBeacon',
|
||||
path: 'packageAPI/pages/ibeacon/ibeacon',
|
||||
};
|
||||
},
|
||||
|
||||
data: {
|
||||
uuid: '',
|
||||
beacons: [],
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
this.stopSearch();
|
||||
},
|
||||
|
||||
enterUuid(e) {
|
||||
this.setData({
|
||||
uuid: e.detail.value,
|
||||
});
|
||||
},
|
||||
|
||||
startSearch() {
|
||||
if (this._searching) return;
|
||||
this._searching = true;
|
||||
xhs.startBeaconDiscovery({
|
||||
uuids: [this.data.uuid],
|
||||
success: res => {
|
||||
console.log(res);
|
||||
xhs.onBeaconUpdate(({ beacons }) => {
|
||||
this.setData({
|
||||
beacons,
|
||||
});
|
||||
});
|
||||
},
|
||||
fail: err => {
|
||||
console.error(err);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
stopSearch() {
|
||||
this._searching = false;
|
||||
xhs.stopBeaconDiscovery();
|
||||
},
|
||||
});
|
||||
3
xhs-mini-demos/component-case/ibeacon/ibeacon.json
Normal file
3
xhs-mini-demos/component-case/ibeacon/ibeacon.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "iBeacon"
|
||||
}
|
||||
29
xhs-mini-demos/component-case/ibeacon/ibeacon.xhsml
Normal file
29
xhs-mini-demos/component-case/ibeacon/ibeacon.xhsml
Normal file
@@ -0,0 +1,29 @@
|
||||
<view class="container">
|
||||
<view class="page-body">
|
||||
<view class="page-section">
|
||||
<view class="weui-cells__title">输入iBeacon设备广播的UUID</view>
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
<view class="weui-cell weui-cell_input">
|
||||
<input class="weui-input" bindinput="enterUuid" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn-area">
|
||||
<button type="primary" bindtap="startSearch">搜索iBeacon</button>
|
||||
<button bindtap="stopSearch">停止搜索</button>
|
||||
</view>
|
||||
<view class="page-body-info">
|
||||
<view class="devices_summary">已发现 {{beacons.length}} 个外围设备:</view>
|
||||
<scroll-view class="device_list" scroll-y scroll-with-animation>
|
||||
<view xhs:for="{{beacons}}" xhs:key="index"
|
||||
class="device_item"
|
||||
hover-class="device_item_hover">
|
||||
<view style="font-size: 16px; color: #333;">主ID: {{item.major}} <text style="font-size: 12px;">次ID: {{item.minor}}</text></view>
|
||||
<view style="font-size: 10px">信号强度: {{item.rssi}}dBm</view>
|
||||
<view style="font-size: 10px">UUID: {{item.uuid}}</view>
|
||||
<view style="font-size: 10px">Proximity: {{item.proximity}} Accuracy: {{item.accuracy}}</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user