Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const stores_bluetooth = require("../../stores/bluetooth.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "bluetooth",
setup(__props) {
const bluetoothStore = stores_bluetooth.useBluetoothStore();
const toggleScan = () => {
if (bluetoothStore.isDiscovering) {
bluetoothStore.stopScan();
} else {
bluetoothStore.startScan();
}
};
const connect = async (deviceId) => {
if (bluetoothStore.isConnected) {
await bluetoothStore.disconnect();
}
await bluetoothStore.connect(deviceId);
if (bluetoothStore.isConnected) {
common_vendor.index.showToast({ title: "连接成功", icon: "success" });
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
}
};
const disconnect = async () => {
await bluetoothStore.disconnect();
common_vendor.index.showToast({ title: "已断开连接", icon: "none" });
};
const getSignalStrength = (rssi) => {
if (rssi >= -50) return "📶";
if (rssi >= -70) return "📡";
return "📴";
};
return (_ctx, _cache) => {
var _a;
return common_vendor.e({
a: common_vendor.t(common_vendor.unref(bluetoothStore).isDiscovering ? "⏹️" : "🔍"),
b: common_vendor.t(common_vendor.unref(bluetoothStore).isDiscovering ? "停止搜索" : "搜索设备"),
c: common_vendor.unref(bluetoothStore).isDiscovering ? 1 : "",
d: common_vendor.o(toggleScan),
e: common_vendor.unref(bluetoothStore).isConnected
}, common_vendor.unref(bluetoothStore).isConnected ? {
f: common_vendor.t((_a = common_vendor.unref(bluetoothStore).connectedDevice) == null ? void 0 : _a.name),
g: common_vendor.o(disconnect)
} : {}, {
h: common_vendor.unref(bluetoothStore).deviceList.length > 0
}, common_vendor.unref(bluetoothStore).deviceList.length > 0 ? {
i: common_vendor.f(common_vendor.unref(bluetoothStore).deviceList, (device, k0, i0) => {
return {
a: common_vendor.t(device.name),
b: common_vendor.t(device.deviceId),
c: common_vendor.t(getSignalStrength(device.RSSI)),
d: device.deviceId,
e: common_vendor.o(($event) => connect(device.deviceId), device.deviceId)
};
})
} : {});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b0f86abb"]]);
wx.createPage(MiniProgramPage);
+6
View File
@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "蓝牙连接",
"navigationBarBackgroundColor": "#3366ff",
"navigationBarTextStyle": "white",
"usingComponents": {}
}
+1
View File
@@ -0,0 +1 @@
<view class="container data-v-b0f86abb"><view class="scan-header data-v-b0f86abb"><view class="{{['scan-btn', 'data-v-b0f86abb', c && 'scanning']}}" bindtap="{{d}}"><text class="scan-icon data-v-b0f86abb">{{a}}</text><text class="data-v-b0f86abb">{{b}}</text></view></view><view class="status-section data-v-b0f86abb"><view wx:if="{{e}}" class="status-item connected data-v-b0f86abb"><text class="status-dot data-v-b0f86abb"></text><text class="status-text data-v-b0f86abb">已连接接 {{f}}</text><view class="disconnect-btn data-v-b0f86abb" bindtap="{{g}}">断开</view></view><view wx:else class="status-item disconnected data-v-b0f86abb"><text class="status-dot data-v-b0f86abb"></text><text class="status-text data-v-b0f86abb">未连接接设备</text></view></view><view wx:if="{{h}}" class="device-list data-v-b0f86abb"><view class="list-title data-v-b0f86abb"><text class="list-icon data-v-b0f86abb">📱</text><text class="data-v-b0f86abb">可用设备</text></view><view wx:for="{{i}}" wx:for-item="device" wx:key="d" class="device-item data-v-b0f86abb" bindtap="{{device.e}}"><view class="device-info data-v-b0f86abb"><text class="device-icon data-v-b0f86abb">📦</text><view class="device-detail data-v-b0f86abb"><text class="device-name data-v-b0f86abb">{{device.a}}</text><text class="device-id data-v-b0f86abb">{{device.b}}</text></view></view><view class="device-signal data-v-b0f86abb"><text class="data-v-b0f86abb">{{device.c}}</text></view></view></view><view wx:else class="empty-state data-v-b0f86abb"><text class="empty-icon data-v-b0f86abb">📡</text><text class="empty-text data-v-b0f86abb">暂无可用设备</text><text class="empty-hint data-v-b0f86abb">请确保电子秤已开启蓝牙</text></view><view class="tips-card data-v-b0f86abb"><text class="tips-icon data-v-b0f86abb">💡</text><text class="tips-text data-v-b0f86abb">搜索范围10米,设备名称通常包含"Scale"</text></view></view>
+171
View File
@@ -0,0 +1,171 @@
.container.data-v-b0f86abb {
min-height: 100vh;
background: #f5f5f5;
padding: 32rpx;
}
.scan-header.data-v-b0f86abb {
margin-bottom: 24rpx;
}
.scan-btn.data-v-b0f86abb {
background: #fff;
border-radius: 40rpx;
padding: 24rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 600;
color: #3366ff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
}
.scan-btn.scanning.data-v-b0f86abb {
background: #fee2e2;
color: #ef4444;
}
.scan-icon.data-v-b0f86abb {
margin-right: 12rpx;
}
.status-section.data-v-b0f86abb {
margin-bottom: 32rpx;
}
.status-item.data-v-b0f86abb {
display: flex;
align-items: center;
padding: 20rpx 24rpx;
border-radius: 12rpx;
}
.status-item.connected.data-v-b0f86abb {
background: #dcfce7;
}
.status-item.disconnected.data-v-b0f86abb {
background: #fef2f2;
}
.status-dot.data-v-b0f86abb {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
margin-right: 12rpx;
}
.connected .status-dot.data-v-b0f86abb {
background: #22c55e;
}
.disconnected .status-dot.data-v-b0f86abb {
background: #ef4444;
}
.status-text.data-v-b0f86abb {
flex: 1;
font-size: 28rpx;
}
.connected .status-text.data-v-b0f86abb {
color: #166534;
}
.disconnected .status-text.data-v-b0f86abb {
color: #991b1b;
}
.disconnect-btn.data-v-b0f86abb {
font-size: 26rpx;
color: #ef4444;
padding: 8rpx 20rpx;
background: rgba(239, 68, 68, 0.1);
border-radius: 8rpx;
}
.device-list.data-v-b0f86abb {
background: #fff;
border-radius: 16rpx;
overflow: hidden;
margin-bottom: 24rpx;
}
.list-title.data-v-b0f86abb {
display: flex;
align-items: center;
padding: 24rpx;
font-size: 30rpx;
font-weight: 600;
color: #333;
border-bottom: 1rpx solid #f0f0f0;
}
.list-icon.data-v-b0f86abb {
margin-right: 12rpx;
}
.device-item.data-v-b0f86abb {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.device-item.data-v-b0f86abb:last-child {
border-bottom: none;
}
.device-item.data-v-b0f86abb:active {
background: #f9fafb;
}
.device-info.data-v-b0f86abb {
display: flex;
align-items: center;
flex: 1;
}
.device-icon.data-v-b0f86abb {
font-size: 40rpx;
margin-right: 16rpx;
}
.device-detail.data-v-b0f86abb {
display: flex;
flex-direction: column;
}
.device-name.data-v-b0f86abb {
font-size: 30rpx;
font-weight: 600;
color: #333;
margin-bottom: 4rpx;
}
.device-id.data-v-b0f86abb {
font-size: 22rpx;
color: #999;
}
.device-signal.data-v-b0f86abb {
font-size: 26rpx;
color: #666;
padding: 6rpx 16rpx;
background: #f3f4f6;
border-radius: 20rpx;
}
.empty-state.data-v-b0f86abb {
display: flex;
flex-direction: column;
align-items: center;
padding: 80rpx 40rpx;
background: #fff;
border-radius: 16rpx;
margin-bottom: 24rpx;
}
.empty-icon.data-v-b0f86abb {
font-size: 80rpx;
margin-bottom: 20rpx;
}
.empty-text.data-v-b0f86abb {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 8rpx;
}
.empty-hint.data-v-b0f86abb {
font-size: 26rpx;
color: #999;
}
.tips-card.data-v-b0f86abb {
background: #eff6ff;
border: 1rpx solid #dbeafe;
border-radius: 12rpx;
padding: 20rpx 24rpx;
display: flex;
align-items: center;
}
.tips-icon.data-v-b0f86abb {
font-size: 32rpx;
margin-right: 12rpx;
}
.tips-text.data-v-b0f86abb {
font-size: 26rpx;
color: #1e40af;
}