feat: init project with miniprogram, cloud functions and admin console

这个提交包含在:
Guoguo
2026-04-22 21:24:20 +08:00
当前提交 a84e37a6e2
修改 106 个文件,包含 5902 行新增0 行删除
+56
查看文件
@@ -0,0 +1,56 @@
var http = require('../../utils/request')
Page({
data: {
scanning: false,
deviceId: '',
error: ''
},
onScan: function () {
var self = this
self.setData({ scanning: true, error: '' })
wx.scanCode({
onlyFromCamera: true,
scanType: ['qrCode'],
success: function (res) {
var deviceId = self.parseDeviceId(res.result)
if (!deviceId) {
self.setData({ scanning: false, error: '无效的设备二维码' })
return
}
self.bindDevice(deviceId)
},
fail: function () {
self.setData({ scanning: false })
}
})
},
parseDeviceId: function (content) {
if (/^[0-9A-Fa-f]{16}$/.test(content)) return content
try {
var url = new URL(content)
var id = url.searchParams.get('device_id') || url.searchParams.get('id')
return id || null
} catch (e) {
return null
}
},
bindDevice: function (deviceId) {
var self = this
http.post('/api/v1/device/bind', { device_id: deviceId }).then(function (data) {
self.setData({ scanning: false })
wx.navigateTo({
url: '/pages/ble-connect/ble-connect?device_id=' + deviceId + '&bind_token=' + data.bind_token
})
}).catch(function (err) {
self.setData({
scanning: false,
error: err.message || '绑定失败'
})
})
}
})
+3
查看文件
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "扫码绑定"
}
+29
查看文件
@@ -0,0 +1,29 @@
<view class="container">
<view class="card text-center">
<view class="section-title">绑定新设备</view>
<view class="text-muted mb-30">请扫描设备底部或包装盒上的二维码</view>
<view class="btn-primary" bindtap="onScan" disabled="{{scanning}}">
{{scanning ? '扫描中...' : '扫描二维码'}}
</view>
</view>
<view class="card" wx:if="{{error}}">
<text class="text-error">{{error}}</text>
</view>
<view class="card">
<view class="section-title">绑定步骤</view>
<view class="step">
<text class="step-num">1</text>
<text class="step-text">扫描设备二维码获取设备ID</text>
</view>
<view class="step">
<text class="step-num">2</text>
<text class="step-text">打开蓝牙连接设备</text>
</view>
<view class="step">
<text class="step-num">3</text>
<text class="step-text">绑定成功,开始使用</text>
</view>
</view>
</view>
+23
查看文件
@@ -0,0 +1,23 @@
.step {
display: flex;
align-items: center;
padding: 16rpx 0;
}
.step-num {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background-color: #333333;
color: #ffffff;
font-size: 24rpx;
text-align: center;
line-height: 48rpx;
margin-right: 20rpx;
flex-shrink: 0;
}
.step-text {
font-size: 28rpx;
color: #333333;
}